diff --git a/mobile/android/base/AboutHomeContent.java b/mobile/android/base/AboutHomeContent.java index f3835e9cb14..c91988c8f0c 100644 --- a/mobile/android/base/AboutHomeContent.java +++ b/mobile/android/base/AboutHomeContent.java @@ -108,8 +108,7 @@ public class AboutHomeContent extends ScrollView } public void init() { - mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - mInflater.inflate(R.layout.abouthome_content, this); + inflate(); mAccountManager = AccountManager.get(mContext); @@ -120,6 +119,29 @@ public class AboutHomeContent extends ScrollView } }, GeckoAppShell.getHandler(), false); + mRemoteTabClickListener = new View.OnClickListener() { + @Override + public void onClick(View v) { + String url = ((String) v.getTag()); + JSONObject args = new JSONObject(); + try { + args.put("url", url); + args.put("engine", null); + args.put("userEntered", false); + } catch (Exception e) { + Log.e(LOGTAG, "error building JSON arguments"); + } + + Log.d(LOGTAG, "Sending message to Gecko: " + SystemClock.uptimeMillis() + " - Tab:Add"); + GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Tab:Add", args.toString())); + } + }; + } + + private void inflate() { + mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + mInflater.inflate(R.layout.abouthome_content, this); + mTopSitesGrid = (GridView)findViewById(R.id.top_sites_grid); mTopSitesGrid.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView parent, View v, int position, long id) { @@ -179,24 +201,6 @@ public class AboutHomeContent extends ScrollView } }); - mRemoteTabClickListener = new View.OnClickListener() { - @Override - public void onClick(View v) { - String url = ((String) v.getTag()); - JSONObject args = new JSONObject(); - try { - args.put("url", url); - args.put("engine", null); - args.put("userEntered", false); - } catch (Exception e) { - Log.e(LOGTAG, "error building JSON arguments"); - } - - Log.d(LOGTAG, "Sending message to Gecko: " + SystemClock.uptimeMillis() + " - Tab:Add"); - GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Tab:Add", args.toString())); - } - }; - setTopSitesConstants(); } @@ -335,7 +339,11 @@ public class AboutHomeContent extends ScrollView public void onConfigurationChanged(Configuration newConfig) { if (mTopSitesAdapter != null) mTopSitesAdapter.notifyDataSetChanged(); - setTopSitesConstants(); + + removeAllViews(); // We must remove the currently inflated view to allow for reinflation. + inflate(); + mTopSitesGrid.setAdapter(mTopSitesAdapter); // mTopSitesGrid is a new instance (from loadTopSites()). + update(AboutHomeContent.UpdateFlags.ALL); // Refresh all elements. super.onConfigurationChanged(newConfig); }