Bug 721354 - Remove onFinishInflate handling from AboutHomeContent (r=blassey)
authorLucas Rocha <lucasr@mozilla.com>
Fri, 27 Jan 2012 10:08:21 +0000
changeset 85547 878b3da812e1c6c25c81ac9701209debad409cb7
parent 85546 e6a2c58123b9f73c2cf5941bce3d747ba0ea1660
child 85548 101feb514dd07b82cd4c1a20011d43a209247e28
push id21930
push usermbrubeck@mozilla.com
push dateFri, 27 Jan 2012 16:32:09 +0000
treeherdermozilla-central@7ab255f53568 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersblassey
bugs721354
milestone12.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 721354 - Remove onFinishInflate handling from AboutHomeContent (r=blassey)
mobile/android/base/AboutHomeContent.java
--- a/mobile/android/base/AboutHomeContent.java
+++ b/mobile/android/base/AboutHomeContent.java
@@ -109,78 +109,70 @@ public class AboutHomeContent extends Sc
 
     public interface UriLoadCallback {
         public void callback(String uriSpec);
     }
 
     public AboutHomeContent(Context context) {
         super(context);
         mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
-    }
+        mInflater.inflate(R.layout.abouthome_content, this);
 
-    @Override
-    protected void onFinishInflate() {
-        super.onFinishInflate();
-        synchronized (this) {
-            if (mTopSitesGrid != null && mAddonsLayout != null && mLastTabsLayout != null)
-                return;
+        mTopSitesGrid = (GridView)findViewById(R.id.top_sites_grid);
+        mTopSitesGrid.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+            public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
+                Cursor c = (Cursor) parent.getItemAtPosition(position);
+
+                String spec = c.getString(c.getColumnIndex(URLColumns.URL));
+                Log.i(LOGTAG, "clicked: " + spec);
 
-            mTopSitesGrid = (GridView)findViewById(R.id.top_sites_grid);
-            mTopSitesGrid.setOnItemClickListener(new AdapterView.OnItemClickListener() {
-                public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
-                    Cursor c = (Cursor) parent.getItemAtPosition(position);
-
-                    String spec = c.getString(c.getColumnIndex(URLColumns.URL));
-                    Log.i(LOGTAG, "clicked: " + spec);
+                if (mUriLoadCallback != null)
+                    mUriLoadCallback.callback(spec);
+            }
+        });
 
-                    if (mUriLoadCallback != null)
-                        mUriLoadCallback.callback(spec);
-                }
-            });
+        mAddonsLayout = (LinearLayout) findViewById(R.id.recommended_addons);
+        mLastTabsLayout = (LinearLayout) findViewById(R.id.last_tabs);
 
-            mAddonsLayout = (LinearLayout) findViewById(R.id.recommended_addons);
-            mLastTabsLayout = (LinearLayout) findViewById(R.id.last_tabs);
+        TextView allTopSitesText = (TextView) findViewById(R.id.all_top_sites_text);
+        allTopSitesText.setOnClickListener(new View.OnClickListener() {
+            public void onClick(View v) {
+                GeckoApp.mAppContext.showAwesomebar(AwesomeBar.Type.EDIT);
+            }
+        });
 
-            TextView allTopSitesText = (TextView) findViewById(R.id.all_top_sites_text);
-            allTopSitesText.setOnClickListener(new View.OnClickListener() {
-                public void onClick(View v) {
-                    GeckoApp.mAppContext.showAwesomebar(AwesomeBar.Type.EDIT);
-                }
-            });
+        TextView allAddonsText = (TextView) findViewById(R.id.all_addons_text);
+        allAddonsText.setOnClickListener(new View.OnClickListener() {
+            public void onClick(View v) {
+                if (mUriLoadCallback != null)
+                    mUriLoadCallback.callback("about:addons");
+            }
+        });
 
-            TextView allAddonsText = (TextView) findViewById(R.id.all_addons_text);
-            allAddonsText.setOnClickListener(new View.OnClickListener() {
-                public void onClick(View v) {
-                    if (mUriLoadCallback != null)
-                        mUriLoadCallback.callback("about:addons");
-                }
-            });
+        TextView syncTextView = (TextView) findViewById(R.id.sync_text);
+        String syncText = syncTextView.getText().toString() + " \u00BB";
+        String boldName = getContext().getResources().getString(R.string.abouthome_sync_bold_name);
+        int styleIndex = syncText.indexOf(boldName);
 
-            TextView syncTextView = (TextView) findViewById(R.id.sync_text);
-            String syncText = syncTextView.getText().toString() + " \u00BB";
-            String boldName = getContext().getResources().getString(R.string.abouthome_sync_bold_name);
-            int styleIndex = syncText.indexOf(boldName);
+        // Highlight any occurrence of "Firefox Sync" in the string
+        // with a bold style.
+        if (styleIndex >= 0) {
+            SpannableString spannableText = new SpannableString(syncText);
+            spannableText.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), styleIndex, styleIndex + 12, 0);
+            syncTextView.setText(spannableText, TextView.BufferType.SPANNABLE);
+        }
 
-            // Highlight any occurrence of "Firefox Sync" in the string
-            // with a bold style.
-            if (styleIndex >= 0) {
-                SpannableString spannableText = new SpannableString(syncText);
-                spannableText.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), styleIndex, styleIndex + 12, 0);
-                syncTextView.setText(spannableText, TextView.BufferType.SPANNABLE);
+        RelativeLayout syncBox = (RelativeLayout) findViewById(R.id.sync_box);
+        syncBox.setOnClickListener(new View.OnClickListener() {
+            public void onClick(View v) {
+                Context context = v.getContext();
+                Intent intent = new Intent(context, SetupSyncActivity.class);
+                context.startActivity(intent);
             }
-
-            RelativeLayout syncBox = (RelativeLayout) findViewById(R.id.sync_box);
-            syncBox.setOnClickListener(new View.OnClickListener() {
-                public void onClick(View v) {
-                    Context context = v.getContext();
-                    Intent intent = new Intent(context, SetupSyncActivity.class);
-                    context.startActivity(intent);
-                }
-            });
-        }
+        });
     }
 
     private void setTopSitesVisibility(boolean visible, boolean hasTopSites) {
         int visibility = visible ? View.VISIBLE : View.GONE;
         int visibilityWithTopSites = visible && hasTopSites ? View.VISIBLE : View.GONE;
         int visibilityWithoutTopSites = visible && !hasTopSites ? View.VISIBLE : View.GONE;
 
         findViewById(R.id.top_sites_grid).setVisibility(visibilityWithTopSites);
@@ -245,18 +237,17 @@ public class AboutHomeContent extends Sc
         Configuration config = getContext().getResources().getConfiguration();
         if (config.orientation == Configuration.ORIENTATION_LANDSCAPE)
             return NUMBER_OF_COLS_LANDSCAPE;
         else
             return NUMBER_OF_COLS_PORTRAIT;
     }
 
     void init(final Activity activity) {
-        mInflater.inflate(R.layout.abouthome_content, this);
-        final Runnable generateCursorsRunnable = new Runnable() {
+        GeckoAppShell.getHandler().post(new Runnable() {
             public void run() {
                 if (mCursor != null)
                     activity.stopManagingCursor(mCursor);
 
                 // Ensure we initialize GeckoApp's startup mode in
                 // background thread before we use it when updating
                 // the top sites section layout in main thread.
                 final GeckoApp.StartupMode startupMode = GeckoApp.mAppContext.getStartupMode();
@@ -289,24 +280,17 @@ public class AboutHomeContent extends Sc
 
                 GeckoAppShell.getHandler().post(new Runnable() {
                     public void run() {
                         readLastTabs(activity);
                         readRecommendedAddons(activity);
                     }
                 });
             }
-        };
-        Runnable finishInflateRunnable = new Runnable() {
-            public void run() {
-                onFinishInflate();
-                GeckoAppShell.getHandler().post(generateCursorsRunnable);
-            }
-        };
-        GeckoApp.mAppContext.mMainHandler.post(finishInflateRunnable);
+        });
     }
 
     public void setUriLoadCallback(UriLoadCallback uriLoadCallback) {
         mUriLoadCallback = uriLoadCallback;
     }
 
     public void onActivityContentChanged(Activity activity) {
         GeckoAppShell.getHandler().post(new Runnable() {