[Android] Cancel search timeout if effective text input

Geoffrey Métais git at videolan.org
Fri Feb 12 18:08:57 CET 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Feb 12 18:08:00 2016 +0100| [07b96c7338e92895bc2ad52bc77b3db982904f7e] | committer: Geoffrey Métais

Cancel search timeout if effective text input

> https://code.videolan.org/videolan/vlc-android/commit/07b96c7338e92895bc2ad52bc77b3db982904f7e
---

 .../src/org/videolan/vlc/gui/audio/AudioPlayer.java      | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
index 2d087df..0a8474c 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
@@ -649,12 +649,7 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ
                 mPlaylistSearchText.getEditText().requestFocus();
                 InputMethodManager imm = (InputMethodManager) VLCApplication.getAppContext().getSystemService(Context.INPUT_METHOD_SERVICE);
                 imm.showSoftInput(mPlaylistSearchText.getEditText(), InputMethodManager.SHOW_IMPLICIT);
-                mHandler.postDelayed(new Runnable() {
-                    @Override
-                    public void run() {
-                        hideSearchField();
-                    }
-                }, SEARCH_TIMEOUT_MILLIS);
+                mHandler.postDelayed(hideSearchRunnable, SEARCH_TIMEOUT_MILLIS);
                 break;
         }
     }
@@ -680,11 +675,20 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ
         return true;
     }
 
+    Runnable hideSearchRunnable = new Runnable() {
+        @Override
+        public void run() {
+            hideSearchField();
+            mPlaylistAdapter.restoreList();
+        }
+    };
+
     @Override
     public void onTextChanged(CharSequence charSequence,  int start, int before, int count) {
         int length = charSequence.length();
         if (length > 1) {
             mPlaylistAdapter.getFilter().filter(charSequence);
+            mHandler.removeCallbacks(hideSearchRunnable);
         } else if (length == 0) {
             mPlaylistAdapter.restoreList();
             hideSearchField();



More information about the Android mailing list