Display marker date in groups

This commit is contained in:
PavelRatushnyi 2017-09-24 11:01:27 +03:00
parent b7ee350791
commit bcc8192cf6

View file

@ -212,10 +212,33 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
itemViewHolder.title.setText(marker.getName(app));
boolean noGroup = marker.groupName == null;
boolean early = false;
if (noGroup) {
Calendar currentDateCalendar = Calendar.getInstance();
currentDateCalendar.setTimeInMillis(System.currentTimeMillis());
int currentDay = currentDateCalendar.get(Calendar.DAY_OF_YEAR);
int currentYear = currentDateCalendar.get(Calendar.YEAR);
Calendar markerCalendar = Calendar.getInstance();
markerCalendar.setTimeInMillis(System.currentTimeMillis());
int markerDay = markerCalendar.get(Calendar.DAY_OF_YEAR);
int markerYear = markerCalendar.get(Calendar.YEAR);
early = currentDay - markerDay >= 2 || currentYear != markerYear;
}
if (markerInHistory) {
itemViewHolder.point.setVisibility(View.VISIBLE);
itemViewHolder.description.setVisibility(View.VISIBLE);
itemViewHolder.description.setText(app.getString(R.string.passed, new SimpleDateFormat("MMM dd", Locale.getDefault()).format(new Date(marker.visitedDate))));
} else if (noGroup && early) {
itemViewHolder.point.setVisibility(View.VISIBLE);
itemViewHolder.description.setVisibility(View.VISIBLE);
Date date = new Date(marker.creationDate);
String month = new SimpleDateFormat("MMM", Locale.getDefault()).format(date);
if (month.length() > 1) {
month = Character.toUpperCase(month.charAt(0)) + month.substring(1);
}
String day = new SimpleDateFormat("dd", Locale.getDefault()).format(date);
itemViewHolder.description.setText(month + " " + day);
} else {
itemViewHolder.point.setVisibility(View.GONE);
itemViewHolder.description.setVisibility(View.GONE);