From 27a9eb8a07284ed1dcdfec3b3504386456775481 Mon Sep 17 00:00:00 2001 From: cpfeiffer Date: Sun, 16 Aug 2015 23:27:18 +0200 Subject: [PATCH] Only repaint chart when activity is still alive (fixes error message when synchronizing in the charts activity and then switching orientation) --- .../activities/charts/AbstractChartFragment.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/AbstractChartFragment.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/AbstractChartFragment.java index 0bced541..fe1dd6f9 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/AbstractChartFragment.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/AbstractChartFragment.java @@ -3,6 +3,7 @@ package nodomain.freeyourgadget.gadgetbridge.activities.charts; import android.content.Context; import android.graphics.Color; import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentActivity; import com.github.mikephil.charting.charts.BarLineChartBase; import com.github.mikephil.charting.charts.Chart; @@ -360,7 +361,12 @@ public abstract class AbstractChartFragment extends Fragment { @Override protected void onPostExecute(Object o) { super.onPostExecute(o); - renderCharts(); + FragmentActivity activity = getActivity(); + if (activity != null && !activity.isFinishing() && !activity.isDestroyed()) { + renderCharts(); + } else { + LOG.info("Not rendering charts because activity is not available anymore"); + } } } }