Fix live statistics not disappearing when track cleared.
This commit is contained in:
parent
ac5c3c2dd5
commit
b01a900fd3
2 changed files with 39 additions and 21 deletions
|
@ -90,11 +90,20 @@ class MapFragment : Fragment(), YesNoDialog.YesNoDialogListener, MapOverlayHelpe
|
||||||
saveTrack()
|
saveTrack()
|
||||||
}
|
}
|
||||||
layout.clearButton.setOnClickListener {
|
layout.clearButton.setOnClickListener {
|
||||||
if (track.wayPoints.isNotEmpty()) {
|
if (track.wayPoints.isEmpty())
|
||||||
YesNoDialog(this as YesNoDialog.YesNoDialogListener).show(context = activity as Context, type = Keys.DIALOG_DELETE_CURRENT_RECORDING, message = R.string.dialog_delete_current_recording_message, yesButton = R.string.dialog_delete_current_recording_button_discard)
|
{
|
||||||
} else {
|
// This might seem useless since it's already empty, but there are other UI updates
|
||||||
|
// that occur as part of cleartrack so we may as well take advantage of those.
|
||||||
trackerService.clearTrack()
|
trackerService.clearTrack()
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
YesNoDialog(this as YesNoDialog.YesNoDialogListener).show(
|
||||||
|
context=activity as Context,
|
||||||
|
type = Keys.DIALOG_DELETE_CURRENT_RECORDING,
|
||||||
|
message = R.string.dialog_delete_current_recording_message,
|
||||||
|
yesButton = R.string.dialog_delete_current_recording_button_discard
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return layout.rootView
|
return layout.rootView
|
||||||
|
|
|
@ -201,30 +201,39 @@ data class MapFragmentLayoutHolder(private var context: Context, private var mar
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Update live statics */
|
/* Update live statics */
|
||||||
fun updateLiveStatics(distance: Float, duration: Long, trackingState: Int) {
|
fun updateLiveStatics(distance: Float, duration: Long, trackingState: Int) {
|
||||||
// toggle visibility
|
// toggle visibility
|
||||||
val trackingActive: Boolean = trackingState != Keys.STATE_TRACKING_NOT_STARTED
|
if (trackingState == Keys.STATE_TRACKING_NOT_STARTED)
|
||||||
liveStatisticsDistanceView.isVisible = trackingActive
|
{
|
||||||
liveStatisticsDurationView.isVisible = trackingActive
|
liveStatisticsDistanceView.isGone = true
|
||||||
// update distance and duration (and add outline)
|
liveStatisticsDurationView.isGone = true
|
||||||
val distanceString: String = LengthUnitHelper.convertDistanceToString(distance, useImperial)
|
liveStatisticsDistanceOutlineView.isGone = true
|
||||||
liveStatisticsDistanceView.text = distanceString
|
liveStatisticsDurationOutlineView.isGone = true
|
||||||
liveStatisticsDistanceOutlineView.text = distanceString
|
}
|
||||||
liveStatisticsDistanceOutlineView.paint.strokeWidth = 5f
|
else
|
||||||
liveStatisticsDistanceOutlineView.paint.style = Paint.Style.STROKE
|
{
|
||||||
val durationString: String = DateTimeHelper.convertToReadableTime(context, duration, compactFormat = true)
|
liveStatisticsDistanceView.isVisible = true
|
||||||
liveStatisticsDurationView.text = durationString
|
liveStatisticsDurationView.isVisible = true
|
||||||
liveStatisticsDurationOutlineView.text = durationString
|
liveStatisticsDistanceOutlineView.isVisible = true
|
||||||
liveStatisticsDurationOutlineView.paint.strokeWidth = 5f
|
liveStatisticsDurationOutlineView.isVisible = true
|
||||||
liveStatisticsDurationOutlineView.paint.style = Paint.Style.STROKE
|
// update distance and duration (and add outline)
|
||||||
|
val distanceString: String = LengthUnitHelper.convertDistanceToString(distance, useImperial)
|
||||||
|
liveStatisticsDistanceView.text = distanceString
|
||||||
|
liveStatisticsDistanceOutlineView.text = distanceString
|
||||||
|
liveStatisticsDistanceOutlineView.paint.strokeWidth = 5f
|
||||||
|
liveStatisticsDistanceOutlineView.paint.style = Paint.Style.STROKE
|
||||||
|
val durationString: String = DateTimeHelper.convertToReadableTime(context, duration, compactFormat = true)
|
||||||
|
liveStatisticsDurationView.text = durationString
|
||||||
|
liveStatisticsDurationOutlineView.text = durationString
|
||||||
|
liveStatisticsDurationOutlineView.paint.strokeWidth = 5f
|
||||||
|
liveStatisticsDurationOutlineView.paint.style = Paint.Style.STROKE
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Toggles state of main button and additional buttons (save & resume) */
|
/* Toggles state of main button and additional buttons (save & resume) */
|
||||||
fun updateMainButton(trackingState: Int) {
|
fun updateMainButton(trackingState: Int)
|
||||||
|
{
|
||||||
when (trackingState) {
|
when (trackingState) {
|
||||||
Keys.STATE_TRACKING_NOT_STARTED -> {
|
Keys.STATE_TRACKING_NOT_STARTED -> {
|
||||||
mainButton.setIconResource(R.drawable.ic_fiber_manual_record_inactive_24dp)
|
mainButton.setIconResource(R.drawable.ic_fiber_manual_record_inactive_24dp)
|
||||||
|
|
Loading…
Reference in a new issue