mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 735636 - Factor out icon update into separate method (r=wesj)
This commit is contained in:
parent
6f17b2ad94
commit
c08adb51c4
@ -498,6 +498,30 @@ public class PromptService implements OnClickListener, OnCancelListener, OnItemC
|
|||||||
return VIEW_TYPE_COUNT;
|
return VIEW_TYPE_COUNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void maybeUpdateIcon(PromptListItem item, TextView t) {
|
||||||
|
if (item.icon == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Resources res = GeckoApp.mAppContext.getResources();
|
||||||
|
|
||||||
|
// Set padding inside the item.
|
||||||
|
t.setPadding(item.inGroup ? mLeftRightTextWithIconPadding + mGroupPaddingSize :
|
||||||
|
mLeftRightTextWithIconPadding,
|
||||||
|
mTopBottomTextWithIconPadding,
|
||||||
|
mLeftRightTextWithIconPadding,
|
||||||
|
mTopBottomTextWithIconPadding);
|
||||||
|
|
||||||
|
// Set the padding between the icon and the text.
|
||||||
|
t.setCompoundDrawablePadding(mIconTextPadding);
|
||||||
|
|
||||||
|
// We want the icon to be of a specific size. Some do not
|
||||||
|
// follow this rule so we have to resize them.
|
||||||
|
Bitmap bitmap = ((BitmapDrawable) item.icon).getBitmap();
|
||||||
|
Drawable d = new BitmapDrawable(Bitmap.createScaledBitmap(bitmap, mIconSize, mIconSize, true));
|
||||||
|
|
||||||
|
t.setCompoundDrawablesWithIntrinsicBounds(d, null, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
PromptListItem item = getItem(position);
|
PromptListItem item = getItem(position);
|
||||||
ViewHolder viewHolder = null;
|
ViewHolder viewHolder = null;
|
||||||
@ -543,29 +567,8 @@ public class PromptService implements OnClickListener, OnCancelListener, OnItemC
|
|||||||
} catch (Exception ex) { }
|
} catch (Exception ex) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (viewHolder.textView != null) {
|
viewHolder.textView.setText(item.label);
|
||||||
final TextView t1 = viewHolder.textView;
|
maybeUpdateIcon(item, viewHolder.textView);
|
||||||
t1.setText(item.label);
|
|
||||||
|
|
||||||
if (item.icon != null) {
|
|
||||||
Resources res = GeckoApp.mAppContext.getResources();
|
|
||||||
|
|
||||||
// Set padding inside the item.
|
|
||||||
t1.setPadding(item. inGroup ? mLeftRightTextWithIconPadding + mGroupPaddingSize : mLeftRightTextWithIconPadding,
|
|
||||||
mTopBottomTextWithIconPadding,
|
|
||||||
mLeftRightTextWithIconPadding, mTopBottomTextWithIconPadding);
|
|
||||||
|
|
||||||
// Set the padding between the icon and the text.
|
|
||||||
t1.setCompoundDrawablePadding(mIconTextPadding);
|
|
||||||
|
|
||||||
// We want the icon to be of a specific size. Some do not
|
|
||||||
// follow this rule so we have to resize them.
|
|
||||||
Bitmap bitmap = ((BitmapDrawable) item.icon).getBitmap();
|
|
||||||
Drawable d = new BitmapDrawable(Bitmap.createScaledBitmap(bitmap, mIconSize, mIconSize, true));
|
|
||||||
|
|
||||||
t1.setCompoundDrawablesWithIntrinsicBounds(d, null, null, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return convertView;
|
return convertView;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user