From b31e4734375869615030774d78bc5775b3095d4f Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Wed, 16 Oct 2013 17:02:02 +0100 Subject: [PATCH] Bug 927371 - Remove performEmptySearch from SearchLoader (r=sriram) --- mobile/android/base/home/BrowserSearch.java | 4 +-- mobile/android/base/home/SearchLoader.java | 32 +++++---------------- 2 files changed, 9 insertions(+), 27 deletions(-) diff --git a/mobile/android/base/home/BrowserSearch.java b/mobile/android/base/home/BrowserSearch.java index 5abdfbf0e8cb..2ca0df7a7eea 100644 --- a/mobile/android/base/home/BrowserSearch.java +++ b/mobile/android/base/home/BrowserSearch.java @@ -321,7 +321,7 @@ public class BrowserSearch extends HomeFragment @Override protected void load() { - SearchLoader.init(getLoaderManager(), LOADER_ID_SEARCH, mCursorLoaderCallbacks, mSearchTerm, false); + SearchLoader.init(getLoaderManager(), LOADER_ID_SEARCH, mCursorLoaderCallbacks, mSearchTerm); } private void handleAutocomplete(String searchTerm, Cursor c) { @@ -612,7 +612,7 @@ public class BrowserSearch extends HomeFragment mAdapter.notifyDataSetChanged(); // Restart loaders with the new search term - SearchLoader.restart(getLoaderManager(), LOADER_ID_SEARCH, mCursorLoaderCallbacks, mSearchTerm, false); + SearchLoader.restart(getLoaderManager(), LOADER_ID_SEARCH, mCursorLoaderCallbacks, mSearchTerm); filterSuggestions(); } } diff --git a/mobile/android/base/home/SearchLoader.java b/mobile/android/base/home/SearchLoader.java index 579e8c4766bf..b06fb8a9cd24 100644 --- a/mobile/android/base/home/SearchLoader.java +++ b/mobile/android/base/home/SearchLoader.java @@ -22,44 +22,34 @@ class SearchLoader { // Key for search terms private static final String KEY_SEARCH_TERM = "search_term"; - // Key for performing empty search - private static final String KEY_PERFORM_EMPTY_SEARCH = "perform_empty_search"; - private SearchLoader() { } public static Loader createInstance(Context context, Bundle args) { if (args != null) { final String searchTerm = args.getString(KEY_SEARCH_TERM); - final boolean performEmptySearch = args.getBoolean(KEY_PERFORM_EMPTY_SEARCH, false); - return new SearchCursorLoader(context, searchTerm, performEmptySearch); + return new SearchCursorLoader(context, searchTerm); } else { - return new SearchCursorLoader(context, "", false); + return new SearchCursorLoader(context, ""); } } - private static Bundle createArgs(String searchTerm, boolean performEmptySearch) { + private static Bundle createArgs(String searchTerm) { Bundle args = new Bundle(); args.putString(SearchLoader.KEY_SEARCH_TERM, searchTerm); - args.putBoolean(SearchLoader.KEY_PERFORM_EMPTY_SEARCH, performEmptySearch); return args; } public static void init(LoaderManager manager, int loaderId, - LoaderCallbacks callbacks, String searchTerm, boolean performEmptySearch) { - Bundle args = createArgs(searchTerm, performEmptySearch); + LoaderCallbacks callbacks, String searchTerm) { + final Bundle args = createArgs(searchTerm); manager.initLoader(loaderId, args, callbacks); } public static void restart(LoaderManager manager, int loaderId, LoaderCallbacks callbacks, String searchTerm) { - restart(manager, loaderId, callbacks, searchTerm, true); - } - - public static void restart(LoaderManager manager, int loaderId, - LoaderCallbacks callbacks, String searchTerm, boolean performEmptySearch) { - Bundle args = createArgs(searchTerm, performEmptySearch); + final Bundle args = createArgs(searchTerm); manager.restartLoader(loaderId, args, callbacks); } @@ -70,21 +60,13 @@ class SearchLoader { // The target search term associated with the loader private final String mSearchTerm; - // An empty search on the DB - private final boolean mPerformEmptySearch; - - public SearchCursorLoader(Context context, String searchTerm, boolean performEmptySearch) { + public SearchCursorLoader(Context context, String searchTerm) { super(context); mSearchTerm = searchTerm; - mPerformEmptySearch = performEmptySearch; } @Override public Cursor loadCursor() { - if (!mPerformEmptySearch && TextUtils.isEmpty(mSearchTerm)) { - return null; - } - return BrowserDB.filter(getContext().getContentResolver(), mSearchTerm, SEARCH_LIMIT); }