Update TripRecordingActiveBottomSheet.java
This commit is contained in:
parent
3b0b49ae1b
commit
38ab4a14fd
1 changed files with 18 additions and 7 deletions
|
@ -49,6 +49,7 @@ import net.osmand.util.Algorithms;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
import static net.osmand.plus.UiUtilities.CompoundButtonType.PROFILE_DEPENDENT;
|
import static net.osmand.plus.UiUtilities.CompoundButtonType.PROFILE_DEPENDENT;
|
||||||
|
@ -102,6 +103,8 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
|
||||||
app = requiredMyApplication();
|
app = requiredMyApplication();
|
||||||
OsmandSettings settings = app.getSettings();
|
OsmandSettings settings = app.getSettings();
|
||||||
Context context = requireContext();
|
Context context = requireContext();
|
||||||
|
final FragmentManager fragmentManager = getFragmentManager();
|
||||||
|
final Fragment targetFragment = getTargetFragment();
|
||||||
|
|
||||||
LayoutInflater inflater = UiUtilities.getInflater(context, nightMode);
|
LayoutInflater inflater = UiUtilities.getInflater(context, nightMode);
|
||||||
View itemView = inflater.inflate(R.layout.trip_recording_active_fragment, null, false);
|
View itemView = inflater.inflate(R.layout.trip_recording_active_fragment, null, false);
|
||||||
|
@ -119,12 +122,14 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
|
||||||
);
|
);
|
||||||
statusIcon.setImageDrawable(statusDrawable);
|
statusIcon.setImageDrawable(statusDrawable);
|
||||||
|
|
||||||
String timeTrackSaved = String.valueOf(app.getSavingTrackHelper().getLastTimeUpdated());
|
long timeTrackSaved = app.getSavingTrackHelper().getLastTimeUpdated();
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("MMM dd,yyyy HH:mm");
|
SimpleDateFormat sdf = new SimpleDateFormat("dd MMM yyyy HH:mm:ss:SSS Z");
|
||||||
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
|
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||||
|
Date resultDate = new Date(timeTrackSaved);
|
||||||
|
String sdfFormatted = sdf.format(resultDate);
|
||||||
CharSequence formattedTimeTrackSaved = null;
|
CharSequence formattedTimeTrackSaved = null;
|
||||||
try {
|
try {
|
||||||
long time = sdf.parse(timeTrackSaved).getTime();
|
long time = sdf.parse(sdfFormatted).getTime();
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
formattedTimeTrackSaved =
|
formattedTimeTrackSaved =
|
||||||
DateUtils.getRelativeTimeSpanString(time, now, DateUtils.MINUTE_IN_MILLIS);
|
DateUtils.getRelativeTimeSpanString(time, now, DateUtils.MINUTE_IN_MILLIS);
|
||||||
|
@ -186,20 +191,26 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
final GPXUtilities.GPXFile gpxFile = app.getSavingTrackHelper().getCurrentTrack().getGpxFile();
|
final GPXUtilities.GPXFile gpxFile = app.getSavingTrackHelper().getCurrentTrack().getGpxFile();
|
||||||
new SaveCurrentTrackTask(app, gpxFile, saveGpxListener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
new SaveCurrentTrackTask(app, gpxFile, saveGpxListener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
buttonStop.setOnClickListener(new View.OnClickListener() {
|
buttonStop.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
FragmentManager fragmentManager = getFragmentManager();
|
if (fragmentManager != null) {
|
||||||
Fragment targetFragment = getTargetFragment();
|
|
||||||
if (fragmentManager != null && targetFragment != null) {
|
|
||||||
StopTrackRecordingBottomFragment.showInstance(fragmentManager, targetFragment);
|
StopTrackRecordingBottomFragment.showInstance(fragmentManager, targetFragment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
buttonClear.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (fragmentManager != null) {
|
||||||
|
ClearRecordedDataBottomSheetFragment.showInstance(fragmentManager, targetFragment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createButton(View view, ItemType type, boolean enabled, @Nullable String description) {
|
private void createButton(View view, ItemType type, boolean enabled, @Nullable String description) {
|
||||||
|
|
Loading…
Reference in a new issue