From ceea1b9d40b80c5e24a12ae0374afc053dad09fb Mon Sep 17 00:00:00 2001
From: Wu-cheng Li <wuchengli@google.com>
Date: Fri, 11 Nov 2011 16:51:23 +0800
Subject: Fix sometimes share icons disappear.

bug:5580133
Change-Id: I4f76ac8d03a54cfd7105e70ca4f1d643e01d3293
---
 src/com/android/camera/ui/OneRowGridView.java | 26 +++++++++++++++-----------
 src/com/android/camera/ui/SharePopup.java     |  2 ++
 2 files changed, 17 insertions(+), 11 deletions(-)

(limited to 'src/com')

diff --git a/src/com/android/camera/ui/OneRowGridView.java b/src/com/android/camera/ui/OneRowGridView.java
index 5e37d35..2545f1c 100644
--- a/src/com/android/camera/ui/OneRowGridView.java
+++ b/src/com/android/camera/ui/OneRowGridView.java
@@ -16,28 +16,32 @@
 
 package com.android.camera.ui;
 
-import com.android.camera.R;
-import com.android.camera.Util;
-
 import android.content.Context;
 import android.util.AttributeSet;
 import android.widget.GridView;
 
 public class OneRowGridView extends GridView {
+    private int mInternalRequestedColumnWidth;
     public OneRowGridView(Context context, AttributeSet attrs) {
         super(context, attrs);
     }
 
     @Override
+    public void setColumnWidth(int columnWidth) {
+        super.setColumnWidth(columnWidth);
+        if (mInternalRequestedColumnWidth != columnWidth) {
+            mInternalRequestedColumnWidth = columnWidth;
+            requestLayout();
+        }
+    }
+
+    @Override
     protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
-        // Once we know the number of children in this view, we have to set
-        // the correct width and height for containing the icons in one row.
-        int n = getChildCount();
-        if (n == 0) {
-            super.onMeasure(widthMeasureSpec, heightMeasureSpec);
-        } else {
-            setMeasuredDimension((n * getChildAt(0).getMeasuredWidth()),
-                    getMeasuredHeight());
+        if (mInternalRequestedColumnWidth != 0) {
+            int n = (getAdapter() == null) ? 0 : getAdapter().getCount();
+            int size = mInternalRequestedColumnWidth * n;
+            widthMeasureSpec = MeasureSpec.makeMeasureSpec(size, MeasureSpec.EXACTLY);
         }
+        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
     }
 }
diff --git a/src/com/android/camera/ui/SharePopup.java b/src/com/android/camera/ui/SharePopup.java
index 134b7c0..b4b0462 100644
--- a/src/com/android/camera/ui/SharePopup.java
+++ b/src/com/android/camera/ui/SharePopup.java
@@ -285,6 +285,8 @@ public class SharePopup extends PopupWindow implements View.OnClickListener,
         if (((Activity) mContext).getRequestedOrientation()
                 == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
             mShareList.setNumColumns(items.size());
+            int width = mContext.getResources().getDimensionPixelSize(R.dimen.share_item_width);
+            mShareList.setColumnWidth(width);
         }
 
         SimpleAdapter listItemAdapter = new MySimpleAdapter(mContext, items,
-- 
cgit v1.1