diff options
Diffstat (limited to 'app/src/main/java')
-rw-r--r-- | app/src/main/java/github/daneren2005/dsub/adapter/SectionAdapter.java | 7 | ||||
-rw-r--r-- | app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java | 25 |
2 files changed, 19 insertions, 13 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 293012a2..8d9a8682 100644 --- a/app/src/main/java/github/daneren2005/dsub/adapter/SectionAdapter.java +++ b/app/src/main/java/github/daneren2005/dsub/adapter/SectionAdapter.java @@ -105,7 +105,7 @@ public abstract class SectionAdapter<T> extends RecyclerView.Adapter<UpdateViewH } }); - updateView.getChildAt(0).setOnLongClickListener(new View.OnLongClickListener() { + /*updateView.getChildAt(0).setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { T item = holder.getItem(); @@ -113,7 +113,7 @@ public abstract class SectionAdapter<T> extends RecyclerView.Adapter<UpdateViewH v.showContextMenu(); return false; } - }); + });*/ } } @@ -240,6 +240,9 @@ public abstract class SectionAdapter<T> extends RecyclerView.Adapter<UpdateViewH this.onItemClickedListener = onItemClickedListener; } + public void addSelected(T item) { + selected.add(item); + } public List<T> getSelected() { List<T> selected = new ArrayList<>(); selected.addAll(this.selected); diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java index 5dc50757..417b1328 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java @@ -77,7 +77,6 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Section private Boolean licenseValid; private List<Entry> albums; private List<Entry> entries; - private boolean addAlbumHeader = false; private LoadTask currentTask; private ArtistInfo artistInfo; private String artistInfoDelayed; @@ -198,9 +197,6 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Section recyclerView.setLayoutManager(layoutManager); } - if(albumListType == null || "starred".equals(albumListType)) { - addAlbumHeader = true; - } registerForContextMenu(recyclerView); if(entries == null) { @@ -763,6 +759,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Section // Show header if not album list type and not root and not artist // For Subsonic 5.1+ display a header for artists with getArtistInfo data if it exists + boolean addedHeader = false; if(albumListType == null && !"root".equals(id) && (!artist || artistInfo != null || artistInfoDelayed != null)) { View header = createHeader(); @@ -796,22 +793,28 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Section } entryGridAdapter.setHeader(header); + addedHeader = true; } } - recyclerView.setAdapter(entryGridAdapter); - context.supportInvalidateOptionsMenu(); - - /*if(lookupEntry != null) { + int scrollToPosition = -1; + if(lookupEntry != null) { for(int i = 0; i < entries.size(); i++) { if(lookupEntry.equals(entries.get(i).getTitle())) { - recyclerView.scrollToPosition(); - entryList.setSelection(i + entryList.getHeaderViewsCount()); + scrollToPosition = i; + entryGridAdapter.addSelected(entries.get(i)); lookupEntry = null; break; } } - }*/ + } + + recyclerView.setAdapter(entryGridAdapter); + context.supportInvalidateOptionsMenu(); + + if(scrollToPosition != -1) { + recyclerView.scrollToPosition(scrollToPosition + (addedHeader ? 1 : 0)); + } Bundle args = getArguments(); boolean playAll = args.getBoolean(Constants.INTENT_EXTRA_NAME_AUTOPLAY, false); |