mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 21:03:54 +01:00
Change item background according to the theme (#3480)
* Change item background according to the theme * Change background colour of item on being selected * Change background colors using XML selectors
This commit is contained in:
parent
81c7281d3a
commit
34a016d49d
5 changed files with 28 additions and 10 deletions
|
|
@ -70,7 +70,7 @@ public class NearbyFilterSearchRecyclerViewAdapter
|
|||
@NonNull
|
||||
@Override
|
||||
public RecyclerViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View itemView = inflater.inflate(callback.isDarkTheme()?R.layout.nearby_search_list_item_dark:R.layout.nearby_search_list_item, parent, false);
|
||||
View itemView = inflater.inflate(callback.isDarkTheme() ? R.layout.nearby_search_list_item_dark : R.layout.nearby_search_list_item, parent, false);
|
||||
return new RecyclerViewHolder(itemView);
|
||||
}
|
||||
|
||||
|
|
@ -79,17 +79,20 @@ public class NearbyFilterSearchRecyclerViewAdapter
|
|||
Label label = displayedLabels.get(position);
|
||||
holder.placeTypeIcon.setImageResource(label.getIcon());
|
||||
holder.placeTypeLabel.setText(label.toString());
|
||||
holder.placeTypeLayout.setSelected(label.isSelected());
|
||||
|
||||
holder.placeTypeLayout.setBackgroundColor(label.isSelected() ? ContextCompat.getColor(context, R.color.divider_grey) : callback.isDarkTheme()?Color.BLACK:Color.WHITE);
|
||||
holder.placeTypeLayout.setOnClickListener(view -> {
|
||||
callback.setCheckboxUnknown();
|
||||
|
||||
if (label.isSelected()) {
|
||||
selectedLabels.remove(label);
|
||||
} else {
|
||||
selectedLabels.add(label);
|
||||
}
|
||||
|
||||
label.setSelected(!label.isSelected());
|
||||
holder.placeTypeLayout.setBackgroundColor(label.isSelected() ? ContextCompat.getColor(context, R.color.divider_grey) : Color.WHITE);
|
||||
holder.placeTypeLayout.setSelected(label.isSelected());
|
||||
|
||||
callback.filterByMarkerType(selectedLabels, 0, false, false);
|
||||
});
|
||||
}
|
||||
|
|
@ -165,7 +168,7 @@ public class NearbyFilterSearchRecyclerViewAdapter
|
|||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public interface Callback{
|
||||
public interface Callback {
|
||||
|
||||
void setCheckboxUnknown();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue