From 623b622315d40499831d97330b7b00a106b58d00 Mon Sep 17 00:00:00 2001 From: "gu.martinm@gmail.com" Date: Mon, 22 Sep 2014 02:49:17 +0200 Subject: [PATCH] WeatherInformation: onPause and onResume intstead of onStop and onStart 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) --- .../exampletdd/fragment/current/CurrentFragment.java | 13 ++++--------- .../exampletdd/fragment/overview/OverviewFragment.java | 13 ++++--------- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/de/example/exampletdd/fragment/current/CurrentFragment.java b/src/de/example/exampletdd/fragment/current/CurrentFragment.java index 2292985..cb21ffb 100644 --- a/src/de/example/exampletdd/fragment/current/CurrentFragment.java +++ b/src/de/example/exampletdd/fragment/current/CurrentFragment.java @@ -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) { diff --git a/src/de/example/exampletdd/fragment/overview/OverviewFragment.java b/src/de/example/exampletdd/fragment/overview/OverviewFragment.java index 94bd9da..2621758 100644 --- a/src/de/example/exampletdd/fragment/overview/OverviewFragment.java +++ b/src/de/example/exampletdd/fragment/overview/OverviewFragment.java @@ -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 -- 2.1.4