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

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

Issue 2664083007: Always adds margin at the end of the label to handle case where label (Closed)
Patch Set: Creates new layout params for sublabel to handle view reuse. Created 3 years, 10 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.Color; 8 import android.graphics.Color;
9 import android.graphics.Typeface; 9 import android.graphics.Typeface;
10 import android.support.annotation.Nullable; 10 import android.support.annotation.Nullable;
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 labelView.setTextColor(ApiCompatibilityUtils.getColor( 183 labelView.setTextColor(ApiCompatibilityUtils.getColor(
184 mContext.getResources(), item.getLabelFontColorResId())); 184 mContext.getResources(), item.getLabelFontColorResId()));
185 labelView.setTextSize(TypedValue.COMPLEX_UNIT_PX, 185 labelView.setTextSize(TypedValue.COMPLEX_UNIT_PX,
186 mContext.getResources().getDimension(item.getLabelFontSizeResId( ))); 186 mContext.getResources().getDimension(item.getLabelFontSizeResId( )));
187 187
188 TextView sublabelView = (TextView) layout.findViewById(R.id.dropdown_sub label); 188 TextView sublabelView = (TextView) layout.findViewById(R.id.dropdown_sub label);
189 CharSequence sublabel = item.getSublabel(); 189 CharSequence sublabel = item.getSublabel();
190 if (TextUtils.isEmpty(sublabel)) { 190 if (TextUtils.isEmpty(sublabel)) {
191 sublabelView.setVisibility(View.GONE); 191 sublabelView.setVisibility(View.GONE);
192 } else { 192 } else {
193 sublabelView.setLayoutParams(layoutParams); 193 if (item.isLabelAndSublabelOnSameLine()) {
194 // Use the layout params in |dropdown_item.xml| for the sublabel if it is on the
195 // same line as the label. We regenerate the layout params in ca se the view is
196 // reused and the label and sublabel are on the same line when t he view is reused.
197 LinearLayout.LayoutParams subLabelLayoutParams = new LinearLayou t.LayoutParams(
198 LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
199 ApiCompatibilityUtils.setMarginStart(subLabelLayoutParams, mLabe lHorizontalMargin);
200 ApiCompatibilityUtils.setMarginEnd(subLabelLayoutParams, mLabelH orizontalMargin);
201 sublabelView.setLayoutParams(subLabelLayoutParams);
202 } else {
203 sublabelView.setLayoutParams(layoutParams);
204 }
194 sublabelView.setText(sublabel); 205 sublabelView.setText(sublabel);
195 sublabelView.setTextSize(TypedValue.COMPLEX_UNIT_PX, 206 sublabelView.setTextSize(TypedValue.COMPLEX_UNIT_PX,
196 mContext.getResources().getDimension(item.getSublabelFontSiz eResId())); 207 mContext.getResources().getDimension(item.getSublabelFontSiz eResId()));
197 sublabelView.setVisibility(View.VISIBLE); 208 sublabelView.setVisibility(View.VISIBLE);
198 } 209 }
199 210
200 ImageView iconViewStart = (ImageView) layout.findViewById(R.id.start_dro pdown_icon); 211 ImageView iconViewStart = (ImageView) layout.findViewById(R.id.start_dro pdown_icon);
201 ImageView iconViewEnd = (ImageView) layout.findViewById(R.id.end_dropdow n_icon); 212 ImageView iconViewEnd = (ImageView) layout.findViewById(R.id.end_dropdow n_icon);
202 if (item.isIconAtStart()) { 213 if (item.isIconAtStart()) {
203 iconViewEnd.setVisibility(View.GONE); 214 iconViewEnd.setVisibility(View.GONE);
(...skipping 30 matching lines...) Expand all
234 return mAreAllItemsEnabled; 245 return mAreAllItemsEnabled;
235 } 246 }
236 247
237 @Override 248 @Override
238 public boolean isEnabled(int position) { 249 public boolean isEnabled(int position) {
239 if (position < 0 || position >= getCount()) return false; 250 if (position < 0 || position >= getCount()) return false;
240 DropdownItem item = getItem(position); 251 DropdownItem item = getItem(position);
241 return item.isEnabled() && !item.isGroupHeader(); 252 return item.isEnabled() && !item.isGroupHeader();
242 } 253 }
243 } 254 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698