diff options
4 files changed, 42 insertions, 12 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/adapter/DownloadFileAdapter.java b/app/src/main/java/github/daneren2005/dsub/adapter/DownloadFileAdapter.java index 37a4ab93..d4613994 100644 --- a/app/src/main/java/github/daneren2005/dsub/adapter/DownloadFileAdapter.java +++ b/app/src/main/java/github/daneren2005/dsub/adapter/DownloadFileAdapter.java @@ -23,10 +23,11 @@ import android.widget.ArrayAdapter; import java.util.List; import github.daneren2005.dsub.service.DownloadFile; +import github.daneren2005.dsub.view.FastScroller; import github.daneren2005.dsub.view.SongView; import github.daneren2005.dsub.view.UpdateView; -public class DownloadFileAdapter extends SectionAdapter<DownloadFile> { +public class DownloadFileAdapter extends SectionAdapter<DownloadFile> implements FastScroller.BubbleTextGetter { public static int VIEW_TYPE_DOWNLOAD_FILE = 1; public DownloadFileAdapter(Context context, List<DownloadFile> entries, OnItemClickedListener onItemClickedListener) { @@ -50,4 +51,9 @@ public class DownloadFileAdapter extends SectionAdapter<DownloadFile> { public int getItemViewType(DownloadFile item) { return VIEW_TYPE_DOWNLOAD_FILE; } + + @Override + public String getTextToShowInBubble(int position) { + return null; + } } 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 2a965727..c58a2ecb 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java @@ -75,6 +75,7 @@ import github.daneren2005.dsub.util.Constants; 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; @@ -184,6 +185,8 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis toggleListButton =rootView.findViewById(R.id.download_toggle_list); playlistView = (RecyclerView)rootView.findViewById(R.id.download_list); + FastScroller fastScroller = (FastScroller) rootView.findViewById(R.id.download_fast_scroller); + fastScroller.attachRecyclerView(playlistView); setupLayoutManager(playlistView, false); ItemTouchHelper touchHelper = new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(ItemTouchHelper.UP | ItemTouchHelper.DOWN, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT) { @Override diff --git a/app/src/main/java/github/daneren2005/dsub/view/FastScroller.java b/app/src/main/java/github/daneren2005/dsub/view/FastScroller.java index 1cc11c08..fdf2b815 100644 --- a/app/src/main/java/github/daneren2005/dsub/view/FastScroller.java +++ b/app/src/main/java/github/daneren2005/dsub/view/FastScroller.java @@ -45,6 +45,7 @@ public class FastScroller extends LinearLayout { private RecyclerView recyclerView; private final ScrollListener scrollListener = new ScrollListener(); private int height; + private boolean visibleBubble = true; private ObjectAnimator currentAnimator = null; @@ -90,8 +91,13 @@ public class FastScroller extends LinearLayout { return false; if(currentAnimator != null) currentAnimator.cancel(); - if(bubble.getVisibility() == INVISIBLE) - showBubble(); + if(bubble.getVisibility() == INVISIBLE) { + if(visibleBubble) { + showBubble(); + } + } else if(!visibleBubble) { + hideBubble(); + } handle.setSelected(true); case MotionEvent.ACTION_MOVE: final float y = event.getY(); @@ -139,9 +145,14 @@ public class FastScroller extends LinearLayout { try { String bubbleText = ((BubbleTextGetter) recyclerView.getAdapter()).getTextToShowInBubble(targetPos); - bubble.setText(bubbleText); + if(bubbleText == null) { + visibleBubble = false; + bubble.setVisibility(View.INVISIBLE); + } else { + bubble.setText(bubbleText); + visibleBubble = true; + } } catch(Exception e) { - Log.e(TAG, "Item count: " + itemCount); Log.e(TAG, "Error getting text for bubble", e); } } @@ -160,7 +171,6 @@ public class FastScroller extends LinearLayout { } private void showBubble() { - AnimatorSet animatorSet = new AnimatorSet(); bubble.setVisibility(VISIBLE); if(currentAnimator != null) currentAnimator.cancel(); diff --git a/app/src/main/res/layout/download_playlist.xml b/app/src/main/res/layout/download_playlist.xml index 7a83330c..db74f8ca 100644 --- a/app/src/main/res/layout/download_playlist.xml +++ b/app/src/main/res/layout/download_playlist.xml @@ -19,11 +19,22 @@ android:padding="10dip" android:textColor="?android:textColorPrimary"/> - <android.support.v7.widget.RecyclerView - android:id="@+id/download_list" - android:layout_width="fill_parent" - android:layout_height="fill_parent" - android:layout_weight="1" - android:scrollbars="vertical"/> + <RelativeLayout + android:layout_width="fill_parent" + android:layout_height="0dip" + android:layout_weight="1.0"> + + <android.support.v7.widget.RecyclerView + android:id="@+id/download_list" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:scrollbars="vertical"/> + + <github.daneren2005.dsub.view.FastScroller + android:id="@+id/download_fast_scroller" + android:layout_width="wrap_content" + android:layout_height="fill_parent" + android:layout_alignParentRight="true"/> + </RelativeLayout> </LinearLayout>
\ No newline at end of file |