Remove unnecessary variable

This commit is contained in:
PavelRatushny 2017-12-21 15:42:22 +02:00
parent 2ba6c849ba
commit f70a37e68a

View file

@ -33,15 +33,14 @@ public class MultiSelectionArrayAdapter extends ArrayAdapter<MapMultiSelectionMe
@NonNull
@Override
public View getView(final int position, @Nullable View convertView, @NonNull ViewGroup parent) {
View v = convertView;
if (v == null) {
v = menu.getMapActivity().getLayoutInflater().inflate(R.layout.menu_obj_list_item, parent, false);
if (convertView == null) {
convertView = menu.getMapActivity().getLayoutInflater().inflate(R.layout.menu_obj_list_item, parent, false);
}
final MapMultiSelectionMenu.MenuObject item = getItem(position);
if (item != null) {
View contentView = v.findViewById(R.id.content);
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);
v.setOnClickListener(new View.OnClickListener() {
contentView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (listener != null) {
@ -50,8 +49,8 @@ public class MultiSelectionArrayAdapter extends ArrayAdapter<MapMultiSelectionMe
}
});
IconsCache iconsCache = menu.getMapActivity().getMyApplication().getIconsCache();
final View iconLayout = v.findViewById(R.id.context_menu_icon_layout);
final ImageView iconView = (ImageView) v.findViewById(R.id.context_menu_icon_view);
final View iconLayout = contentView.findViewById(R.id.context_menu_icon_layout);
final ImageView iconView = (ImageView) contentView.findViewById(R.id.context_menu_icon_view);
Drawable icon = item.getLeftIcon();
int iconId = item.getLeftIconId();
if (icon != null) {
@ -66,13 +65,13 @@ public class MultiSelectionArrayAdapter extends ArrayAdapter<MapMultiSelectionMe
}
// Text line 1
TextView line1 = (TextView) v.findViewById(R.id.context_menu_line1);
((TextView) v.findViewById(R.id.context_menu_line1)).setTextColor(ContextCompat.getColor(getContext(),
TextView line1 = (TextView) contentView.findViewById(R.id.context_menu_line1);
((TextView) contentView.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) v.findViewById(R.id.context_menu_line2);
TextView line2 = (TextView) contentView.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();
@ -80,11 +79,11 @@ public class MultiSelectionArrayAdapter extends ArrayAdapter<MapMultiSelectionMe
line2.setCompoundDrawablePadding(AndroidUtils.dpToPx(menu.getMapActivity(), 5f));
// Divider
View divider = v.findViewById(R.id.divider);
View divider = contentView.findViewById(R.id.divider);
divider.setVisibility(position != getCount() - 1 ? View.VISIBLE : View.GONE);
}
return v;
return convertView;
}
public interface OnClickListener {