diff options
author | Michael Jurka <mikejurka@google.com> | 2011-05-17 18:21:03 -0700 |
---|---|---|
committer | Michael Jurka <mikejurka@google.com> | 2011-05-18 14:24:52 -0700 |
commit | 4c6016fab10685eea750c092f1ffa3e862c85df2 (patch) | |
tree | e14cba7d3f84490aae7e3fbc0a35c18d4a795af2 /src/com/android/launcher2/CustomizePagedView.java | |
parent | d1d48a68409c5f0777e608f83950b41a2306f3f3 (diff) | |
download | android_packages_apps_Trebuchet-4c6016fab10685eea750c092f1ffa3e862c85df2.tar.gz android_packages_apps_Trebuchet-4c6016fab10685eea750c092f1ffa3e862c85df2.tar.bz2 android_packages_apps_Trebuchet-4c6016fab10685eea750c092f1ffa3e862c85df2.zip |
Allow determining # of rows/columns for All Apps and Customize at run time
Diffstat (limited to 'src/com/android/launcher2/CustomizePagedView.java')
-rw-r--r-- | src/com/android/launcher2/CustomizePagedView.java | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/com/android/launcher2/CustomizePagedView.java b/src/com/android/launcher2/CustomizePagedView.java index b2e308d76..cdae80c45 100644 --- a/src/com/android/launcher2/CustomizePagedView.java +++ b/src/com/android/launcher2/CustomizePagedView.java @@ -54,6 +54,7 @@ import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.View; +import android.view.View.MeasureSpec; import android.view.animation.DecelerateInterpolator; import android.view.animation.LinearInterpolator; import android.widget.Checkable; @@ -124,6 +125,8 @@ public class CustomizePagedView extends PagedViewWithDraggableItems private final Canvas mCanvas = new Canvas(); private final LayoutInflater mInflater; + private boolean mFirstMeasure = true; + private final float mTmpFloatPos[] = new float[2]; private final float ANIMATION_SCALE = 0.5f; @@ -190,6 +193,31 @@ public class CustomizePagedView extends PagedViewWithDraggableItems mCenterPagesVertically = false; } + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + + final int widthSize = MeasureSpec.getSize(widthMeasureSpec); + final int heightSize = MeasureSpec.getSize(heightMeasureSpec); + + if (mFirstMeasure) { + mFirstMeasure = false; + + // TODO: actually calculate mCellCountX/mCellCountY as some function of + // widthSize and heightSize + //mCellCountX = ? + //mCellCountY = ? + + // Since mCellCountX/mCellCountY changed, we need to update the pages + invalidatePageData(); + + // Create a dummy page and set it up to find out the content width (used by our parent) + PagedViewCellLayout layout = new PagedViewCellLayout(getContext()); + setupPage(layout); + mPageContentWidth = layout.getContentWidth(); + } + } + public void setLauncher(Launcher launcher) { Context context = getContext(); mLauncher = launcher; @@ -1093,6 +1121,11 @@ public class CustomizePagedView extends PagedViewWithDraggableItems @Override public void syncPages() { + if (mFirstMeasure) { + // We don't know our size yet, which means we haven't calculated cell count x/y; + // onMeasure will call us once we figure out our size + return; + } boolean enforceMinimumPagedWidths = false; boolean centerPagedViewCellLayouts = false; switch (mCustomizationType) { |