Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(114)

Side by Side Diff: ui/android/java/src/org/chromium/ui/DropdownPopupWindow.java

Issue 606153002: [android] Password generation UI for android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Set the width of the popup correctly. Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.ui; 5 package org.chromium.ui;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.graphics.Rect; 8 import android.graphics.Rect;
9 import android.util.Log; 9 import android.util.Log;
10 import android.view.View; 10 import android.view.View;
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 142
143 @Override 143 @Override
144 public void setOnDismissListener(PopupWindow.OnDismissListener listener) { 144 public void setOnDismissListener(PopupWindow.OnDismissListener listener) {
145 mOnDismissListener = listener; 145 mOnDismissListener = listener;
146 } 146 }
147 147
148 /** 148 /**
149 * Sets the text direction in the dropdown. Should be called before show(). 149 * Sets the text direction in the dropdown. Should be called before show().
150 * @param isRtl If true, then dropdown text direciton is right to left. 150 * @param isRtl If true, then dropdown text direciton is right to left.
151 */ 151 */
152 protected void setRtl(boolean isRtl) { 152 public void setRtl(boolean isRtl) {
153 mRtl = isRtl; 153 mRtl = isRtl;
154 } 154 }
155 155
156 /** 156 /**
157 * Returns the width of the anchor to which this popup is attached.
158 * @return The width of the anchor.
159 */
160 public float getAnchorWidth() {
161 return mAnchorWidth;
162 }
163
164 /**
157 * Measures the width of the list content. 165 * Measures the width of the list content.
158 * @return The popup window width in pixels. 166 * @return The popup window width in pixels.
159 */ 167 */
160 private int measureContentWidth() { 168 private int measureContentWidth() {
169 if (mAdapter == null) return 0;
aurimas (slooooooooow) 2014/10/23 00:57:01 Why would mAdapter be null?
161 int maxWidth = 0; 170 int maxWidth = 0;
162 View itemView = null; 171 View[] itemViews = new View[mAdapter.getViewTypeCount()];
163 if (mAdapter == null) return 0;
164 final int widthMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec. UNSPECIFIED); 172 final int widthMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec. UNSPECIFIED);
165 final int heightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec .UNSPECIFIED); 173 final int heightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec .UNSPECIFIED);
166 for (int i = 0; i < mAdapter.getCount(); i++) { 174 for (int i = 0; i < mAdapter.getCount(); i++) {
167 itemView = mAdapter.getView(i, itemView, null); 175 int type = mAdapter.getItemViewType(i);
176 itemViews[type] = mAdapter.getView(i, itemViews[type], null);
177 View itemView = itemViews[type];
168 LinearLayout.LayoutParams params = 178 LinearLayout.LayoutParams params =
169 new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP _CONTENT, 179 new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP _CONTENT,
170 LinearLayout.LayoutParams.WRAP_CONTENT); 180 LinearLayout.LayoutParams.WRAP_CONTENT);
171 itemView.setLayoutParams(params); 181 itemView.setLayoutParams(params);
172 itemView.measure(widthMeasureSpec, heightMeasureSpec); 182 itemView.measure(widthMeasureSpec, heightMeasureSpec);
173 maxWidth = Math.max(maxWidth, itemView.getMeasuredWidth()); 183 maxWidth = Math.max(maxWidth, itemView.getMeasuredWidth());
174 } 184 }
175 return maxWidth; 185 return maxWidth;
176 } 186 }
177 } 187 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698