forked from upstream-mirrors/OpenTracks
Bugfix: StatsFragment (onResume and track was recording) overwrote in the total time UI until next UI update.
This commit is contained in:
@@ -91,7 +91,7 @@ public class StatsFragment extends Fragment implements TrackDataListener {
|
|||||||
public void run() {
|
public void run() {
|
||||||
if (isResumed() && isSelectedTrackRecording()) {
|
if (isResumed() && isSelectedTrackRecording()) {
|
||||||
if (!isSelectedTrackPaused() && lastTripStatistics != null) {
|
if (!isSelectedTrackPaused() && lastTripStatistics != null) {
|
||||||
setTotalTimeValue(System.currentTimeMillis() - lastTripStatistics.getStopTime() + lastTripStatistics.getTotalTime());
|
updateTotalTime();
|
||||||
updateSensorDataUI();
|
updateSensorDataUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,10 +224,7 @@ public class StatsFragment extends Fragment implements TrackDataListener {
|
|||||||
trackRecordingServiceConnection = new TrackRecordingServiceConnection(getContext(), null);
|
trackRecordingServiceConnection = new TrackRecordingServiceConnection(getContext(), null);
|
||||||
trackRecordingServiceConnection.startConnection(getContext());
|
trackRecordingServiceConnection.startConnection(getContext());
|
||||||
|
|
||||||
updateUi();
|
handlerUpdateUI.post(updateUIeachSecond);
|
||||||
if (isSelectedTrackRecording()) {
|
|
||||||
handlerUpdateUI.post(updateUIeachSecond);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -307,7 +304,7 @@ public class StatsFragment extends Fragment implements TrackDataListener {
|
|||||||
if (isResumed()) {
|
if (isResumed()) {
|
||||||
lastTripStatistics = track != null ? track.getTripStatistics() : null;
|
lastTripStatistics = track != null ? track.getTripStatistics() : null;
|
||||||
category = track != null ? track.getCategory() : "";
|
category = track != null ? track.getCategory() : "";
|
||||||
updateUi();
|
updateUI();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -377,7 +374,7 @@ public class StatsFragment extends Fragment implements TrackDataListener {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (isResumed()) {
|
if (isResumed()) {
|
||||||
updateUi();
|
updateUI();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -392,7 +389,7 @@ public class StatsFragment extends Fragment implements TrackDataListener {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (isResumed()) {
|
if (isResumed()) {
|
||||||
updateUi();
|
updateUI();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -448,7 +445,7 @@ public class StatsFragment extends Fragment implements TrackDataListener {
|
|||||||
return trackDataHub != null && trackDataHub.isSelectedTrackPaused();
|
return trackDataHub != null && trackDataHub.isSelectedTrackPaused();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateUi() {
|
private void updateUI() {
|
||||||
updateStats();
|
updateStats();
|
||||||
setLocationValues();
|
setLocationValues();
|
||||||
updateSensorDataUI();
|
updateSensorDataUI();
|
||||||
@@ -523,9 +520,8 @@ public class StatsFragment extends Fragment implements TrackDataListener {
|
|||||||
|
|
||||||
// Set time
|
// Set time
|
||||||
if (lastTripStatistics != null) {
|
if (lastTripStatistics != null) {
|
||||||
setTotalTimeValue(lastTripStatistics.getTotalTime());
|
|
||||||
|
|
||||||
movingTimeValue.setText(StringUtils.formatElapsedTime(lastTripStatistics.getMovingTime()));
|
movingTimeValue.setText(StringUtils.formatElapsedTime(lastTripStatistics.getMovingTime()));
|
||||||
|
updateTotalTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set average speed/pace
|
// Set average speed/pace
|
||||||
@@ -590,7 +586,13 @@ public class StatsFragment extends Fragment implements TrackDataListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setTotalTimeValue(long totalTime) {
|
private void updateTotalTime() {
|
||||||
|
long totalTime;
|
||||||
|
if (isSelectedTrackRecording()) {
|
||||||
|
totalTime = System.currentTimeMillis() - lastTripStatistics.getStopTime() + lastTripStatistics.getTotalTime();
|
||||||
|
} else {
|
||||||
|
totalTime = lastTripStatistics.getTotalTime();
|
||||||
|
}
|
||||||
totalTimeValueView.setText(StringUtils.formatElapsedTime(totalTime));
|
totalTimeValueView.setText(StringUtils.formatElapsedTime(totalTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user