[Android] Avoid unnecessary updates
Geoffrey Métais
git at videolan.org
Wed Feb 14 17:36:32 CET 2018
vlc-android | branch: 3.0.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Feb 14 10:55:05 2018 +0100| [8d1c52f5fa61c3dcb5726530927b239ac48f6017] | committer: Geoffrey Métais
Avoid unnecessary updates
(cherry picked from commit 2bcb8ed0b6f172b227d57e22c09747dafd6ae90b)
> https://code.videolan.org/videolan/vlc-android/commit/8d1c52f5fa61c3dcb5726530927b239ac48f6017
---
vlc-android/src/org/videolan/vlc/SortableAdapter.java | 4 +++-
vlc-android/src/org/videolan/vlc/gui/browser/SortableFragment.java | 3 +--
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/SortableAdapter.java b/vlc-android/src/org/videolan/vlc/SortableAdapter.java
index 238c20c95..2775dd5f8 100644
--- a/vlc-android/src/org/videolan/vlc/SortableAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/SortableAdapter.java
@@ -4,6 +4,7 @@ import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import org.jetbrains.annotations.NotNull;
+import org.videolan.medialibrary.Medialibrary;
import org.videolan.medialibrary.media.MediaLibraryItem;
import org.videolan.vlc.gui.DiffUtilAdapter;
import org.videolan.vlc.util.MediaLibraryItemComparator;
@@ -37,7 +38,8 @@ public abstract class SortableAdapter<T extends MediaLibraryItem, VH extends Rec
}
public void updateIfSortChanged() {
- if (!hasPendingUpdates() && hasSortChanged()) update(new ArrayList<>(peekLast()));
+ final Medialibrary ml = VLCApplication.getMLInstance();
+ if (ml.isInitiated() && !ml.isWorking() && !hasPendingUpdates() && hasSortChanged()) update(new ArrayList<>(peekLast()));
}
private boolean hasSortChanged() {
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/SortableFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/SortableFragment.java
index 2688df43f..0f4639bfc 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/SortableFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/SortableFragment.java
@@ -52,8 +52,7 @@ public abstract class SortableFragment<T extends SortableAdapter> extends MediaB
public void onHiddenChanged(boolean hidden) {
super.onHiddenChanged(hidden);
final T adapter = getCurrentAdapter();
- if (adapter != null)
- adapter.updateIfSortChanged();
+ if (adapter != null) adapter.updateIfSortChanged();
}
@Override
More information about the Android
mailing list