Revert "Removing onInitialize method and creating searchManager in getView"

This reverts commit 6530017bb88179aeb1e3f131738da8f0d7592f36.

Change-Id: I8ecfd21ec854cfe1774f16d2d50c7a0e45dd6865
diff --git a/src/com/android/launcher3/allapps/AllAppsSearchBarController.java b/src/com/android/launcher3/allapps/AllAppsSearchBarController.java
index 9e51406..341539c 100644
--- a/src/com/android/launcher3/allapps/AllAppsSearchBarController.java
+++ b/src/com/android/launcher3/allapps/AllAppsSearchBarController.java
@@ -15,6 +15,7 @@
  */
 package com.android.launcher3.allapps;
 
+import android.content.ComponentName;
 import android.graphics.Rect;
 import android.view.View;
 import android.view.ViewGroup;
@@ -34,13 +35,17 @@
     /**
      * Sets the references to the apps model and the search result callback.
      */
-    public void initialize(AlphabeticalAppsList apps, Callbacks cb) {
+    public final void initialize(AlphabeticalAppsList apps, Callbacks cb) {
         mApps = apps;
         mCb = cb;
+        onInitialize();
     }
 
-    @Deprecated
-    protected void onInitialize() { };
+    /**
+     * To be overridden by subclasses.  This method will get called when the controller is set,
+     * before getView().
+     */
+    protected abstract void onInitialize();
 
     /**
      * Returns the search bar view.
diff --git a/src/com/android/launcher3/allapps/DefaultAppSearchController.java b/src/com/android/launcher3/allapps/DefaultAppSearchController.java
index 629bfea..20924af 100644
--- a/src/com/android/launcher3/allapps/DefaultAppSearchController.java
+++ b/src/com/android/launcher3/allapps/DefaultAppSearchController.java
@@ -31,6 +31,7 @@
 
 import java.util.List;
 
+
 /**
  * The default search controller.
  */
@@ -73,8 +74,6 @@
 
     @Override
     public View getView(ViewGroup parent) {
-        mSearchManager = new DefaultAppSearchAlgorithm(mApps.getApps());
-
         LayoutInflater inflater = LayoutInflater.from(parent.getContext());
         mSearchView = inflater.inflate(R.layout.all_apps_search_bar, parent, false);
         mSearchView.setOnClickListener(this);
@@ -115,6 +114,11 @@
     }
 
     @Override
+    protected void onInitialize() {
+        mSearchManager = new DefaultAppSearchAlgorithm(mApps.getApps());
+    }
+
+    @Override
     public void reset() {
         hideSearchField(false, null);
     }