[Android] Fix refresh triggered on crolling up
Geoffrey Métais
git at videolan.org
Sat Nov 5 19:56:55 CET 2016
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Sat Nov 5 19:56:15 2016 +0100| [fd9bf620d4d1947222c2b7121f546704c9db12f5] | committer: Geoffrey Métais
Fix refresh triggered on crolling up
> https://code.videolan.org/videolan/vlc-android/commit/fd9bf620d4d1947222c2b7121f546704c9db12f5
---
vlc-android/src/org/videolan/vlc/gui/HistoryFragment.java | 4 +---
.../src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java | 4 +---
vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java | 5 ++---
.../src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java | 4 +---
vlc-android/src/org/videolan/vlc/gui/browser/ExtensionBrowser.java | 4 +---
vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java | 5 ++---
6 files changed, 8 insertions(+), 18 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/HistoryFragment.java b/vlc-android/src/org/videolan/vlc/gui/HistoryFragment.java
index c5a9375..ae1a200 100644
--- a/vlc-android/src/org/videolan/vlc/gui/HistoryFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/HistoryFragment.java
@@ -94,9 +94,7 @@ public class HistoryFragment extends MediaBrowserFragment implements IRefreshabl
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
- int topRowVerticalPosition =
- (recyclerView == null || recyclerView.getChildCount() == 0) ? 0 : recyclerView.getChildAt(0).getTop();
- mSwipeRefreshLayout.setEnabled(topRowVerticalPosition >= 0);
+ mSwipeRefreshLayout.setEnabled(((LinearLayoutManager)recyclerView.getLayoutManager()).findFirstVisibleItemPosition() >= 0);
}
};
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
index ae7bd73..4e1e779 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
@@ -162,9 +162,7 @@ public class AudioAlbumsSongsFragment extends MediaBrowserFragment implements Sw
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
- int topRowVerticalPosition =
- (recyclerView == null || recyclerView.getChildCount() == 0) ? 0 : recyclerView.getChildAt(0).getTop();
- mSwipeRefreshLayout.setEnabled(topRowVerticalPosition >= 0);
+ mSwipeRefreshLayout.setEnabled(((LinearLayoutManager)recyclerView.getLayoutManager()).findFirstVisibleItemPosition() >= 0);
}
};
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
index f8b1db2..3fabb4d 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
@@ -45,6 +45,7 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Filter;
+import android.widget.LinearLayout;
import android.widget.TextView;
import org.videolan.libvlc.Media;
@@ -217,9 +218,7 @@ public class AudioBrowserFragment extends MediaBrowserFragment implements Device
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
- int topRowVerticalPosition =
- (recyclerView == null || recyclerView.getChildCount() == 0) ? 0 : recyclerView.getChildAt(0).getTop();
- mSwipeRefreshLayout.setEnabled(topRowVerticalPosition >= 0);
+ mSwipeRefreshLayout.setEnabled(((LinearLayoutManager)recyclerView.getLayoutManager()).findFirstVisibleItemPosition() >= 0);
}
};
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
index d33fc4f..a4328e3 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
@@ -283,9 +283,7 @@ public abstract class BaseBrowserFragment extends MediaBrowserFragment implement
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
- int topRowVerticalPosition =
- (recyclerView == null || recyclerView.getChildCount() == 0) ? 0 : recyclerView.getChildAt(0).getTop();
- mSwipeRefreshLayout.setEnabled(topRowVerticalPosition >= 0);
+ mSwipeRefreshLayout.setEnabled(((LinearLayoutManager)recyclerView.getLayoutManager()).findFirstVisibleItemPosition() >= 0);
}
};
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/ExtensionBrowser.java b/vlc-android/src/org/videolan/vlc/gui/browser/ExtensionBrowser.java
index 3aa33af..918c239 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/ExtensionBrowser.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/ExtensionBrowser.java
@@ -178,9 +178,7 @@ public class ExtensionBrowser extends Fragment implements View.OnClickListener,
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
- int topRowVerticalPosition =
- (recyclerView == null || recyclerView.getChildCount() == 0) ? 0 : recyclerView.getChildAt(0).getTop();
- mSwipeRefreshLayout.setEnabled(topRowVerticalPosition >= 0);
+ mSwipeRefreshLayout.setEnabled(((LinearLayoutManager)recyclerView.getLayoutManager()).findFirstVisibleItemPosition() >= 0);
}
};
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
index ea801ff..40cc7cb 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
@@ -32,6 +32,7 @@ import android.preference.PreferenceManager;
import android.support.annotation.MainThread;
import android.support.design.widget.BottomSheetDialogFragment;
import android.support.v4.content.LocalBroadcastManager;
+import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.DisplayMetrics;
import android.util.Log;
@@ -443,9 +444,7 @@ public class VideoGridFragment extends MediaBrowserFragment implements MediaUpda
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
- int topRowVerticalPosition =
- (recyclerView == null || recyclerView.getChildCount() == 0) ? 0 : recyclerView.getChildAt(0).getTop();
- mSwipeRefreshLayout.setEnabled(topRowVerticalPosition >= 0);
+ mSwipeRefreshLayout.setEnabled(((LinearLayoutManager)recyclerView.getLayoutManager()).findFirstVisibleItemPosition() >= 0);
}
};
More information about the Android
mailing list