aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2015-08-24 17:48:00 -0700
committerScott Jackson <daneren2005@gmail.com>2015-08-24 17:48:00 -0700
commit6d30b8cfda0c8d848d20abc6cd9805ed763836ef (patch)
treef3f2dd1b7881f51cdb0d4598c097e8e138bc9eeb /app/src/main
parentc6d2629702b220e0ce9c19e41793dad84edcbb76 (diff)
downloaddsub-6d30b8cfda0c8d848d20abc6cd9805ed763836ef.tar.gz
dsub-6d30b8cfda0c8d848d20abc6cd9805ed763836ef.tar.bz2
dsub-6d30b8cfda0c8d848d20abc6cd9805ed763836ef.zip
Add fast scrolling with no bubble to NowPlayingFragment
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/adapter/DownloadFileAdapter.java8
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java3
-rw-r--r--app/src/main/java/github/daneren2005/dsub/view/FastScroller.java20
-rw-r--r--app/src/main/res/layout/download_playlist.xml23
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