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,13 +201,22 @@ 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
|
||||||
|
liveStatisticsDurationView.isGone = true
|
||||||
|
liveStatisticsDistanceOutlineView.isGone = true
|
||||||
|
liveStatisticsDurationOutlineView.isGone = true
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
liveStatisticsDistanceView.isVisible = true
|
||||||
|
liveStatisticsDurationView.isVisible = true
|
||||||
|
liveStatisticsDistanceOutlineView.isVisible = true
|
||||||
|
liveStatisticsDurationOutlineView.isVisible = true
|
||||||
// update distance and duration (and add outline)
|
// update distance and duration (and add outline)
|
||||||
val distanceString: String = LengthUnitHelper.convertDistanceToString(distance, useImperial)
|
val distanceString: String = LengthUnitHelper.convertDistanceToString(distance, useImperial)
|
||||||
liveStatisticsDistanceView.text = distanceString
|
liveStatisticsDistanceView.text = distanceString
|
||||||
|
@ -219,12 +228,12 @@ data class MapFragmentLayoutHolder(private var context: Context, private var mar
|
||||||
liveStatisticsDurationOutlineView.text = durationString
|
liveStatisticsDurationOutlineView.text = durationString
|
||||||
liveStatisticsDurationOutlineView.paint.strokeWidth = 5f
|
liveStatisticsDurationOutlineView.paint.strokeWidth = 5f
|
||||||
liveStatisticsDurationOutlineView.paint.style = Paint.Style.STROKE
|
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