More refactoring.
This commit is contained in:
parent
5f9352b404
commit
3be10f89b6
3 changed files with 21 additions and 22 deletions
|
@ -161,10 +161,10 @@ public class ContextMenuAdapter {
|
|||
public View getView(final int position, View convertView, ViewGroup parent) {
|
||||
// User super class to create the View
|
||||
final ContextMenuItem item = getItem(position);
|
||||
int lid = item.getLayout();
|
||||
lid = lid != -1 ? lid : DEFAULT_LAYOUT_ID;
|
||||
if (lid == R.layout.mode_toggles) {
|
||||
final Set<ApplicationMode> selected = new LinkedHashSet<ApplicationMode>();
|
||||
int layoutId = item.getLayout();
|
||||
layoutId = layoutId != -1 ? layoutId : DEFAULT_LAYOUT_ID;
|
||||
if (layoutId == R.layout.mode_toggles) {
|
||||
final Set<ApplicationMode> selected = new LinkedHashSet<>();
|
||||
return AppModeDialog.prepareAppModeDrawerView((Activity) getContext(),
|
||||
selected, true, new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -179,9 +179,9 @@ public class ContextMenuAdapter {
|
|||
}
|
||||
});
|
||||
}
|
||||
if (convertView == null || (lid != convertView.getTag())) {
|
||||
convertView = LayoutInflater.from(getContext()).inflate(lid, parent, false);
|
||||
convertView.setTag(lid);
|
||||
if (convertView == null || (layoutId != convertView.getTag())) {
|
||||
convertView = LayoutInflater.from(getContext()).inflate(layoutId, parent, false);
|
||||
convertView.setTag(layoutId);
|
||||
}
|
||||
TextView tv = (TextView) convertView.findViewById(R.id.title);
|
||||
if (!item.isCategory()) {
|
||||
|
@ -189,7 +189,7 @@ public class ContextMenuAdapter {
|
|||
}
|
||||
tv.setText(item.isCategory() ? item.getTitle().toUpperCase() : item.getTitle());
|
||||
|
||||
if (layoutId == R.layout.simple_list_menu_item) {
|
||||
if (this.layoutId == R.layout.simple_list_menu_item) {
|
||||
int color = ContextCompat.getColor(getContext(),
|
||||
holoLight ? R.color.icon_color : R.color.dashboard_subheader_text_dark);
|
||||
Drawable imageId = ContextCompat.getDrawable(getContext(), item.getLightIcon());
|
||||
|
@ -203,7 +203,6 @@ public class ContextMenuAdapter {
|
|||
} else {
|
||||
Drawable drawable = getImage(app, position, holoLight);
|
||||
if (drawable != null) {
|
||||
|
||||
((ImageView) convertView.findViewById(R.id.icon)).setImageDrawable(drawable);
|
||||
convertView.findViewById(R.id.icon).setVisibility(View.VISIBLE);
|
||||
} else if (convertView.findViewById(R.id.icon) != null) {
|
||||
|
@ -211,11 +210,11 @@ public class ContextMenuAdapter {
|
|||
}
|
||||
}
|
||||
@DrawableRes
|
||||
int secondaryLightDrawable = item.getSecondaryLightIcon();
|
||||
if (secondaryLightDrawable != -1) {
|
||||
int secondaryDrawable = item.getSecondaryIcon();
|
||||
if (secondaryDrawable != -1) {
|
||||
int color = ContextCompat.getColor(getContext(),
|
||||
holoLight ? R.color.icon_color : R.color.dashboard_subheader_text_dark);
|
||||
Drawable drawable = ContextCompat.getDrawable(getContext(), item.getSecondaryLightIcon());
|
||||
Drawable drawable = ContextCompat.getDrawable(getContext(), item.getSecondaryIcon());
|
||||
DrawableCompat.setTint(drawable, color);
|
||||
ImageView imageView = (ImageView) convertView.findViewById(R.id.secondary_icon);
|
||||
imageView.setImageDrawable(drawable);
|
||||
|
|
|
@ -18,7 +18,7 @@ public class ContextMenuItem {
|
|||
@DrawableRes
|
||||
private final int lightIcon;
|
||||
@DrawableRes
|
||||
private final int secondaryLightIcon;
|
||||
private final int secondaryIcon;
|
||||
private Boolean selected;
|
||||
private int progress;
|
||||
@LayoutRes
|
||||
|
@ -30,7 +30,7 @@ public class ContextMenuItem {
|
|||
private ContextMenuAdapter.OnContextMenuClick checkBoxListener;
|
||||
private ContextMenuAdapter.OnIntegerValueChangedListener integerListener;
|
||||
|
||||
private ContextMenuItem(int titleId, String title, int icon, int lightIcon, int secondaryLightIcon,
|
||||
private ContextMenuItem(int titleId, String title, int icon, int lightIcon, int secondaryIcon,
|
||||
Boolean selected, int progress, int layout, boolean loading, boolean category,
|
||||
int pos, String description, ContextMenuAdapter.OnContextMenuClick checkBoxListener,
|
||||
ContextMenuAdapter.OnIntegerValueChangedListener integerListener) {
|
||||
|
@ -38,7 +38,7 @@ public class ContextMenuItem {
|
|||
this.title = title;
|
||||
this.icon = icon;
|
||||
this.lightIcon = lightIcon;
|
||||
this.secondaryLightIcon = secondaryLightIcon;
|
||||
this.secondaryIcon = secondaryIcon;
|
||||
this.selected = selected;
|
||||
this.progress = progress;
|
||||
this.layout = layout;
|
||||
|
@ -66,8 +66,8 @@ public class ContextMenuItem {
|
|||
return lightIcon;
|
||||
}
|
||||
|
||||
public int getSecondaryLightIcon() {
|
||||
return secondaryLightIcon;
|
||||
public int getSecondaryIcon() {
|
||||
return secondaryIcon;
|
||||
}
|
||||
|
||||
public Boolean getSelected() {
|
||||
|
@ -143,7 +143,7 @@ public class ContextMenuItem {
|
|||
private String mTitle;
|
||||
private int mIcon = -1;
|
||||
private int mLightIcon = -1;
|
||||
private int mSecondaryLightIcon = -1;
|
||||
private int mSecondaryIcon = -1;
|
||||
private Boolean mSelected = null;
|
||||
private int mProgress = -1;
|
||||
private int mLayout = -1;
|
||||
|
@ -178,8 +178,8 @@ public class ContextMenuItem {
|
|||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder setSecondaryLightIcon(int secondaryLightIcon) {
|
||||
mSecondaryLightIcon = secondaryLightIcon;
|
||||
public ItemBuilder setSecondaryIcon(int secondaryIcon) {
|
||||
mSecondaryIcon = secondaryIcon;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -229,7 +229,7 @@ public class ContextMenuItem {
|
|||
}
|
||||
|
||||
public ContextMenuItem createItem() {
|
||||
return new ContextMenuItem(mTitleId, mTitle, mIcon, mLightIcon, mSecondaryLightIcon, mSelected, mProgress, mLayout, mLoading, mCat, mPos, mDescription, mCheckBoxListener, mIntegerListener);
|
||||
return new ContextMenuItem(mTitleId, mTitle, mIcon, mLightIcon, mSecondaryIcon, mSelected, mProgress, mLayout, mLoading, mCat, mPos, mDescription, mCheckBoxListener, mIntegerListener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -403,7 +403,7 @@ public class MapWidgetRegistry {
|
|||
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(r.messageId, map)
|
||||
.setSelected(r.visibleCollapsed(mode) || r.visible(mode))
|
||||
.setColorIcon(r.drawableMenu)
|
||||
.setSecondaryLightIcon(R.drawable.ic_action_additional_option)
|
||||
.setSecondaryIcon(R.drawable.ic_action_additional_option)
|
||||
.setListener(new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> a, int itemId, int pos, boolean isChecked) {
|
||||
|
|
Loading…
Reference in a new issue