[Android] [PATCH 0/3] Keep search filter on screen rotation
Romain Vimont
rom at rom1v.com
Tue Nov 7 21:43:38 CET 2017
There are race conditions which must be fixed before this patchset works
correctly.
Currently, it (randomly, but very often on some devices) fails to apply
the filter after the activity is re-created, because it is overriden by
an update of the full list immediately after (or before, this is racy).
To highlight the problem, delay the video list results:
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 418435ab8..031331e82 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
@@ -30,6 +30,7 @@ import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
+import android.os.SystemClock;
import android.preference.PreferenceManager;
import android.support.annotation.MainThread;
import android.support.annotation.Nullable;
@@ -358,6 +359,7 @@ public class VideoGridFragment extends SortableFragment<VideoListAdapter> implem
for (MediaGroup item : MediaGroup.group(itemList))
displayList.add(item.getMedia());
}
+ SystemClock.sleep(8000); // delay the update by 8 seconds to highlight race conditions
VLCApplication.runOnMainThread(new Runnable() {
@Override
public void run() {
Then, when you open VLC, while it loads the video data (during more than
8 seconds), type something in the search view: once the data is loaded,
the search query is not applied. This is exactly the same problem.
Therefore, I think we should store the search query and apply it
whenever the list is updated. In particular, the filter must be applied
after by VideoListAdapter.update().
Moreover, this patchset is incomplete, since it only targets video
lists. Once fixed, some changes have to be applied to other lists too.
Le mardi 7 novembre 2017 à 18:34 +0100, Romain Vimont a écrit :
> The search filter was cleared on screen rotation:
> <https://code.videolan.org/videolan/vlc-android/issues/404>
>
> The first commit removes some code duplication.
>
> The second commit changes the search behavior for small query strings.
>
> The last implements the state save/restore to keep the search filter on screen
> rotation.
>
> Romain Vimont (3):
> Remove identical overridden implementation
> Clear list filter on small search query string
> Keep search filter on screen rotation
>
> .../src/org/videolan/vlc/gui/ContentActivity.java | 32 ++++++++++++++++++++--
> .../src/org/videolan/vlc/gui/MainActivity.java | 12 --------
> .../videolan/vlc/gui/video/VideoGridFragment.java | 2 +-
> .../videolan/vlc/gui/video/VideoListAdapter.java | 4 +++
> 4 files changed, 34 insertions(+), 16 deletions(-)
>
> --
> 2.11.0
>
More information about the Android
mailing list