diff options
author | Scott Jackson <daneren2005@gmail.com> | 2015-07-30 19:03:42 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2015-07-30 19:03:42 -0700 |
commit | 67cd4eb3447794c94b96946e64d8e2720acbc51f (patch) | |
tree | 23c7a80c58a57ec1c5a71389f4c38e95e57077a3 /app | |
parent | 64a01118e3cdbd92af846f413e926559f7d13da4 (diff) | |
download | dsub-67cd4eb3447794c94b96946e64d8e2720acbc51f.tar.gz dsub-67cd4eb3447794c94b96946e64d8e2720acbc51f.tar.bz2 dsub-67cd4eb3447794c94b96946e64d8e2720acbc51f.zip |
Add ActionMode for search/bookmarks
Diffstat (limited to 'app')
3 files changed, 35 insertions, 2 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/adapter/SearchAdapter.java b/app/src/main/java/github/daneren2005/dsub/adapter/SearchAdapter.java index c1185702..66f2db21 100644 --- a/app/src/main/java/github/daneren2005/dsub/adapter/SearchAdapter.java +++ b/app/src/main/java/github/daneren2005/dsub/adapter/SearchAdapter.java @@ -17,6 +17,8 @@ package github.daneren2005.dsub.adapter; import android.content.Context; import android.content.res.Resources; +import android.view.Menu; +import android.view.MenuInflater; import android.view.ViewGroup; import java.io.Serializable; @@ -27,6 +29,7 @@ import github.daneren2005.dsub.R; import github.daneren2005.dsub.domain.MusicDirectory.Entry; import github.daneren2005.dsub.domain.SearchResult; import github.daneren2005.dsub.util.ImageLoader; +import github.daneren2005.dsub.util.Util; import github.daneren2005.dsub.view.AlbumView; import github.daneren2005.dsub.view.ArtistView; import github.daneren2005.dsub.view.SongView; @@ -64,6 +67,7 @@ public class SearchAdapter extends SectionAdapter<Serializable> { this.headers.add(res.getString(R.string.search_songs)); } this.onItemClickedListener = listener; + checkable = true; } @Override @@ -88,7 +92,7 @@ public class SearchAdapter extends SectionAdapter<Serializable> { albumView.setObject((Entry) item, imageLoader); } else if(viewType == VIEW_TYPE_SONG) { SongView songView = (SongView) view; - songView.setObject((Entry) item, false); + songView.setObject((Entry) item, true); } else if(viewType == VIEW_TYPE_ARTIST) { view.setObject(item); } @@ -111,4 +115,15 @@ public class SearchAdapter extends SectionAdapter<Serializable> { return VIEW_TYPE_ARTIST; } } + + @Override + public void onCreateActionModeMenu(Menu menu, MenuInflater menuInflater) { + if(Util.isOffline(context)) { + menuInflater.inflate(R.menu.multiselect_media_offline, menu); + } else { + menuInflater.inflate(R.menu.multiselect_media, menu); + } + + menu.removeItem(R.id.menu_remove_playlist); + } } diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SearchFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SearchFragment.java index 96b32d8d..f442dabb 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/SearchFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/SearchFragment.java @@ -1,7 +1,9 @@ package github.daneren2005.dsub.fragments; import java.io.Serializable; +import java.util.ArrayList; import java.util.Arrays; +import java.util.List; import android.content.Intent; import android.os.Bundle; @@ -158,6 +160,19 @@ public class SearchFragment extends SubsonicFragment implements SectionAdapter.O } } + @Override + protected List<MusicDirectory.Entry> getSelectedEntries() { + List<Serializable> selected = adapter.getSelected(); + List<MusicDirectory.Entry> selectedMedia = new ArrayList<>(); + for(Serializable ser: selected) { + if(ser instanceof MusicDirectory.Entry) { + selectedMedia.add((MusicDirectory.Entry) ser); + } + } + + return selectedMedia; + } + public void search(final String query, final boolean autoplay) { if(skipSearch) { skipSearch = false; diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SelectRecyclerFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SelectRecyclerFragment.java index f91048b9..9dc3e363 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/SelectRecyclerFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/SelectRecyclerFragment.java @@ -35,7 +35,6 @@ import github.daneren2005.dsub.R; import github.daneren2005.dsub.adapter.SectionAdapter; import github.daneren2005.dsub.service.MusicService; import github.daneren2005.dsub.service.MusicServiceFactory; -import github.daneren2005.dsub.util.BackgroundTask; import github.daneren2005.dsub.util.Constants; import github.daneren2005.dsub.util.ProgressListener; import github.daneren2005.dsub.util.TabBackgroundTask; @@ -141,6 +140,10 @@ public abstract class SelectRecyclerFragment<T> extends SubsonicFragment impleme } } + protected SectionAdapter getCurrentAdapter() { + return adapter; + } + private void setupLayoutManager() { setupLayoutManager(recyclerView, largeAlbums); } |