Backout of bug 898187.
☠☠ backed out by 58523c4666e8 ☠ ☠
authorSriram Ramasubramanian <sriram@mozilla.com>
Mon, 29 Jul 2013 11:59:40 -0700
changeset 143473 ce8fb2c1f618a43d0fdd01307a587b5009299dae
parent 143472 a7c85fd8b5c7bda742173c9e1d342fecc4b4c33f
child 143474 58523c4666e86e4be63db749fe050080c646abe8
push id25130
push userlrocha@mozilla.com
push dateWed, 21 Aug 2013 09:41:27 +0000
treeherdermozilla-central@b2486721572e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs898187
milestone25.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
Backout of bug 898187.
mobile/android/base/home/BrowserSearch.java
--- a/mobile/android/base/home/BrowserSearch.java
+++ b/mobile/android/base/home/BrowserSearch.java
@@ -28,17 +28,17 @@ import android.app.Activity;
 import android.content.Context;
 import android.database.Cursor;
 import android.graphics.Bitmap;
 import android.net.Uri;
 import android.os.Bundle;
 import android.support.v4.app.LoaderManager.LoaderCallbacks;
 import android.support.v4.content.AsyncTaskLoader;
 import android.support.v4.content.Loader;
-import android.support.v4.widget.CursorAdapter;
+import android.support.v4.widget.SimpleCursorAdapter;
 import android.text.TextUtils;
 import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.view.ViewGroup;
 import android.view.ViewStub;
 import android.view.WindowManager.LayoutParams;
@@ -105,16 +105,19 @@ public class BrowserSearch extends HomeF
     private boolean mSuggestionsEnabled;
 
     // Callbacks used for the search and favicon cursor loaders
     private CursorLoaderCallbacks mCursorLoaderCallbacks;
 
     // Callbacks used for the search suggestion loader
     private SuggestionLoaderCallbacks mSuggestionLoaderCallbacks;
 
+    // Inflater used by the adapter
+    private LayoutInflater mInflater;
+
     // Autocomplete handler used when filtering results
     private AutocompleteHandler mAutocompleteHandler;
 
     // On URL open listener
     private OnUrlOpenListener mUrlOpenListener;
 
     // On search listener
     private OnSearchListener mSearchListener;
@@ -163,22 +166,25 @@ public class BrowserSearch extends HomeF
         }
 
         try {
             mEditSuggestionListener = (OnEditSuggestionListener) activity;
         } catch (ClassCastException e) {
             throw new ClassCastException(activity.toString()
                     + " must implement BrowserSearch.OnEditSuggestionListener");
         }
+
+        mInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
     }
 
     @Override
     public void onDetach() {
         super.onDetach();
 
+        mInflater = null;
         mAutocompleteHandler = null;
         mUrlOpenListener = null;
         mSearchListener = null;
         mEditSuggestionListener = null;
     }
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
@@ -612,25 +618,25 @@ public class BrowserSearch extends HomeF
         protected void onReset() {
             super.onReset();
 
             onStopLoading();
             mSuggestions = null;
         }
     }
 
-    private class SearchAdapter extends CursorAdapter {
+    private class SearchAdapter extends SimpleCursorAdapter {
         private static final int ROW_SEARCH = 0;
         private static final int ROW_STANDARD = 1;
         private static final int ROW_SUGGEST = 2;
 
         private static final int ROW_TYPE_COUNT = 3;
 
         public SearchAdapter(Context context) {
-            super(context, null);
+            super(context, -1, null, new String[] {}, new int[] {});
         }
 
         @Override
         public int getItemViewType(int position) {
             final int engine = getEngineIndex(position);
 
             if (engine == -1) {
                 return ROW_STANDARD;
@@ -685,21 +691,19 @@ public class BrowserSearch extends HomeF
             return resultCount + mSearchEngines.size();
         }
 
         @Override
         public View getView(int position, View convertView, ViewGroup parent) {
             final int type = getItemViewType(position);
 
             if (type == ROW_SEARCH || type == ROW_SUGGEST) {
-                // Cursor doesn't know about search suggestions.
-                // Hence overriding getView() to handle this special case.
                 final SearchEngineRow row;
                 if (convertView == null) {
-                    row = (SearchEngineRow) LayoutInflater.from(parent.getContext()).inflate(R.layout.home_search_item_row, parent, false);
+                    row = (SearchEngineRow) mInflater.inflate(R.layout.home_search_item_row, mList, false);
                     row.setOnUrlOpenListener(mUrlOpenListener);
                     row.setOnSearchListener(mSearchListener);
                     row.setOnEditSuggestionListener(mEditSuggestionListener);
                 } else {
                     row = (SearchEngineRow) convertView;
                 }
 
                 row.setSearchTerm(mSearchTerm);
@@ -709,30 +713,35 @@ public class BrowserSearch extends HomeF
                 row.updateFromSearchEngine(engine, animate);
                 if (animate) {
                     // Only animate suggestions the first time they are shown
                     mAnimateSuggestions = false;
                 }
 
                 return row;
             } else {
+                final TwoLinePageRow row;
+                if (convertView == null) {
+                    row = (TwoLinePageRow) mInflater.inflate(R.layout.home_item_row, mList, false);
+                } else {
+                    row = (TwoLinePageRow) convertView;
+                }
+
                 // Account for the search engines
                 position -= getSuggestEngineCount();
-                return super.getView(position, convertView, parent);
-            }
-        }
 
-        @Override
-        public void bindView(View view, Context context, Cursor cursor) {
-            ((TwoLinePageRow) view).updateFromCursor(cursor);
-        }
+                final Cursor c = getCursor();
+                if (!c.moveToPosition(position)) {
+                    throw new IllegalStateException("Couldn't move cursor to position " + position);
+                }
 
-        @Override
-        public View newView(Context context, Cursor cursor, ViewGroup parent) {
-            return LayoutInflater.from(context).inflate(R.layout.home_item_row, parent, false);
+                row.updateFromCursor(c);
+
+                return row;
+            }
         }
 
         private int getSuggestEngineCount() {
             return (TextUtils.isEmpty(mSearchTerm) || mSuggestClient == null || !mSuggestionsEnabled) ? 0 : 1;
         }
 
         private int getEngineIndex(int position) {
             final int resultCount = super.getCount();
@@ -863,9 +872,9 @@ public class BrowserSearch extends HomeF
 
         private void deselectRow() {
             if (mSelectedEngineRow != null) {
                 mSelectedEngineRow.onDeselected();
                 mSelectedEngineRow = null;
             }
         }
     }
-}
+}
\ No newline at end of file