[Android] Disable predictive animations in videos grid

Geoffrey Métais git at videolan.org
Mon May 30 13:41:06 CEST 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon May 30 13:39:37 2016 +0200| [9bf8e30fdd74a6ebc64f1ddd4ac3ac02c84cb786] | committer: Geoffrey Métais

Disable predictive animations in videos grid

> https://code.videolan.org/videolan/vlc-android/commit/9bf8e30fdd74a6ebc64f1ddd4ac3ac02c84cb786
---

 .../videolan/vlc/gui/view/AutoFitRecyclerView.java |  6 +--
 .../vlc/gui/view/NpaGridLayoutManager.java         | 44 ++++++++++++++++++++++
 2 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/view/AutoFitRecyclerView.java b/vlc-android/src/org/videolan/vlc/gui/view/AutoFitRecyclerView.java
index 8965ae3..da5a632 100644
--- a/vlc-android/src/org/videolan/vlc/gui/view/AutoFitRecyclerView.java
+++ b/vlc-android/src/org/videolan/vlc/gui/view/AutoFitRecyclerView.java
@@ -34,7 +34,7 @@ import org.videolan.vlc.VLCApplication;
 
 public class AutoFitRecyclerView extends ContextMenuRecyclerView {
 
-    private GridLayoutManager mGridLayoutManager;
+    private NpaGridLayoutManager mGridLayoutManager;
     private int mColumnWidth = -1;
     private int mSpanCount = -1;
 
@@ -63,7 +63,7 @@ public class AutoFitRecyclerView extends ContextMenuRecyclerView {
             array.recycle();
         }
 
-        mGridLayoutManager = new GridLayoutManager(getContext(), 1);
+        mGridLayoutManager = new NpaGridLayoutManager(getContext(), 1);
         setLayoutManager(mGridLayoutManager);
     }
 
@@ -71,7 +71,7 @@ public class AutoFitRecyclerView extends ContextMenuRecyclerView {
     protected void onMeasure(int widthSpec, int heightSpec) {
         super.onMeasure(widthSpec, heightSpec);
         if (mSpanCount == -1 && mColumnWidth > 0) {
-            int ratio = (int) (getMeasuredWidth() / (mColumnWidth));
+            int ratio = getMeasuredWidth() / mColumnWidth;
             int spanCount = Math.max(1, ratio);
             mGridLayoutManager.setSpanCount(spanCount);
         } else
diff --git a/vlc-android/src/org/videolan/vlc/gui/view/NpaGridLayoutManager.java b/vlc-android/src/org/videolan/vlc/gui/view/NpaGridLayoutManager.java
new file mode 100644
index 0000000..8d5c51d
--- /dev/null
+++ b/vlc-android/src/org/videolan/vlc/gui/view/NpaGridLayoutManager.java
@@ -0,0 +1,44 @@
+/*
+ * ************************************************************************
+ *  NpaGridLayout.java
+ * *************************************************************************
+ *  Copyright © 2016 VLC authors and VideoLAN
+ *  Author: Geoffrey Métais
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *
+ *  *************************************************************************
+ */
+
+package org.videolan.vlc.gui.view;
+
+import android.content.Context;
+import android.support.v7.widget.GridLayoutManager;
+
+public class NpaGridLayoutManager extends GridLayoutManager {
+
+    public NpaGridLayoutManager(Context context, int spanCount) {
+        super(context, spanCount);
+    }
+
+    /*
+     * Disable predictive animations to prevent a bug on Recyclerview
+     * AppCompat 23.1.1, may be fixed with AppCompat 24.
+     */
+    @Override
+    public boolean supportsPredictiveItemAnimations() {
+        return false;
+    }
+}



More information about the Android mailing list