[Android] Disable fast scrolling for Android 2.3

Geoffrey Métais git at videolan.org
Tue Nov 8 17:51:29 CET 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Nov  8 14:27:10 2016 +0100| [13f3e9e5b9e74495895848b8268afe1b4831c6a1] | committer: Geoffrey Métais

Disable fast scrolling for Android 2.3

> https://code.videolan.org/videolan/vlc-android/commit/13f3e9e5b9e74495895848b8268afe1b4831c6a1
---

 .../org/videolan/vlc/gui/view/FastScroller.java    | 78 ++++++++++------------
 1 file changed, 36 insertions(+), 42 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/view/FastScroller.java b/vlc-android/src/org/videolan/vlc/gui/view/FastScroller.java
index 670aa38..ea86061 100644
--- a/vlc-android/src/org/videolan/vlc/gui/view/FastScroller.java
+++ b/vlc-android/src/org/videolan/vlc/gui/view/FastScroller.java
@@ -47,6 +47,7 @@ import org.videolan.libvlc.util.AndroidUtil;
 import org.videolan.vlc.R;
 
 
+ at TargetApi(Build.VERSION_CODES.HONEYCOMB)
 public class FastScroller extends LinearLayout {
     
     private static final String TAG = "FastScroller";
@@ -99,51 +100,43 @@ public class FastScroller extends LinearLayout {
     }
 
     private void showBubble() {
-        if (AndroidUtil.isHoneycombOrLater()) {
-            AnimatorSet animatorSet = new AnimatorSet();
-            bubble.setPivotX(bubble.getWidth());
-            bubble.setPivotY(bubble.getHeight());
-            bubble.setVisibility(VISIBLE);
-            Animator growerX = ObjectAnimator.ofFloat(bubble, SCALE_X, 0f, 1f).setDuration(HANDLE_ANIMATION_DURATION);
-            Animator growerY = ObjectAnimator.ofFloat(bubble, SCALE_Y, 0f, 1f).setDuration(HANDLE_ANIMATION_DURATION);
-            Animator alpha = ObjectAnimator.ofFloat(bubble, ALPHA, 0f, 1f).setDuration(HANDLE_ANIMATION_DURATION);
-            animatorSet.playTogether(growerX, growerY, alpha);
-            animatorSet.start();
-        } else
-            bubble.setVisibility(VISIBLE);
+        AnimatorSet animatorSet = new AnimatorSet();
+        bubble.setPivotX(bubble.getWidth());
+        bubble.setPivotY(bubble.getHeight());
+        bubble.setVisibility(VISIBLE);
+        Animator growerX = ObjectAnimator.ofFloat(bubble, SCALE_X, 0f, 1f).setDuration(HANDLE_ANIMATION_DURATION);
+        Animator growerY = ObjectAnimator.ofFloat(bubble, SCALE_Y, 0f, 1f).setDuration(HANDLE_ANIMATION_DURATION);
+        Animator alpha = ObjectAnimator.ofFloat(bubble, ALPHA, 0f, 1f).setDuration(HANDLE_ANIMATION_DURATION);
+        animatorSet.playTogether(growerX, growerY, alpha);
+        animatorSet.start();
     }
 
     private void hideBubble() {
-        if (AndroidUtil.isHoneycombOrLater()) {
-            currentAnimator = new AnimatorSet();
-            bubble.setPivotX(bubble.getWidth());
-            bubble.setPivotY(bubble.getHeight());
-            Animator shrinkerX = ObjectAnimator.ofFloat(bubble, SCALE_X, 1f, 0f).setDuration(HANDLE_ANIMATION_DURATION);
-            Animator shrinkerY = ObjectAnimator.ofFloat(bubble, SCALE_Y, 1f, 0f).setDuration(HANDLE_ANIMATION_DURATION);
-            Animator alpha = ObjectAnimator.ofFloat(bubble, ALPHA, 1f, 0f).setDuration(HANDLE_ANIMATION_DURATION);
-            currentAnimator.playTogether(shrinkerX, shrinkerY, alpha);
-            currentAnimator.addListener(new AnimatorListenerAdapter() {
-                @Override
-                public void onAnimationEnd(Animator animation) {
-                    super.onAnimationEnd(animation);
-                    bubble.setVisibility(GONE);
-                    currentAnimator = null;
-                    mHandler.sendEmptyMessageDelayed(HIDE_SCROLLER, SCROLLER_HIDE_DELAY);
-                }
+        currentAnimator = new AnimatorSet();
+        bubble.setPivotX(bubble.getWidth());
+        bubble.setPivotY(bubble.getHeight());
+        Animator shrinkerX = ObjectAnimator.ofFloat(bubble, SCALE_X, 1f, 0f).setDuration(HANDLE_ANIMATION_DURATION);
+        Animator shrinkerY = ObjectAnimator.ofFloat(bubble, SCALE_Y, 1f, 0f).setDuration(HANDLE_ANIMATION_DURATION);
+        Animator alpha = ObjectAnimator.ofFloat(bubble, ALPHA, 1f, 0f).setDuration(HANDLE_ANIMATION_DURATION);
+        currentAnimator.playTogether(shrinkerX, shrinkerY, alpha);
+        currentAnimator.addListener(new AnimatorListenerAdapter() {
+            @Override
+            public void onAnimationEnd(Animator animation) {
+                super.onAnimationEnd(animation);
+                bubble.setVisibility(GONE);
+                currentAnimator = null;
+                mHandler.sendEmptyMessageDelayed(HIDE_SCROLLER, SCROLLER_HIDE_DELAY);
+            }
 
-                @Override
-                public void onAnimationCancel(Animator animation) {
-                    super.onAnimationCancel(animation);
-                    bubble.setVisibility(INVISIBLE);
-                    currentAnimator = null;
-                    mHandler.sendEmptyMessageDelayed(HIDE_SCROLLER, SCROLLER_HIDE_DELAY);
-                }
-            });
-            currentAnimator.start();
-        } else {
-            bubble.setVisibility(GONE);
-            mHandler.sendEmptyMessageDelayed(HIDE_SCROLLER, SCROLLER_HIDE_DELAY);
-        }
+            @Override
+            public void onAnimationCancel(Animator animation) {
+                super.onAnimationCancel(animation);
+                bubble.setVisibility(INVISIBLE);
+                currentAnimator = null;
+                mHandler.sendEmptyMessageDelayed(HIDE_SCROLLER, SCROLLER_HIDE_DELAY);
+            }
+        });
+        currentAnimator.start();
     }
 
     private void setPosition(float y) {
@@ -155,6 +148,8 @@ public class FastScroller extends LinearLayout {
     }
 
     public void setRecyclerView(RecyclerView recyclerView) {
+        if (!AndroidUtil.isHoneycombOrLater())
+            return;
         if (mRecyclerView != null)
             mRecyclerView.removeOnScrollListener(scrollListener);
         setVisibility(INVISIBLE);
@@ -164,7 +159,6 @@ public class FastScroller extends LinearLayout {
         mShowBubble = ((SeparatedAdapter)recyclerView.getAdapter()).hasSections();
     }
 
-    @TargetApi(Build.VERSION_CODES.HONEYCOMB)
     @Override
     public boolean onTouchEvent(@NonNull MotionEvent event) {
         if (event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == MotionEvent.ACTION_MOVE) {



More information about the Android mailing list