Bug 1175355 - Add AsyncQueryHandlerImpl in SearchActivity. r=nalexander
authorMichael Comella <michael.l.comella@gmail.com>
Wed, 24 Jun 2015 16:58:06 -0700
changeset 281158 42c4d687437d11a2027aabb009420a63e0990874
parent 281157 94af910d67fb04c59e7d8e973d0dc9df5a1fda7b
child 281159 58334ada143a33f9e4043c12a17ef2cd98c26ae3
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-beta@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnalexander
bugs1175355
milestone41.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1175355 - Add AsyncQueryHandlerImpl in SearchActivity. r=nalexander This avoids the "HandlerLeak" Android Lint warning.
mobile/android/search/java/org/mozilla/search/SearchActivity.java
--- a/mobile/android/search/java/org/mozilla/search/SearchActivity.java
+++ b/mobile/android/search/java/org/mozilla/search/SearchActivity.java
@@ -14,16 +14,17 @@ import org.mozilla.gecko.distribution.Di
 import org.mozilla.gecko.health.BrowserHealthRecorder;
 import org.mozilla.search.autocomplete.SearchBar;
 import org.mozilla.search.autocomplete.SuggestionsFragment;
 import org.mozilla.search.providers.SearchEngine;
 import org.mozilla.search.providers.SearchEngineManager;
 import org.mozilla.search.providers.SearchEngineManager.SearchEngineCallback;
 
 import android.content.AsyncQueryHandler;
+import android.content.ContentResolver;
 import android.content.ContentValues;
 import android.content.Intent;
 import android.graphics.Rect;
 import android.os.Bundle;
 import android.text.TextUtils;
 import android.util.Log;
 import android.view.View;
 import android.view.animation.AccelerateDecelerateInterpolator;
@@ -87,33 +88,43 @@ public class SearchActivity extends Loca
 
     // View used for suggestion animation.
     private View animationCard;
 
     // Suggestion card background padding.
     private int cardPaddingX;
     private int cardPaddingY;
 
+    /**
+     * An empty implementation of AsyncQueryHandler to avoid the "HandlerLeak" warning from Android
+     * Lint. See also {@see org.mozilla.gecko.util.WeakReferenceHandler}.
+     */
+    private static class AsyncQueryHandlerImpl extends AsyncQueryHandler {
+        public AsyncQueryHandlerImpl(final ContentResolver that) {
+            super(that);
+        }
+    }
+
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         GeckoAppShell.ensureCrashHandling();
 
         super.onCreate(savedInstanceState);
         setContentView(R.layout.search_activity_main);
 
         suggestionsFragment = (SuggestionsFragment) getSupportFragmentManager().findFragmentById(R.id.suggestions);
         postSearchFragment = (PostSearchFragment)  getSupportFragmentManager().findFragmentById(R.id.postsearch);
 
         searchEngineManager = new SearchEngineManager(this, Distribution.init(this));
         searchEngineManager.setChangeCallback(this);
 
         // Initialize the fragments with the selected search engine.
         searchEngineManager.getEngine(this);
 
-        queryHandler = new AsyncQueryHandler(getContentResolver()) {};
+        queryHandler = new AsyncQueryHandlerImpl(getContentResolver());
 
         searchBar = (SearchBar) findViewById(R.id.search_bar);
         searchBar.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
                 setEditState(EditState.EDITING);
             }
         });