diff options
author | Scott Jackson <daneren2005@gmail.com> | 2015-10-22 18:03:27 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2015-10-22 18:03:27 -0700 |
commit | 53cafd6b2e373b5a99260be93e170920c12a33a2 (patch) | |
tree | dccc16c4454697f8c13dd64ec4c103ee9e2c3126 /app/src/main | |
parent | 8d0a62bf99d5d11f5778c346fc969f659ba0ef75 (diff) | |
download | dsub-53cafd6b2e373b5a99260be93e170920c12a33a2.tar.gz dsub-53cafd6b2e373b5a99260be93e170920c12a33a2.tar.bz2 dsub-53cafd6b2e373b5a99260be93e170920c12a33a2.zip |
Missed some files when commit fix for broken preference updating
Diffstat (limited to 'app/src/main')
6 files changed, 27 insertions, 40 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/adapter/SectionAdapter.java b/app/src/main/java/github/daneren2005/dsub/adapter/SectionAdapter.java index 75b1562f..000832d7 100644 --- a/app/src/main/java/github/daneren2005/dsub/adapter/SectionAdapter.java +++ b/app/src/main/java/github/daneren2005/dsub/adapter/SectionAdapter.java @@ -125,7 +125,7 @@ public abstract class SectionAdapter<T> extends RecyclerView.Adapter<UpdateViewH } } } else if (onItemClickedListener != null) { - onItemClickedListener.onItemClicked(item); + onItemClickedListener.onItemClicked(updateView, item); } } }); @@ -138,18 +138,22 @@ public abstract class SectionAdapter<T> extends RecyclerView.Adapter<UpdateViewH moreButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - final T item = holder.getItem(); - if(onItemClickedListener != null) { - PopupMenu popup = new PopupMenu(context, v); - onItemClickedListener.onCreateContextMenu(popup.getMenu(), popup.getMenuInflater(), updateView, item); - - popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { - @Override - public boolean onMenuItemClick(MenuItem menuItem) { - return onItemClickedListener.onContextItemSelected(menuItem, updateView, item); - } - }); - popup.show(); + try { + final T item = holder.getItem(); + if (onItemClickedListener != null) { + PopupMenu popup = new PopupMenu(context, v); + onItemClickedListener.onCreateContextMenu(popup.getMenu(), popup.getMenuInflater(), updateView, item); + + popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { + @Override + public boolean onMenuItemClick(MenuItem menuItem) { + return onItemClickedListener.onContextItemSelected(menuItem, updateView, item); + } + }); + popup.show(); + } + } catch(Exception e) { + Log.w(TAG, "Failed to show popup", e); } } }); @@ -494,7 +498,7 @@ public abstract class SectionAdapter<T> extends RecyclerView.Adapter<UpdateViewH } public interface OnItemClickedListener<T> { - void onItemClicked(T item); + void onItemClicked(UpdateView<T> updateView, T item); void onCreateContextMenu(Menu menu, MenuInflater menuInflater, UpdateView<T> updateView, T item); boolean onContextItemSelected(MenuItem menuItem, UpdateView<T> updateView, T item); } diff --git a/app/src/main/java/github/daneren2005/dsub/adapter/SettingsAdapter.java b/app/src/main/java/github/daneren2005/dsub/adapter/SettingsAdapter.java index d99b294b..0328e607 100644 --- a/app/src/main/java/github/daneren2005/dsub/adapter/SettingsAdapter.java +++ b/app/src/main/java/github/daneren2005/dsub/adapter/SettingsAdapter.java @@ -16,6 +16,7 @@ package github.daneren2005.dsub.adapter; import android.content.Context; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -33,17 +34,19 @@ import github.daneren2005.dsub.view.UpdateView; import static github.daneren2005.dsub.domain.User.Setting; public class SettingsAdapter extends SectionAdapter<Setting> { + private static final String TAG = SettingsAdapter.class.getSimpleName(); public final int VIEW_TYPE_SETTING = 1; private final User user; private final boolean editable; private final ImageLoader imageLoader; - public SettingsAdapter(Context context, User user, ImageLoader imageLoader, boolean editable) { + public SettingsAdapter(Context context, User user, ImageLoader imageLoader, boolean editable, OnItemClickedListener<Setting> onItemClickedListener) { super(context, user.getSettings(), imageLoader != null); this.user = user; this.imageLoader = imageLoader; this.editable = editable; + this.onItemClickedListener = onItemClickedListener; List<Setting> settings = sections.get(0); for(Setting setting: settings) { @@ -92,7 +95,7 @@ public class SettingsAdapter extends SectionAdapter<Setting> { @Override public void setChecked(UpdateView updateView, boolean checked) { if(updateView instanceof SettingView) { - ((SettingView) updateView).setChecked(checked); + updateView.setChecked(checked); } } } diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/AdminFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/AdminFragment.java index d4afa67e..630acf2c 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/AdminFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/AdminFragment.java @@ -16,13 +16,9 @@ package github.daneren2005.dsub.fragments; import android.os.Bundle; -import android.view.ContextMenu; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; -import android.view.View; -import android.widget.AdapterView; -import android.widget.ArrayAdapter; import java.io.File; import java.util.ArrayList; @@ -136,7 +132,7 @@ public class AdminFragment extends SelectRecyclerFragment<User> { } @Override - public void onItemClicked(User user) { + public void onItemClicked(UpdateView<User> updateView, User user) { SubsonicFragment fragment = new UserFragment(); Bundle args = new Bundle(); args.putSerializable(Constants.INTENT_EXTRA_NAME_ID, user); diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/DownloadFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/DownloadFragment.java index edbeff43..7594a99e 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/DownloadFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/DownloadFragment.java @@ -18,17 +18,13 @@ package github.daneren2005.dsub.fragments; import android.content.DialogInterface; import android.os.Bundle; import android.os.Handler; -import android.support.v7.widget.RecyclerView; import android.support.v7.widget.helper.ItemTouchHelper; -import android.view.ContextMenu; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; -import android.widget.AdapterView; -import android.widget.ArrayAdapter; import java.util.ArrayList; import java.util.List; @@ -47,7 +43,6 @@ import github.daneren2005.dsub.util.ProgressListener; import github.daneren2005.dsub.util.SilentBackgroundTask; import github.daneren2005.dsub.util.Util; import github.daneren2005.dsub.adapter.DownloadFileAdapter; -import github.daneren2005.dsub.view.SongView; import github.daneren2005.dsub.view.UpdateView; public class DownloadFragment extends SelectRecyclerFragment<DownloadFile> implements SectionAdapter.OnItemClickedListener<DownloadFile> { @@ -125,7 +120,7 @@ public class DownloadFragment extends SelectRecyclerFragment<DownloadFile> imple } @Override - public void onItemClicked(DownloadFile item) { + public void onItemClicked(UpdateView<DownloadFile> updateView, DownloadFile item) { } diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/MainFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/MainFragment.java index cb94ed19..5d12c2df 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/MainFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/MainFragment.java @@ -2,8 +2,6 @@ package github.daneren2005.dsub.fragments; import android.content.res.Resources; import android.os.Environment; -import android.support.v7.app.AlertDialog; -import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.net.Uri; @@ -14,24 +12,19 @@ import android.util.Log; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; -import android.view.View; -import android.widget.CheckBox; import github.daneren2005.dsub.R; import github.daneren2005.dsub.adapter.MainAdapter; import github.daneren2005.dsub.adapter.SectionAdapter; import github.daneren2005.dsub.domain.ServerInfo; -import github.daneren2005.dsub.service.DownloadService; import github.daneren2005.dsub.util.Constants; import github.daneren2005.dsub.util.FileUtil; import github.daneren2005.dsub.util.LoadingTask; -import github.daneren2005.dsub.util.Pair; import github.daneren2005.dsub.util.ProgressListener; import github.daneren2005.dsub.util.UserUtil; import github.daneren2005.dsub.util.Util; import github.daneren2005.dsub.service.MusicService; import github.daneren2005.dsub.service.MusicServiceFactory; -import github.daneren2005.dsub.util.SilentBackgroundTask; import github.daneren2005.dsub.view.ChangeLog; import github.daneren2005.dsub.view.UpdateView; @@ -295,7 +288,7 @@ public class MainFragment extends SelectRecyclerFragment<Integer> { } @Override - public void onItemClicked(Integer item) { + public void onItemClicked(UpdateView<Integer> updateView, Integer item) { if (item == R.string.main_albums_newest) { showAlbumList("newest"); } else if (item == R.string.main_albums_random) { diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java index 892891d2..281491af 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java @@ -35,7 +35,6 @@ import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.helper.ItemTouchHelper; import android.util.Log; -import android.view.ContextMenu; import android.view.Display; import android.view.GestureDetector; import android.view.GestureDetector.OnGestureListener; @@ -49,7 +48,6 @@ import android.view.View.OnClickListener; import android.view.ViewGroup; import android.view.WindowManager; import android.view.animation.AnimationUtils; -import android.widget.AdapterView; import android.widget.EditText; import android.widget.ImageButton; import android.widget.ImageView; @@ -76,7 +74,6 @@ import github.daneren2005.dsub.util.SilentBackgroundTask; import github.daneren2005.dsub.adapter.DownloadFileAdapter; import github.daneren2005.dsub.view.FadeOutAnimation; import github.daneren2005.dsub.view.FastScroller; -import github.daneren2005.dsub.view.SongView; import github.daneren2005.dsub.view.UpdateView; import github.daneren2005.dsub.util.Util; @@ -86,7 +83,6 @@ import github.daneren2005.dsub.util.*; import github.daneren2005.dsub.view.AutoRepeatButton; import java.util.ArrayList; import java.util.concurrent.ScheduledFuture; -import github.daneren2005.dsub.activity.SubsonicActivity; public class NowPlayingFragment extends SubsonicFragment implements OnGestureListener, SectionAdapter.OnItemClickedListener<DownloadFile>, OnSongChangedListener { private static final String TAG = NowPlayingFragment.class.getSimpleName(); @@ -1217,7 +1213,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis } @Override - public void onItemClicked(final DownloadFile item) { + public void onItemClicked(UpdateView<DownloadFile> updateView, final DownloadFile item) { warnIfStorageUnavailable(); new SilentBackgroundTask<Void>(context) { @Override |