Remove unnecessary getters and setters

This commit is contained in:
Alexander Sytnyk 2018-03-21 12:34:56 +02:00
parent f91b5f58ef
commit 140a23457f
3 changed files with 22 additions and 79 deletions

View file

@ -133,12 +133,12 @@ public class MapMarkersHelper {
if (group == null) {
if (noGroup == null) {
noGroup = new MapMarkersGroup();
noGroup.setCreationDate(Long.MAX_VALUE);
noGroup.creationDate = Long.MAX_VALUE;
}
noGroup.getMarkers().add(marker);
} else {
if (marker.creationDate < group.getCreationDate()) {
group.setCreationDate(marker.creationDate);
if (marker.creationDate < group.creationDate) {
group.creationDate = marker.creationDate;
}
group.getMarkers().add(marker);
}
@ -363,7 +363,7 @@ public class MapMarkersHelper {
markersDbHelper.removeActiveMarkersFromGroup(group.getId());
removeFromMapMarkersList(group.getActiveMarkers());
if (updateGroup) {
group.setMarkers(group.getHistoryMarkers());
group.markers = group.getHistoryMarkers();
updateGroup(group);
}
reorderActiveMarkersIfNeeded();
@ -383,12 +383,12 @@ public class MapMarkersHelper {
ShowHideHistoryButton showHideHistoryButton = mapMarkersGroup.getShowHideHistoryButton();
if (showHideHistoryButton != null) {
if (historyMarkersCount == 0) {
mapMarkersGroup.setShowHideHistoryButton(null);
mapMarkersGroup.showHideHistoryButton = null;
}
} else if (historyMarkersCount > 0) {
showHideHistoryButton = new ShowHideHistoryButton();
showHideHistoryButton.setShowHistory(false);
mapMarkersGroup.setShowHideHistoryButton(showHideHistoryButton);
showHideHistoryButton.showHistory = false;
mapMarkersGroup.showHideHistoryButton = showHideHistoryButton;
}
}
@ -409,9 +409,9 @@ public class MapMarkersHelper {
}
} else {
mapMarkersGroup = new MapMarkersGroup();
mapMarkersGroup.setId(marker.groupKey);
mapMarkersGroup.setName(marker.groupName);
mapMarkersGroup.setCreationDate(Long.MAX_VALUE);
mapMarkersGroup.id = marker.groupKey;
mapMarkersGroup.name = marker.groupName;
mapMarkersGroup.creationDate = Long.MAX_VALUE;
mapMarkersGroup.getMarkers().add(marker);
addToGroupsList(mapMarkersGroup);
sortGroups();
@ -425,11 +425,11 @@ public class MapMarkersHelper {
GroupHeader header = new GroupHeader();
int type = group.getType();
if (type != -1) {
header.setIconRes(type == MapMarkersGroup.FAVORITES_TYPE
? R.drawable.ic_action_fav_dark : R.drawable.ic_action_polygom_dark);
header.iconRes = type == MapMarkersGroup.FAVORITES_TYPE
? R.drawable.ic_action_fav_dark : R.drawable.ic_action_polygom_dark;
}
header.setGroup(group);
group.setGroupHeader(header);
header.group = group;
group.header = header;
}
}
@ -448,8 +448,8 @@ public class MapMarkersHelper {
Collections.sort(mapMarkersGroups, new Comparator<MapMarkersGroup>() {
@Override
public int compare(MapMarkersGroup group1, MapMarkersGroup group2) {
long t1 = group1.getCreationDate();
long t2 = group2.getCreationDate();
long t1 = group1.creationDate;
long t2 = group2.creationDate;
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) {
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.name = name;
this.type = type;
this.wptCategories = wptCategories;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public void setWptCategories(Set<String> wptCategories) {
this.wptCategories = wptCategories;
}
public long getCreationDate() {
return creationDate;
}
public void setCreationDate(long creationDate) {
this.creationDate = creationDate;
}
public boolean isDisabled() {
return disabled;
}
@ -1193,26 +1164,14 @@ public class MapMarkersHelper {
return markers;
}
public void setMarkers(List<MapMarker> markers) {
this.markers = markers;
}
public GroupHeader getGroupHeader() {
return header;
}
public void setGroupHeader(GroupHeader header) {
this.header = header;
}
public ShowHideHistoryButton getShowHideHistoryButton() {
return showHideHistoryButton;
}
public void setShowHideHistoryButton(ShowHideHistoryButton showHideHistoryButton) {
this.showHideHistoryButton = showHideHistoryButton;
}
@Nullable
public String getWptCategoriesString() {
if (wptCategories != null) {
@ -1244,15 +1203,7 @@ public class MapMarkersHelper {
}
public static class ShowHideHistoryButton {
private boolean showHistory;
public boolean isShowHistory() {
return showHistory;
}
public void setShowHistory(boolean showHistory) {
this.showHistory = showHistory;
}
public boolean showHistory;
}
public static class GroupHeader {
@ -1263,17 +1214,9 @@ public class MapMarkersHelper {
return iconRes;
}
public void setIconRes(int iconRes) {
this.iconRes = iconRes;
}
public MapMarkersGroup getGroup() {
return group;
}
public void setGroup(MapMarkersGroup group) {
this.group = group;
}
}
public static class MapMarker implements LocationPoint {

View file

@ -233,9 +233,9 @@ public class MapMarkersDbHelper {
boolean disabled = query.getInt(3) == 1;
String categories = query.getString(4);
MapMarkersGroup res = new MapMarkersGroup(id, name, type,
categories == null ? null : Algorithms.decodeStringSet(categories));
MapMarkersGroup res = new MapMarkersGroup(id, name, type);
res.setDisabled(disabled);
res.setWptCategories(categories == null ? null : Algorithms.decodeStringSet(categories));
return res;
}

View file

@ -147,7 +147,7 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
ShowHideHistoryButton showHideHistoryButton = group.getShowHideHistoryButton();
if (!group.isDisabled()) {
List<Object> objectsToAdd = new ArrayList<>();
if (showHideHistoryButton != null && showHideHistoryButton.isShowHistory()) {
if (showHideHistoryButton != null && showHideHistoryButton.showHistory) {
objectsToAdd.addAll(group.getMarkers());
} else {
objectsToAdd.addAll(group.getActiveMarkers());
@ -424,7 +424,7 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
} else if (holder instanceof MapMarkersShowHideHistoryViewHolder) {
final MapMarkersShowHideHistoryViewHolder showHideHistoryViewHolder = (MapMarkersShowHideHistoryViewHolder) holder;
final ShowHideHistoryButton showHideHistoryButton = (ShowHideHistoryButton) getItem(position);
final boolean showHistory = showHideHistoryButton.isShowHistory();
final boolean showHistory = showHideHistoryButton.showHistory;
if (position == getItemCount() - 1) {
showHideHistoryViewHolder.bottomShadow.setVisibility(View.VISIBLE);
} else {
@ -434,7 +434,7 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
showHideHistoryViewHolder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showHideHistoryButton.setShowHistory(!showHistory);
showHideHistoryButton.showHistory = !showHistory;
createDisplayGroups();
notifyDataSetChanged();
}