Fix ui for groups

This commit is contained in:
PavelRatushnyi 2017-09-20 13:13:20 +03:00
parent cbe5c3c20f
commit d212fc24d3
3 changed files with 23 additions and 8 deletions

View file

@ -6,7 +6,15 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants"> android:descendantFocusability="blocksDescendants">
<include layout="@layout/list_item_divider"/> <include android:id="@+id/top_shadow_divider"
layout="@layout/list_item_divider"/>
<View
android:id="@+id/top_divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:visibility="gone"
tools:visibility="visible"/>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"

View file

@ -10,6 +10,8 @@ import net.osmand.plus.R;
public class MapMarkerHeaderViewHolder extends RecyclerView.ViewHolder { public class MapMarkerHeaderViewHolder extends RecyclerView.ViewHolder {
final View topShadowDivider;
final View topDivider;
final ImageView icon; final ImageView icon;
final View iconSpace; final View iconSpace;
final TextView title; final TextView title;
@ -17,6 +19,8 @@ public class MapMarkerHeaderViewHolder extends RecyclerView.ViewHolder {
public MapMarkerHeaderViewHolder(View itemView) { public MapMarkerHeaderViewHolder(View itemView) {
super(itemView); super(itemView);
topShadowDivider = itemView.findViewById(R.id.top_shadow_divider);
topDivider = itemView.findViewById(R.id.top_divider);
icon = (ImageView) itemView.findViewById(R.id.icon); icon = (ImageView) itemView.findViewById(R.id.icon);
iconSpace = itemView.findViewById(R.id.icon_space); iconSpace = itemView.findViewById(R.id.icon_space);
title = (TextView) itemView.findViewById(R.id.title); title = (TextView) itemView.findViewById(R.id.title);

View file

@ -245,6 +245,9 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
} }
final boolean markerInHistory = marker.history; final boolean markerInHistory = marker.history;
String markerGroupName = marker.groupName;
boolean markerHasGroup = markerGroupName != null;
final MapMarkersGroup group = markerHasGroup ? getMapMarkerGroupByName(markerGroupName) : null;
itemViewHolder.optionsBtn.setImageDrawable(iconsCache.getThemedIcon(markerInHistory ? R.drawable.ic_action_reset_to_default_dark : R.drawable.ic_action_marker_passed)); itemViewHolder.optionsBtn.setImageDrawable(iconsCache.getThemedIcon(markerInHistory ? R.drawable.ic_action_reset_to_default_dark : R.drawable.ic_action_marker_passed));
itemViewHolder.optionsBtn.setOnClickListener(new View.OnClickListener() { itemViewHolder.optionsBtn.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -253,9 +256,6 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
if (position < 0) { if (position < 0) {
return; return;
} }
String markerGroupName = marker.groupName;
boolean markerHasGroup = markerGroupName != null;
MapMarkersGroup group = markerHasGroup ? getMapMarkerGroupByName(markerGroupName) : null;
if (markerInHistory) { if (markerInHistory) {
app.getMapMarkersHelper().restoreMarkerFromHistory(marker, 0); app.getMapMarkersHelper().restoreMarkerFromHistory(marker, 0);
if (group != null) { if (group != null) {
@ -300,13 +300,13 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
}); });
itemViewHolder.iconReorder.setVisibility(View.GONE); itemViewHolder.iconReorder.setVisibility(View.GONE);
itemViewHolder.flagIconLeftSpace.setVisibility(View.VISIBLE); itemViewHolder.flagIconLeftSpace.setVisibility(View.VISIBLE);
if (position == getItemCount() - 1) { boolean lastItem = position == getItemCount() - 1;
itemViewHolder.bottomShadow.setVisibility(View.VISIBLE); if ((getItemCount() > position + 1 && getItemViewType(position + 1) == HEADER_TYPE) || lastItem) {
itemViewHolder.divider.setVisibility(View.GONE); itemViewHolder.divider.setVisibility(View.GONE);
} else { } else {
itemViewHolder.bottomShadow.setVisibility(View.GONE);
itemViewHolder.divider.setVisibility(View.VISIBLE); itemViewHolder.divider.setVisibility(View.VISIBLE);
} }
itemViewHolder.bottomShadow.setVisibility(lastItem ? View.VISIBLE : View.GONE);
LatLon markerLatLon = new LatLon(marker.getLatitude(), marker.getLongitude()); LatLon markerLatLon = new LatLon(marker.getLatitude(), marker.getLongitude());
DashLocationFragment.updateLocationView(useCenter, location, DashLocationFragment.updateLocationView(useCenter, location,
@ -346,6 +346,8 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
throw new IllegalArgumentException("Unsupported header"); throw new IllegalArgumentException("Unsupported header");
} }
headerViewHolder.title.setText(headerString); headerViewHolder.title.setText(headerString);
headerViewHolder.topShadowDivider.setVisibility(View.GONE);
headerViewHolder.topDivider.setVisibility(View.VISIBLE);
} else if (holder instanceof MapMarkersShowHideHistoryViewHolder) { } else if (holder instanceof MapMarkersShowHideHistoryViewHolder) {
final MapMarkersShowHideHistoryViewHolder showHideHistoryViewHolder = (MapMarkersShowHideHistoryViewHolder) holder; final MapMarkersShowHideHistoryViewHolder showHideHistoryViewHolder = (MapMarkersShowHideHistoryViewHolder) holder;
final ShowHideHistoryButton showHideHistoryButton = (ShowHideHistoryButton) getItem(position); final ShowHideHistoryButton showHideHistoryButton = (ShowHideHistoryButton) getItem(position);
@ -401,7 +403,8 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
private MapMarkersGroup getMapMarkerGroupByName(String name) { private MapMarkersGroup getMapMarkerGroupByName(String name) {
for (MapMarkersGroup group : groups) { for (MapMarkersGroup group : groups) {
if (group.getName() != null && group.getName().equals(name)) { if ((name == null && group.getName() == null)
|| (group.getName() != null && group.getName().equals(name))) {
return group; return group;
} }
} }