Add disabling groups
This commit is contained in:
parent
d2cb331beb
commit
a5e0a5120e
2 changed files with 34 additions and 51 deletions
|
@ -873,19 +873,12 @@ public class MapMarkersHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createHeaderAndHistoryButtonInGroup(MapMarkersGroup group) {
|
private void createHeaderAndHistoryButtonInGroup(MapMarkersGroup group) {
|
||||||
String markerGroupName = group.getName();
|
|
||||||
if (markerGroupName.equals("")) {
|
|
||||||
markerGroupName = ctx.getString(R.string.shared_string_favorites);
|
|
||||||
}
|
|
||||||
GroupHeader header = new GroupHeader();
|
GroupHeader header = new GroupHeader();
|
||||||
header.setGroupName(markerGroupName);
|
|
||||||
int type = group.getType();
|
int type = group.getType();
|
||||||
if (type != -1) {
|
if (type != -1) {
|
||||||
header.setIconRes(type == MapMarkersHelper.MarkersSyncGroup.FAVORITES_TYPE ? R.drawable.ic_action_fav_dark : R.drawable.ic_action_track_16);
|
header.setIconRes(type == MapMarkersHelper.MarkersSyncGroup.FAVORITES_TYPE ? R.drawable.ic_action_fav_dark : R.drawable.ic_action_track_16);
|
||||||
}
|
}
|
||||||
header.setActiveMarkersCount(group.getActiveMarkers().size());
|
header.setGroup(group);
|
||||||
header.setMarkersCount(group.getMarkers().size());
|
|
||||||
header.setColor(group.getColor());
|
|
||||||
group.setGroupHeader(header);
|
group.setGroupHeader(header);
|
||||||
updateShowHideHistoryButtonInGroup(group);
|
updateShowHideHistoryButtonInGroup(group);
|
||||||
}
|
}
|
||||||
|
@ -981,6 +974,7 @@ public class MapMarkersHelper {
|
||||||
private long creationDate;
|
private long creationDate;
|
||||||
private ShowHideHistoryButton showHideHistoryButton;
|
private ShowHideHistoryButton showHideHistoryButton;
|
||||||
private int color;
|
private int color;
|
||||||
|
private boolean disabled;
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
|
@ -1057,6 +1051,14 @@ public class MapMarkersHelper {
|
||||||
public void setColor(int color) {
|
public void setColor(int color) {
|
||||||
this.color = color;
|
this.color = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isDisabled() {
|
||||||
|
return disabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDisabled(boolean disabled) {
|
||||||
|
this.disabled = disabled;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ShowHideHistoryButton {
|
public static class ShowHideHistoryButton {
|
||||||
|
@ -1081,35 +1083,8 @@ public class MapMarkersHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class GroupHeader {
|
public static class GroupHeader {
|
||||||
private String groupName;
|
|
||||||
private int activeMarkersCount;
|
|
||||||
private int markersCount;
|
|
||||||
private int iconRes;
|
private int iconRes;
|
||||||
private int color;
|
private MapMarkersGroup group;
|
||||||
|
|
||||||
public String getGroupName() {
|
|
||||||
return groupName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setGroupName(String groupName) {
|
|
||||||
this.groupName = groupName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getActiveMarkersCount() {
|
|
||||||
return activeMarkersCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setActiveMarkersCount(int activeMarkersCount) {
|
|
||||||
this.activeMarkersCount = activeMarkersCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMarkersCount() {
|
|
||||||
return markersCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMarkersCount(int markersCount) {
|
|
||||||
this.markersCount = markersCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getIconRes() {
|
public int getIconRes() {
|
||||||
return iconRes;
|
return iconRes;
|
||||||
|
@ -1119,12 +1094,12 @@ public class MapMarkersHelper {
|
||||||
this.iconRes = iconRes;
|
this.iconRes = iconRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getColor() {
|
public MapMarkersGroup getGroup() {
|
||||||
return color;
|
return group;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setColor(int color) {
|
public void setGroup(MapMarkersGroup group) {
|
||||||
this.color = color;
|
this.group = group;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.CompoundButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
|
@ -249,13 +250,6 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (group != null) {
|
|
||||||
GroupHeader header = group.getGroupHeader();
|
|
||||||
if (header != null) {
|
|
||||||
header.setActiveMarkersCount(group.getActiveMarkers().size());
|
|
||||||
header.setMarkersCount(group.getMarkers().size());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
updateShowDirectionMarkers();
|
updateShowDirectionMarkers();
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
@ -296,14 +290,28 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
|
||||||
} else {
|
} else {
|
||||||
headerString = String.valueOf(dateHeader);
|
headerString = String.valueOf(dateHeader);
|
||||||
}
|
}
|
||||||
|
headerViewHolder.disableGroupSwitch.setVisibility(View.GONE);
|
||||||
} else if (header instanceof GroupHeader) {
|
} else if (header instanceof GroupHeader) {
|
||||||
GroupHeader groupHeader = (GroupHeader) header;
|
final GroupHeader groupHeader = (GroupHeader) header;
|
||||||
headerString = groupHeader.getGroupName() + " \u2014 "
|
String groupName = groupHeader.getGroup().getName();
|
||||||
+ groupHeader.getActiveMarkersCount()
|
if (groupName.equals("")) {
|
||||||
+ "/" + (groupHeader.getMarkersCount());
|
groupName = app.getString(R.string.shared_string_favorites);
|
||||||
|
}
|
||||||
|
headerString = groupName + " \u2014 "
|
||||||
|
+ groupHeader.getGroup().getActiveMarkers().size()
|
||||||
|
+ "/" + groupHeader.getGroup().getMarkers().size();
|
||||||
headerViewHolder.icon.setVisibility(View.VISIBLE);
|
headerViewHolder.icon.setVisibility(View.VISIBLE);
|
||||||
headerViewHolder.iconSpace.setVisibility(View.GONE);
|
headerViewHolder.iconSpace.setVisibility(View.GONE);
|
||||||
headerViewHolder.icon.setImageDrawable(iconsCache.getIcon(groupHeader.getIconRes(), R.color.divider_color));
|
headerViewHolder.icon.setImageDrawable(iconsCache.getIcon(groupHeader.getIconRes(), R.color.divider_color));
|
||||||
|
boolean groupIsDisabled = groupHeader.getGroup().isDisabled();
|
||||||
|
headerViewHolder.disableGroupSwitch.setChecked(!groupIsDisabled);
|
||||||
|
headerViewHolder.disableGroupSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
||||||
|
groupHeader.getGroup().setDisabled(!b);
|
||||||
|
notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("Unsupported header");
|
throw new IllegalArgumentException("Unsupported header");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue