[Android] Fix IllegalStateException within the SearchFragment

Ludovic Fauvet git at videolan.org
Mon Apr 14 18:15:27 CEST 2014


vlc-ports/android | branch: master | Ludovic Fauvet <etix at videolan.org> | Mon Apr 14 18:11:51 2014 +0200| [afb24bae1be4567446eab2e6df31d538e50d1669] | committer: Ludovic Fauvet

Fix IllegalStateException within the SearchFragment

This commit prevents the search from being triggered before the view is
completely setup.

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=afb24bae1be4567446eab2e6df31d538e50d1669
---

 vlc-android/src/org/videolan/vlc/gui/SearchFragment.java |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/SearchFragment.java b/vlc-android/src/org/videolan/vlc/gui/SearchFragment.java
index 71d01c2..be97211 100644
--- a/vlc-android/src/org/videolan/vlc/gui/SearchFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/SearchFragment.java
@@ -20,6 +20,7 @@
 
 package org.videolan.vlc.gui;
 
+import java.lang.Override;
 import java.util.ArrayList;
 import java.util.Locale;
 
@@ -66,13 +67,19 @@ public class SearchFragment extends SherlockListFragment {
         mHistoryAdapter = new SearchHistoryAdapter(getActivity());
         mResultAdapter = new SearchResultAdapter(getActivity());
 
+        return v;
+    }
+
+    @Override
+    public void onActivityCreated(Bundle savedInstanceState) {
+        super.onActivityCreated(savedInstanceState);
+        View v = getView();
+
         mSearchText = (EditText) v.findViewById(R.id.search_text);
         mSearchText.setOnEditorActionListener(searchTextListener);
         mSearchText.addTextChangedListener(searchTextWatcher);
 
         mSearchText.requestFocus();
-
-        return v;
     }
 
     @Override



More information about the Android mailing list