From: gu.martinm@gmail.com Date: Sun, 31 Aug 2014 23:28:19 +0000 (+0200) Subject: Android WeatherInformation: X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=e2f757b49813f788e102468bf10dad0578047871;p=JavaForFun Android WeatherInformation: check null value (current and forecast) before trying to update UI. --- diff --git a/Android/WeatherInformation/src/de/example/exampletdd/fragment/current/CurrentFragment.java b/Android/WeatherInformation/src/de/example/exampletdd/fragment/current/CurrentFragment.java index cd79d9b..8f3bd53 100644 --- a/Android/WeatherInformation/src/de/example/exampletdd/fragment/current/CurrentFragment.java +++ b/Android/WeatherInformation/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/Android/WeatherInformation/src/de/example/exampletdd/fragment/overview/OverviewFragment.java b/Android/WeatherInformation/src/de/example/exampletdd/fragment/overview/OverviewFragment.java index a7aa902..d2cfbc1 100644 --- a/Android/WeatherInformation/src/de/example/exampletdd/fragment/overview/OverviewFragment.java +++ b/Android/WeatherInformation/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/Android/WeatherInformation/src/de/example/exampletdd/fragment/specific/SpecificFragment.java b/Android/WeatherInformation/src/de/example/exampletdd/fragment/specific/SpecificFragment.java index 542749e..7339dd4 100644 --- a/Android/WeatherInformation/src/de/example/exampletdd/fragment/specific/SpecificFragment.java +++ b/Android/WeatherInformation/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; }