From f7efa4f3461d396129b907eda43b5f8335ccc4cd Mon Sep 17 00:00:00 2001 From: "gu.martinm@gmail.com" Date: Mon, 1 Sep 2014 01:28:19 +0200 Subject: [PATCH] Android WeatherInformation: check null value (current and forecast) before trying to update UI. --- src/de/example/exampletdd/fragment/current/CurrentFragment.java | 6 ++++++ src/de/example/exampletdd/fragment/overview/OverviewFragment.java | 6 ++++++ src/de/example/exampletdd/fragment/specific/SpecificFragment.java | 2 ++ 3 files changed, 14 insertions(+) diff --git a/src/de/example/exampletdd/fragment/current/CurrentFragment.java b/src/de/example/exampletdd/fragment/current/CurrentFragment.java index cd79d9b..8f3bd53 100644 --- a/src/de/example/exampletdd/fragment/current/CurrentFragment.java +++ b/src/de/example/exampletdd/fragment/current/CurrentFragment.java @@ -318,6 +318,12 @@ public class CurrentFragment extends ListFragment { @Override protected void onPostExecute(final Current current) { + + if (current == null) { + // Nothing to do + return; + } + // Call updateUI on the UI thread. updateUI(current); diff --git a/src/de/example/exampletdd/fragment/overview/OverviewFragment.java b/src/de/example/exampletdd/fragment/overview/OverviewFragment.java index a7aa902..d2cfbc1 100644 --- a/src/de/example/exampletdd/fragment/overview/OverviewFragment.java +++ b/src/de/example/exampletdd/fragment/overview/OverviewFragment.java @@ -306,6 +306,12 @@ public class OverviewFragment extends ListFragment { @Override protected void onPostExecute(final Forecast forecast) { + + if (forecast == null) { + // Nothing to do + return; + } + // Call updateUI on the UI thread. updateUI(forecast); diff --git a/src/de/example/exampletdd/fragment/specific/SpecificFragment.java b/src/de/example/exampletdd/fragment/specific/SpecificFragment.java index 542749e..7339dd4 100644 --- a/src/de/example/exampletdd/fragment/specific/SpecificFragment.java +++ b/src/de/example/exampletdd/fragment/specific/SpecificFragment.java @@ -37,8 +37,10 @@ public class SpecificFragment extends ListFragment { final Bundle extras = this.getActivity().getIntent().getExtras(); if (extras != null) { + // handset layout this.mChosenDay = extras.getInt("CHOSEN_DAY", 0); } else { + // tablet layout // Always 0 when tablet layout. this.mChosenDay = 0; } -- 2.1.4