Fix multi selection menu adapter

This commit is contained in:
PavelRatushny 2017-12-21 15:55:26 +02:00
parent f70a37e68a
commit c032e16218

View file

@ -38,9 +38,8 @@ public class MultiSelectionArrayAdapter extends ArrayAdapter<MapMultiSelectionMe
}
final MapMultiSelectionMenu.MenuObject item = getItem(position);
if (item != null) {
View contentView = convertView.findViewById(R.id.content);
AndroidUtils.setBackground(menu.getMapActivity(), contentView, !menu.isLight(), R.drawable.expandable_list_item_background_light, R.drawable.expandable_list_item_background_dark);
contentView.setOnClickListener(new View.OnClickListener() {
AndroidUtils.setBackground(menu.getMapActivity(), convertView, !menu.isLight(), R.drawable.expandable_list_item_background_light, R.drawable.expandable_list_item_background_dark);
convertView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (listener != null) {
@ -49,8 +48,8 @@ public class MultiSelectionArrayAdapter extends ArrayAdapter<MapMultiSelectionMe
}
});
IconsCache iconsCache = menu.getMapActivity().getMyApplication().getIconsCache();
final View iconLayout = contentView.findViewById(R.id.context_menu_icon_layout);
final ImageView iconView = (ImageView) contentView.findViewById(R.id.context_menu_icon_view);
final View iconLayout = convertView.findViewById(R.id.context_menu_icon_layout);
final ImageView iconView = (ImageView) convertView.findViewById(R.id.context_menu_icon_view);
Drawable icon = item.getLeftIcon();
int iconId = item.getLeftIconId();
if (icon != null) {
@ -65,13 +64,13 @@ public class MultiSelectionArrayAdapter extends ArrayAdapter<MapMultiSelectionMe
}
// Text line 1
TextView line1 = (TextView) contentView.findViewById(R.id.context_menu_line1);
((TextView) contentView.findViewById(R.id.context_menu_line1)).setTextColor(ContextCompat.getColor(getContext(),
TextView line1 = (TextView) convertView.findViewById(R.id.context_menu_line1);
((TextView) convertView.findViewById(R.id.context_menu_line1)).setTextColor(ContextCompat.getColor(getContext(),
!menu.isLight() ? R.color.ctx_menu_title_color_dark : R.color.ctx_menu_title_color_light));
line1.setText(item.getTitleStr());
// Text line 2
TextView line2 = (TextView) contentView.findViewById(R.id.context_menu_line2);
TextView line2 = (TextView) convertView.findViewById(R.id.context_menu_line2);
((TextView) line2).setTextColor(ContextCompat.getColor(getContext(), R.color.ctx_menu_subtitle_color));
line2.setText(item.getTypeStr());
Drawable slIcon = item.getTypeIcon();
@ -79,7 +78,7 @@ public class MultiSelectionArrayAdapter extends ArrayAdapter<MapMultiSelectionMe
line2.setCompoundDrawablePadding(AndroidUtils.dpToPx(menu.getMapActivity(), 5f));
// Divider
View divider = contentView.findViewById(R.id.divider);
View divider = convertView.findViewById(R.id.divider);
divider.setVisibility(position != getCount() - 1 ? View.VISIBLE : View.GONE);
}