From: gu.martinm@gmail.com Date: Mon, 22 Sep 2014 00:49:17 +0000 (+0200) Subject: WeatherInformation: onPause and onResume intstead of onStop and onStart X-Git-Tag: weatherinformation-1.0~129 X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=623b622315d40499831d97330b7b00a106b58d00;p=AndroidWeatherInformation 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) --- 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