Bug 1211467 - Use new Fragment.onAttach() API (support library 23). r=mcomella
authorSebastian Kaspari <s.kaspari@gmail.com>
Wed, 07 Oct 2015 09:14:10 +0200
changeset 266340 ca4229eea123cd416fd71f1da1cdd762ae57e546
parent 266339 735d8bed131daa58cfd2f6d68e3900f24c1f531c
child 266341 d823b6f2f8d27f287f21f14ce14f44ba20b06395
push id15551
push users.kaspari@gmail.com
push dateWed, 07 Oct 2015 07:16:12 +0000
treeherderfx-team@d823b6f2f8d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcomella
bugs1211467
milestone44.0a1
Bug 1211467 - Use new Fragment.onAttach() API (support library 23). r=mcomella
mobile/android/search/java/org/mozilla/search/PreSearchFragment.java
mobile/android/search/java/org/mozilla/search/autocomplete/SuggestionsFragment.java
--- a/mobile/android/search/java/org/mozilla/search/PreSearchFragment.java
+++ b/mobile/android/search/java/org/mozilla/search/PreSearchFragment.java
@@ -1,15 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.search;
 
-import android.app.Activity;
+import android.content.Context;
 import android.database.Cursor;
 import android.graphics.Rect;
 import android.net.Uri;
 import android.os.AsyncTask;
 import android.os.Bundle;
 import android.support.v4.app.Fragment;
 import android.support.v4.app.LoaderManager;
 import android.support.v4.content.CursorLoader;
@@ -58,23 +58,23 @@ public class PreSearchFragment extends F
 
     private static final int LOADER_ID_SEARCH_HISTORY = 1;
 
     public PreSearchFragment() {
         // Mandatory empty constructor for Android's Fragment.
     }
 
     @Override
-    public void onAttach(Activity activity) {
-        super.onAttach(activity);
+    public void onAttach(Context context) {
+        super.onAttach(context);
 
-        if (activity instanceof AcceptsSearchQuery) {
-            searchListener = (AcceptsSearchQuery) activity;
+        if (context instanceof AcceptsSearchQuery) {
+            searchListener = (AcceptsSearchQuery) context;
         } else {
-            throw new ClassCastException(activity.toString() + " must implement AcceptsSearchQuery.");
+            throw new ClassCastException(context.toString() + " must implement AcceptsSearchQuery.");
         }
     }
 
     @Override
     public void onDetach() {
         super.onDetach();
         searchListener = null;
     }
--- a/mobile/android/search/java/org/mozilla/search/autocomplete/SuggestionsFragment.java
+++ b/mobile/android/search/java/org/mozilla/search/autocomplete/SuggestionsFragment.java
@@ -11,17 +11,16 @@ import org.mozilla.gecko.R;
 import org.mozilla.gecko.SuggestClient;
 import org.mozilla.gecko.Telemetry;
 import org.mozilla.gecko.TelemetryContract;
 import org.mozilla.gecko.util.ColorUtils;
 import org.mozilla.search.AcceptsSearchQuery;
 import org.mozilla.search.AcceptsSearchQuery.SuggestionAnimation;
 import org.mozilla.search.providers.SearchEngine;
 
-import android.app.Activity;
 import android.content.Context;
 import android.graphics.Rect;
 import android.os.Bundle;
 import android.support.v4.app.Fragment;
 import android.support.v4.app.LoaderManager;
 import android.support.v4.content.AsyncTaskLoader;
 import android.support.v4.content.Loader;
 import android.text.SpannableString;
@@ -63,27 +62,27 @@ public class SuggestionsFragment extends
     // Holds the list of search suggestions.
     private ListView suggestionsList;
 
     public SuggestionsFragment() {
         // Required empty public constructor
     }
 
     @Override
-    public void onAttach(Activity activity) {
-        super.onAttach(activity);
+    public void onAttach(Context context) {
+        super.onAttach(context);
 
-        if (activity instanceof AcceptsSearchQuery) {
-            searchListener = (AcceptsSearchQuery) activity;
+        if (context instanceof AcceptsSearchQuery) {
+            searchListener = (AcceptsSearchQuery) context;
         } else {
-            throw new ClassCastException(activity.toString() + " must implement AcceptsSearchQuery.");
+            throw new ClassCastException(context.toString() + " must implement AcceptsSearchQuery.");
         }
 
         suggestionLoaderCallbacks = new SuggestionLoaderCallbacks();
-        autoCompleteAdapter = new AutoCompleteAdapter(activity);
+        autoCompleteAdapter = new AutoCompleteAdapter(context);
     }
 
     @Override
     public void onDetach() {
         super.onDetach();
 
         searchListener = null;
         suggestionLoaderCallbacks = null;