Add possibility to remove marker
This commit is contained in:
parent
3c66c6e2e8
commit
305bef2719
1 changed files with 14 additions and 2 deletions
|
@ -60,8 +60,8 @@ public class CoordinateInputAdapter extends RecyclerView.Adapter<MapMarkerItemVi
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(MapMarkerItemViewHolder holder, int position) {
|
||||
MapMarker mapMarker = getItem(position);
|
||||
public void onBindViewHolder(final MapMarkerItemViewHolder holder, int position) {
|
||||
final MapMarker mapMarker = getItem(position);
|
||||
holder.iconDirection.setVisibility(View.VISIBLE);
|
||||
holder.icon.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_flag_dark, MapMarker.getColorId(mapMarker.colorIndex)));
|
||||
holder.mainLayout.setBackgroundColor(ContextCompat.getColor(mapActivity, nightTheme ? R.color.bg_color_dark : R.color.bg_color_light));
|
||||
|
@ -74,6 +74,18 @@ public class CoordinateInputAdapter extends RecyclerView.Adapter<MapMarkerItemVi
|
|||
holder.numberText.setText(Integer.toString(position + 1));
|
||||
holder.description.setVisibility(View.GONE);
|
||||
|
||||
holder.optionsBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
int position = holder.getAdapterPosition();
|
||||
if (position != RecyclerView.NO_POSITION) {
|
||||
MapMarker mapMarker = getItem(position);
|
||||
mapMarkers.remove(mapMarker);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
boolean fistItem = position == 0;
|
||||
boolean lastItem = position == getItemCount() - 1;
|
||||
holder.topDivider.setVisibility(fistItem ? View.VISIBLE : View.GONE);
|
||||
|
|
Loading…
Reference in a new issue