diff options
| author | The Android Open Source Project <initial-contribution@android.com> | 2009-03-02 22:54:33 -0800 |
|---|---|---|
| committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-02 22:54:33 -0800 |
| commit | 3dec7d563a2f3e1eb967ce2054a00b6620e3558c (patch) | |
| tree | aa3b0365c47cb3c1607c0dc76c8d32b4046fc287 /core/java/android/widget/GridView.java | |
| parent | 15ab3eae2ec3d73b3e8aa60b33ae41445bf83f4b (diff) | |
auto import from //depot/cupcake/@137055
Diffstat (limited to 'core/java/android/widget/GridView.java')
| -rw-r--r-- | core/java/android/widget/GridView.java | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/core/java/android/widget/GridView.java b/core/java/android/widget/GridView.java index 38bfc7c17b44..6bbf062c3afe 100644 --- a/core/java/android/widget/GridView.java +++ b/core/java/android/widget/GridView.java @@ -924,32 +924,23 @@ public class GridView extends AbsListView { final int count = mItemCount; if (count > 0) { final View child = obtainView(0); - final int childViewType = mAdapter.getItemViewType(0); - AbsListView.LayoutParams lp = (AbsListView.LayoutParams) child.getLayoutParams(); - if (lp == null) { - lp = new AbsListView.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, + AbsListView.LayoutParams p = (AbsListView.LayoutParams)child.getLayoutParams(); + if (p == null) { + p = new AbsListView.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0); - child.setLayoutParams(lp); - } - lp.viewType = childViewType; - - final int childWidthSpec = ViewGroup.getChildMeasureSpec(widthMeasureSpec, - mListPadding.left + mListPadding.right, lp.width); - - int lpHeight = lp.height; - - int childHeightSpec; - if (lpHeight > 0) { - childHeightSpec = MeasureSpec.makeMeasureSpec(lpHeight, MeasureSpec.EXACTLY); - } else { - childHeightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); } + p.viewType = mAdapter.getItemViewType(0); + int childHeightSpec = getChildMeasureSpec( + MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), 0, p.height); + int childWidthSpec = getChildMeasureSpec( + MeasureSpec.makeMeasureSpec(mColumnWidth, MeasureSpec.EXACTLY), 0, p.width); child.measure(childWidthSpec, childHeightSpec); + childHeight = child.getMeasuredHeight(); - if (mRecycler.shouldRecycleViewType(childViewType)) { + if (mRecycler.shouldRecycleViewType(p.viewType)) { mRecycler.addScrapView(child); } } |
