Only repaint chart when activity is still alive

(fixes error message when synchronizing in the charts activity and then
switching orientation)
live-activity-data
cpfeiffer 2015-08-16 23:27:18 +02:00
parent 0bd65e050c
commit 27a9eb8a07
1 changed files with 7 additions and 1 deletions

View File

@ -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");
}
}
}
}