remove unnecessary changes

This commit is contained in:
Vitaliy 2020-06-19 19:45:40 +03:00
parent a348dc36cc
commit 1cb985e3f2
2 changed files with 9 additions and 14 deletions

View file

@ -478,17 +478,7 @@ public class OsmAndFormatter {
return newStrings;
}
public static boolean isSameDay(long startTime, long endTime) {
Calendar start = Calendar.getInstance();
Calendar end = Calendar.getInstance();
start.setTimeInMillis(startTime);
end.setTimeInMillis(endTime);
return isSameDay(start, end);
}
public static boolean isSameDay(Calendar cal1, Calendar cal2) {
private static boolean isSameDay(Calendar cal1, Calendar cal2) {
return (cal1.get(Calendar.ERA) == cal2.get(Calendar.ERA) &&
cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) &&
cal1.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR));

View file

@ -23,8 +23,11 @@ import net.osmand.plus.mapcontextmenu.MenuBuilder;
import net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint;
import net.osmand.util.Algorithms;
import org.apache.commons.lang3.time.DateUtils;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
public class SelectedGpxMenuBuilder extends MenuBuilder {
@ -72,16 +75,18 @@ public class SelectedGpxMenuBuilder extends MenuBuilder {
timeSpan + " / " + timeMoving, 0, null,
false, null, false, 0, false, false, false, null, false);
Date start = new Date(analysis.startTime);
Date end = new Date(analysis.endTime);
DateFormat startFormat = SimpleDateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
DateFormat endFormat;
if (OsmAndFormatter.isSameDay(analysis.startTime, analysis.endTime)) {
if (DateUtils.isSameDay(start, end)) {
endFormat = SimpleDateFormat.getTimeInstance(DateFormat.SHORT);
} else {
endFormat = SimpleDateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT)
endFormat = SimpleDateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
}
String startEndTimeTitle = app.getString(R.string.shared_string_start_time) + " - " + app.getString(R.string.shared_string_end_time);
buildRow(view, getThemedIcon(R.drawable.ic_action_time_start), null, startEndTimeTitle,
startFormat.format(analysis.startTime) + " - " + endFormat.format(analysis.endTime), 0, null,
startFormat.format(start) + " - " + endFormat.format(end), 0, null,
false, null, false, 0, false, false, false, null, true);
}