Android WeatherInformation:
authorgu.martinm@gmail.com <gu.martinm@gmail.com>
Sun, 31 Aug 2014 23:28:19 +0000 (01:28 +0200)
committergu.martinm@gmail.com <gu.martinm@gmail.com>
Sun, 31 Aug 2014 23:28:19 +0000 (01:28 +0200)
check null value (current and forecast) before trying to update UI.

src/de/example/exampletdd/fragment/current/CurrentFragment.java
src/de/example/exampletdd/fragment/overview/OverviewFragment.java
src/de/example/exampletdd/fragment/specific/SpecificFragment.java

index cd79d9b..8f3bd53 100644 (file)
@@ -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);
 
index a7aa902..d2cfbc1 100644 (file)
@@ -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);
 
index 542749e..7339dd4 100644 (file)
@@ -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;
         }