WeatherInformation: onPause and onResume intstead of onStop and onStart
authorgu.martinm@gmail.com <gu.martinm@gmail.com>
Mon, 22 Sep 2014 00:49:17 +0000 (02:49 +0200)
committergu.martinm@gmail.com <gu.martinm@gmail.com>
Mon, 22 Sep 2014 00:51:20 +0000 (02:51 +0200)
Just trying to make sure I do not update the UI when it is not allowed.
(Trying to avoid nasty exceptions that could kill my app)

Android/WeatherInformation/src/de/example/exampletdd/fragment/current/CurrentFragment.java
Android/WeatherInformation/src/de/example/exampletdd/fragment/overview/OverviewFragment.java

index 2292985..cb21ffb 100644 (file)
@@ -81,8 +81,8 @@ public class CurrentFragment extends Fragment {
     }
 
     @Override
-    public void onStart() {
-       super.onStart();
+    public void onResume() {
+        super.onResume();
 
         this.mReceiver = new BroadcastReceiver() {
 
@@ -113,11 +113,6 @@ public class CurrentFragment extends Fragment {
         filter.addAction("de.example.exampletdd.UPDATECURRENT");
         LocalBroadcastManager.getInstance(this.getActivity().getApplicationContext())
                                                        .registerReceiver(this.mReceiver, filter);
-    }
-
-    @Override
-    public void onResume() {
-        super.onResume();
 
         final DatabaseQueries query = new DatabaseQueries(this.getActivity().getApplicationContext());
         final WeatherLocation weatherLocation = query.queryDataBase();
@@ -163,10 +158,10 @@ public class CurrentFragment extends Fragment {
     }
 
     @Override
-    public void onStop() {
+    public void onPause() {
         LocalBroadcastManager.getInstance(this.getActivity().getApplicationContext()).unregisterReceiver(this.mReceiver);
 
-        super.onStop();
+        super.onPause();
     }
 
     private void updateUI(final Current current) {
index 94bd9da..2621758 100644 (file)
@@ -83,8 +83,8 @@ public class OverviewFragment extends ListFragment {
     }
 
     @Override
-    public void onStart() {
-       super.onStart();
+    public void onResume() {
+        super.onResume();
 
         this.mReceiver = new BroadcastReceiver() {
 
@@ -117,11 +117,6 @@ public class OverviewFragment extends ListFragment {
         filter.addAction("de.example.exampletdd.UPDATEFORECAST");
         LocalBroadcastManager.getInstance(this.getActivity().getApplicationContext())
                                                        .registerReceiver(this.mReceiver, filter);
-    }
-
-    @Override
-    public void onResume() {
-        super.onResume();
 
         final DatabaseQueries query = new DatabaseQueries(this.getActivity().getApplicationContext());
         final WeatherLocation weatherLocation = query.queryDataBase();
@@ -168,10 +163,10 @@ public class OverviewFragment extends ListFragment {
     }
 
     @Override
-    public void onStop() {
+    public void onPause() {
         LocalBroadcastManager.getInstance(this.getActivity().getApplicationContext()).unregisterReceiver(this.mReceiver);
 
-        super.onStop();
+        super.onPause();
     }
 
     @Override