Bug 898501: LOADER_ID OCD in PinBookmarkSearch. [r=lucasr]
authorSriram Ramasubramanian <sriram@mozilla.com>
Mon, 29 Jul 2013 15:05:28 -0700
changeset 151465 a9f2a85bf1ebc1fb86bd575150cf158a10c0566a
parent 151464 4fa359c591e579c98b7abd3d955aa781eba60fbc
child 151466 1fc9bcc1d4ab5487ef25cd373f0c46a8496c6741
push idunknown
push userunknown
push dateunknown
reviewerslucasr
bugs898501
milestone25.0a1
Bug 898501: LOADER_ID OCD in PinBookmarkSearch. [r=lucasr]
mobile/android/base/home/PinBookmarkDialog.java
--- a/mobile/android/base/home/PinBookmarkDialog.java
+++ b/mobile/android/base/home/PinBookmarkDialog.java
@@ -30,20 +30,20 @@ import android.widget.ListView;
  */
 class PinBookmarkDialog extends DialogFragment {
     // Listener for url selection
     public static interface OnBookmarkSelectedListener {
         public void onBookmarkSelected(String url, String title);
     }
 
     // Cursor loader ID for search query
-    private static final int SEARCH_LOADER_ID = 0;
+    private static final int LOADER_ID_SEARCH = 0;
 
     // Cursor loader ID for favicons query
-    private static final int FAVICONS_LOADER_ID = 1;
+    private static final int LOADER_ID_FAVICONS = 1;
 
     // Holds the current search term to use in the query
     private String mSearchTerm;
 
     // Adapter for the list of search results
     private SearchAdapter mAdapter;
 
     // Search entry
@@ -127,32 +127,32 @@ class PinBookmarkDialog extends DialogFr
         // Initialize the search adapter
         mAdapter = new SearchAdapter(getActivity());
         mList.setAdapter(mAdapter);
 
         // Create callbacks before the initial loader is started
         mLoaderCallbacks = new CursorLoaderCallbacks();
 
         // Reconnect to the loader only if present
-        getLoaderManager().initLoader(SEARCH_LOADER_ID, null, mLoaderCallbacks);
+        getLoaderManager().initLoader(LOADER_ID_SEARCH, null, mLoaderCallbacks);
 
         // Default filter.
         filter("");
     }
 
     private void filter(String searchTerm) {
         if (!TextUtils.isEmpty(searchTerm) &&
             TextUtils.equals(mSearchTerm, searchTerm)) {
             return;
         }
 
         mSearchTerm = searchTerm;
 
         // Restart loaders with the new search term
-        SearchLoader.restart(getLoaderManager(), SEARCH_LOADER_ID, mLoaderCallbacks, mSearchTerm);
+        SearchLoader.restart(getLoaderManager(), LOADER_ID_SEARCH, mLoaderCallbacks, mSearchTerm);
     }
 
     public void setOnBookmarkSelectedListener(OnBookmarkSelectedListener listener) {
         mOnBookmarkSelectedListener = listener;
     }
 
     private static class SearchAdapter extends CursorAdapter {
         private LayoutInflater mInflater;
@@ -174,51 +174,51 @@ class PinBookmarkDialog extends DialogFr
             return (TwoLinePageRow) mInflater.inflate(R.layout.home_item_row, parent, false);
         }
     }
 
     private class CursorLoaderCallbacks implements LoaderCallbacks<Cursor> {
         @Override
         public Loader<Cursor> onCreateLoader(int id, Bundle args) {
             switch(id) {
-            case SEARCH_LOADER_ID:
+            case LOADER_ID_SEARCH:
                 return SearchLoader.createInstance(getActivity(), args);
 
-            case FAVICONS_LOADER_ID:
+            case LOADER_ID_FAVICONS:
                 return FaviconsLoader.createInstance(getActivity(), args);
             }
 
             return null;
         }
 
         @Override
         public void onLoadFinished(Loader<Cursor> loader, Cursor c) {
             final int loaderId = loader.getId();
             switch(loaderId) {
-            case SEARCH_LOADER_ID:
+            case LOADER_ID_SEARCH:
                 mAdapter.swapCursor(c);
 
-                FaviconsLoader.restartFromCursor(getLoaderManager(), FAVICONS_LOADER_ID,
+                FaviconsLoader.restartFromCursor(getLoaderManager(), LOADER_ID_FAVICONS,
                         mLoaderCallbacks, c);
                 break;
 
-            case FAVICONS_LOADER_ID:
+            case LOADER_ID_FAVICONS:
                 // Force the list to use the in-memory favicons.
                 mAdapter.notifyDataSetChanged();
                 break;
             }
         }
 
         @Override
         public void onLoaderReset(Loader<Cursor> loader) {
             final int loaderId = loader.getId();
             switch(loaderId) {
-            case SEARCH_LOADER_ID:
+            case LOADER_ID_SEARCH:
                 mAdapter.swapCursor(null);
                 break;
 
-            case FAVICONS_LOADER_ID:
+            case LOADER_ID_FAVICONS:
                 // Do nothing
                 break;
             }
         }
     }
 }