ChartFragment: re-added isResume() check.
package de.dennisguse.opentracks.fragments;
+import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.LayoutInflater;
@@ -24,7 +25,6 @@ import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
-import androidx.fragment.app.FragmentActivity;
import java.util.ArrayList;
import java.util.List;
@@ -169,6 +169,7 @@ public class ChartFragment extends Fragment implements TrackDataListener {
@Override
public void onTrackUpdated(Track track) {
+ if (isResumed()) {
if (track == null) {
category = "";
return;
@@ -181,9 +182,11 @@ public class ChartFragment extends Fragment implements TrackDataListener {
viewBinding.chartView.applyReportSpeed();
}
}
+ }
@Override
public void clearTrackPoints() {
+ if (isResumed()) {
pendingPoints.clear();
viewBinding.chartView.reset();
runOnUiThread(() -> {
@@ -192,33 +195,44 @@ public class ChartFragment extends Fragment implements TrackDataListener {
}
});
}
+ }
public void onSampledInTrackPoint(@NonNull TrackPoint trackPoint, @NonNull TrackStatistics trackStatistics, Speed smoothedSpeed, double smoothedAltitude_m) {
+ if (isResumed()) {
ChartPoint point = new ChartPoint(trackStatistics, trackPoint, smoothedSpeed, smoothedAltitude_m, chartByDistance, viewBinding.chartView.getMetricUnits());
pendingPoints.add(point);
}
+ }
@Override
public void onNewTrackPointsDone() {
+ if (isResumed()) {
viewBinding.chartView.addChartPoints(pendingPoints);
pendingPoints.clear();
runOnUiThread(updateChart);
}
+ }
@Override
public void clearMarkers() {
+ if (isResumed()) {
viewBinding.chartView.clearMarker();
}
+ }
@Override
public void onNewMarker(@NonNull Marker marker) {
+ if (isResumed()) {
viewBinding.chartView.addMarker(marker);
}
+ }
@Override
public void onNewMarkersDone() {
+ if (isResumed()) {
runOnUiThread(updateChart);
}
+ }
/**
* Checks the chart settings.
@@ -264,7 +278,7 @@ public class ChartFragment extends Fragment implements TrackDataListener {
* @param runnable the runnable
*/
private void runOnUiThread(Runnable runnable) {
- FragmentActivity fragmentActivity = getActivity();
+ Activity fragmentActivity = getActivity();
if (fragmentActivity != null) {
fragmentActivity.runOnUiThread(runnable);
}
