From 829e8f10581dd361c818fd00e82c2b0e23b6064c Mon Sep 17 00:00:00 2001 From: Peter Serwylo Date: Tue, 8 Dec 2015 00:20:20 +1100 Subject: [PATCH] Queue pending search until the SearchView is inflated. --- F-Droid/src/org/fdroid/fdroid/FDroid.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/F-Droid/src/org/fdroid/fdroid/FDroid.java b/F-Droid/src/org/fdroid/fdroid/FDroid.java index 9f77c976e..0013cd264 100644 --- a/F-Droid/src/org/fdroid/fdroid/FDroid.java +++ b/F-Droid/src/org/fdroid/fdroid/FDroid.java @@ -79,6 +79,9 @@ public class FDroid extends AppCompatActivity implements SearchView.OnQueryTextL @Nullable private MenuItem searchMenuItem; + @Nullable + private String pendingSearchQuery; + @Override protected void onCreate(Bundle savedInstanceState) { @@ -123,7 +126,8 @@ public class FDroid extends AppCompatActivity implements SearchView.OnQueryTextL private void performSearch(String query) { if (searchMenuItem == null) { - Log.e(TAG, "Tried to search, but search view has not yet been created."); + // Store this for later when we do actually have a search menu ready to use. + pendingSearchQuery = query; return; } @@ -288,6 +292,11 @@ public class FDroid extends AppCompatActivity implements SearchView.OnQueryTextL searchView.setMaxWidth(1000000); searchView.setOnQueryTextListener(this); + if (pendingSearchQuery != null) { + performSearch(pendingSearchQuery); + pendingSearchQuery = null; + } + return super.onCreateOptionsMenu(menu); }