From 565a5a48c09cfcee5740a6a92eb98aadb7a5372b Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Tue, 8 May 2012 11:44:48 +0100 Subject: [PATCH] Bug 725389 - Set number of columns in top site's grid view onMeasure (r=mfinkle) --- mobile/android/base/AboutHomeContent.java | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/mobile/android/base/AboutHomeContent.java b/mobile/android/base/AboutHomeContent.java index 2ae1d0a1381..ddc1b05e7da 100644 --- a/mobile/android/base/AboutHomeContent.java +++ b/mobile/android/base/AboutHomeContent.java @@ -324,14 +324,6 @@ public class AboutHomeContent extends ScrollView return NUMBER_OF_TOP_SITES_PORTRAIT; } - private int getNumberOfColumns() { - Configuration config = getContext().getResources().getConfiguration(); - if (config.orientation == Configuration.ORIENTATION_LANDSCAPE) - return NUMBER_OF_COLS_LANDSCAPE; - else - return NUMBER_OF_COLS_PORTRAIT; - } - private void loadTopSites(final Activity activity) { // Ensure we initialize GeckoApp's startup mode in // background thread before we use it when updating @@ -361,8 +353,6 @@ public class AboutHomeContent extends ScrollView mTopSitesAdapter.changeCursor(mCursor); } - mTopSitesGrid.setNumColumns(getNumberOfColumns()); - updateLayout(startupMode, syncIsSetup); } }); @@ -396,8 +386,6 @@ public class AboutHomeContent extends ScrollView @Override public void onConfigurationChanged(Configuration newConfig) { - if (mTopSitesGrid != null) - mTopSitesGrid.setNumColumns(getNumberOfColumns()); if (mTopSitesAdapter != null) mTopSitesAdapter.notifyDataSetChanged(); @@ -709,13 +697,16 @@ public class AboutHomeContent extends ScrollView if (config.orientation == Configuration.ORIENTATION_LANDSCAPE) { nSites = Math.min(nSites, NUMBER_OF_TOP_SITES_LANDSCAPE); numRows = (int) Math.round((double) nSites / NUMBER_OF_COLS_LANDSCAPE); + setNumColumns(NUMBER_OF_COLS_LANDSCAPE); } else { nSites = Math.min(nSites, NUMBER_OF_TOP_SITES_PORTRAIT); numRows = (int) Math.round((double) nSites / NUMBER_OF_COLS_PORTRAIT); + setNumColumns(NUMBER_OF_COLS_PORTRAIT); } int expandedHeightSpec = MeasureSpec.makeMeasureSpec((int)(mDisplayDensity * numRows * kTopSiteItemHeight), MeasureSpec.EXACTLY); + super.onMeasure(widthMeasureSpec, expandedHeightSpec); } }