Remove unnecessary getters and setters
This commit is contained in:
parent
f91b5f58ef
commit
140a23457f
3 changed files with 22 additions and 79 deletions
|
@ -133,12 +133,12 @@ public class MapMarkersHelper {
|
||||||
if (group == null) {
|
if (group == null) {
|
||||||
if (noGroup == null) {
|
if (noGroup == null) {
|
||||||
noGroup = new MapMarkersGroup();
|
noGroup = new MapMarkersGroup();
|
||||||
noGroup.setCreationDate(Long.MAX_VALUE);
|
noGroup.creationDate = Long.MAX_VALUE;
|
||||||
}
|
}
|
||||||
noGroup.getMarkers().add(marker);
|
noGroup.getMarkers().add(marker);
|
||||||
} else {
|
} else {
|
||||||
if (marker.creationDate < group.getCreationDate()) {
|
if (marker.creationDate < group.creationDate) {
|
||||||
group.setCreationDate(marker.creationDate);
|
group.creationDate = marker.creationDate;
|
||||||
}
|
}
|
||||||
group.getMarkers().add(marker);
|
group.getMarkers().add(marker);
|
||||||
}
|
}
|
||||||
|
@ -363,7 +363,7 @@ public class MapMarkersHelper {
|
||||||
markersDbHelper.removeActiveMarkersFromGroup(group.getId());
|
markersDbHelper.removeActiveMarkersFromGroup(group.getId());
|
||||||
removeFromMapMarkersList(group.getActiveMarkers());
|
removeFromMapMarkersList(group.getActiveMarkers());
|
||||||
if (updateGroup) {
|
if (updateGroup) {
|
||||||
group.setMarkers(group.getHistoryMarkers());
|
group.markers = group.getHistoryMarkers();
|
||||||
updateGroup(group);
|
updateGroup(group);
|
||||||
}
|
}
|
||||||
reorderActiveMarkersIfNeeded();
|
reorderActiveMarkersIfNeeded();
|
||||||
|
@ -383,12 +383,12 @@ public class MapMarkersHelper {
|
||||||
ShowHideHistoryButton showHideHistoryButton = mapMarkersGroup.getShowHideHistoryButton();
|
ShowHideHistoryButton showHideHistoryButton = mapMarkersGroup.getShowHideHistoryButton();
|
||||||
if (showHideHistoryButton != null) {
|
if (showHideHistoryButton != null) {
|
||||||
if (historyMarkersCount == 0) {
|
if (historyMarkersCount == 0) {
|
||||||
mapMarkersGroup.setShowHideHistoryButton(null);
|
mapMarkersGroup.showHideHistoryButton = null;
|
||||||
}
|
}
|
||||||
} else if (historyMarkersCount > 0) {
|
} else if (historyMarkersCount > 0) {
|
||||||
showHideHistoryButton = new ShowHideHistoryButton();
|
showHideHistoryButton = new ShowHideHistoryButton();
|
||||||
showHideHistoryButton.setShowHistory(false);
|
showHideHistoryButton.showHistory = false;
|
||||||
mapMarkersGroup.setShowHideHistoryButton(showHideHistoryButton);
|
mapMarkersGroup.showHideHistoryButton = showHideHistoryButton;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -409,9 +409,9 @@ public class MapMarkersHelper {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mapMarkersGroup = new MapMarkersGroup();
|
mapMarkersGroup = new MapMarkersGroup();
|
||||||
mapMarkersGroup.setId(marker.groupKey);
|
mapMarkersGroup.id = marker.groupKey;
|
||||||
mapMarkersGroup.setName(marker.groupName);
|
mapMarkersGroup.name = marker.groupName;
|
||||||
mapMarkersGroup.setCreationDate(Long.MAX_VALUE);
|
mapMarkersGroup.creationDate = Long.MAX_VALUE;
|
||||||
mapMarkersGroup.getMarkers().add(marker);
|
mapMarkersGroup.getMarkers().add(marker);
|
||||||
addToGroupsList(mapMarkersGroup);
|
addToGroupsList(mapMarkersGroup);
|
||||||
sortGroups();
|
sortGroups();
|
||||||
|
@ -425,11 +425,11 @@ public class MapMarkersHelper {
|
||||||
GroupHeader header = new GroupHeader();
|
GroupHeader header = new GroupHeader();
|
||||||
int type = group.getType();
|
int type = group.getType();
|
||||||
if (type != -1) {
|
if (type != -1) {
|
||||||
header.setIconRes(type == MapMarkersGroup.FAVORITES_TYPE
|
header.iconRes = type == MapMarkersGroup.FAVORITES_TYPE
|
||||||
? R.drawable.ic_action_fav_dark : R.drawable.ic_action_polygom_dark);
|
? R.drawable.ic_action_fav_dark : R.drawable.ic_action_polygom_dark;
|
||||||
}
|
}
|
||||||
header.setGroup(group);
|
header.group = group;
|
||||||
group.setGroupHeader(header);
|
group.header = header;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -448,8 +448,8 @@ public class MapMarkersHelper {
|
||||||
Collections.sort(mapMarkersGroups, new Comparator<MapMarkersGroup>() {
|
Collections.sort(mapMarkersGroups, new Comparator<MapMarkersGroup>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(MapMarkersGroup group1, MapMarkersGroup group2) {
|
public int compare(MapMarkersGroup group1, MapMarkersGroup group2) {
|
||||||
long t1 = group1.getCreationDate();
|
long t1 = group1.creationDate;
|
||||||
long t2 = group2.getCreationDate();
|
long t2 = group2.creationDate;
|
||||||
return (t1 > t2) ? -1 : ((t1 == t2) ? 0 : 1);
|
return (t1 > t2) ? -1 : ((t1 == t2) ? 0 : 1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1131,56 +1131,27 @@ public class MapMarkersHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapMarkersGroup(@NonNull String id, @NonNull String name, int type) {
|
public MapMarkersGroup(@NonNull String id, @NonNull String name, int type) {
|
||||||
init(id, name, type, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MapMarkersGroup(@NonNull String id, @NonNull String name, int type, @Nullable Set<String> wptCategories) {
|
|
||||||
init(id, name, type, wptCategories);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void init(String id, String name, int type, Set<String> wptCategories) {
|
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.wptCategories = wptCategories;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(String id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getType() {
|
public int getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(int type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWptCategories(Set<String> wptCategories) {
|
public void setWptCategories(Set<String> wptCategories) {
|
||||||
this.wptCategories = wptCategories;
|
this.wptCategories = wptCategories;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getCreationDate() {
|
|
||||||
return creationDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreationDate(long creationDate) {
|
|
||||||
this.creationDate = creationDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isDisabled() {
|
public boolean isDisabled() {
|
||||||
return disabled;
|
return disabled;
|
||||||
}
|
}
|
||||||
|
@ -1193,26 +1164,14 @@ public class MapMarkersHelper {
|
||||||
return markers;
|
return markers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMarkers(List<MapMarker> markers) {
|
|
||||||
this.markers = markers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GroupHeader getGroupHeader() {
|
public GroupHeader getGroupHeader() {
|
||||||
return header;
|
return header;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGroupHeader(GroupHeader header) {
|
|
||||||
this.header = header;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ShowHideHistoryButton getShowHideHistoryButton() {
|
public ShowHideHistoryButton getShowHideHistoryButton() {
|
||||||
return showHideHistoryButton;
|
return showHideHistoryButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setShowHideHistoryButton(ShowHideHistoryButton showHideHistoryButton) {
|
|
||||||
this.showHideHistoryButton = showHideHistoryButton;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public String getWptCategoriesString() {
|
public String getWptCategoriesString() {
|
||||||
if (wptCategories != null) {
|
if (wptCategories != null) {
|
||||||
|
@ -1244,15 +1203,7 @@ public class MapMarkersHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ShowHideHistoryButton {
|
public static class ShowHideHistoryButton {
|
||||||
private boolean showHistory;
|
public boolean showHistory;
|
||||||
|
|
||||||
public boolean isShowHistory() {
|
|
||||||
return showHistory;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setShowHistory(boolean showHistory) {
|
|
||||||
this.showHistory = showHistory;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class GroupHeader {
|
public static class GroupHeader {
|
||||||
|
@ -1263,17 +1214,9 @@ public class MapMarkersHelper {
|
||||||
return iconRes;
|
return iconRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIconRes(int iconRes) {
|
|
||||||
this.iconRes = iconRes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MapMarkersGroup getGroup() {
|
public MapMarkersGroup getGroup() {
|
||||||
return group;
|
return group;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGroup(MapMarkersGroup group) {
|
|
||||||
this.group = group;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class MapMarker implements LocationPoint {
|
public static class MapMarker implements LocationPoint {
|
||||||
|
|
|
@ -233,9 +233,9 @@ public class MapMarkersDbHelper {
|
||||||
boolean disabled = query.getInt(3) == 1;
|
boolean disabled = query.getInt(3) == 1;
|
||||||
String categories = query.getString(4);
|
String categories = query.getString(4);
|
||||||
|
|
||||||
MapMarkersGroup res = new MapMarkersGroup(id, name, type,
|
MapMarkersGroup res = new MapMarkersGroup(id, name, type);
|
||||||
categories == null ? null : Algorithms.decodeStringSet(categories));
|
|
||||||
res.setDisabled(disabled);
|
res.setDisabled(disabled);
|
||||||
|
res.setWptCategories(categories == null ? null : Algorithms.decodeStringSet(categories));
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,7 +147,7 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
|
||||||
ShowHideHistoryButton showHideHistoryButton = group.getShowHideHistoryButton();
|
ShowHideHistoryButton showHideHistoryButton = group.getShowHideHistoryButton();
|
||||||
if (!group.isDisabled()) {
|
if (!group.isDisabled()) {
|
||||||
List<Object> objectsToAdd = new ArrayList<>();
|
List<Object> objectsToAdd = new ArrayList<>();
|
||||||
if (showHideHistoryButton != null && showHideHistoryButton.isShowHistory()) {
|
if (showHideHistoryButton != null && showHideHistoryButton.showHistory) {
|
||||||
objectsToAdd.addAll(group.getMarkers());
|
objectsToAdd.addAll(group.getMarkers());
|
||||||
} else {
|
} else {
|
||||||
objectsToAdd.addAll(group.getActiveMarkers());
|
objectsToAdd.addAll(group.getActiveMarkers());
|
||||||
|
@ -424,7 +424,7 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
|
||||||
} 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);
|
||||||
final boolean showHistory = showHideHistoryButton.isShowHistory();
|
final boolean showHistory = showHideHistoryButton.showHistory;
|
||||||
if (position == getItemCount() - 1) {
|
if (position == getItemCount() - 1) {
|
||||||
showHideHistoryViewHolder.bottomShadow.setVisibility(View.VISIBLE);
|
showHideHistoryViewHolder.bottomShadow.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
|
@ -434,7 +434,7 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
|
||||||
showHideHistoryViewHolder.itemView.setOnClickListener(new View.OnClickListener() {
|
showHideHistoryViewHolder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
showHideHistoryButton.setShowHistory(!showHistory);
|
showHideHistoryButton.showHistory = !showHistory;
|
||||||
createDisplayGroups();
|
createDisplayGroups();
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue