Ignore harmless errors (un)subscribing to the message bus.
This commit is contained in:
parent
3b19db14fd
commit
79458a1c73
2 changed files with 18 additions and 3 deletions
|
@ -245,12 +245,27 @@ public class MainApp extends Application {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void stopKeepAliveService() {
|
public void stopKeepAliveService() {
|
||||||
if (keepAliveReceiver != null)
|
if (keepAliveReceiver != null)
|
||||||
KeepAliveReceiver.cancelAlarm(this);
|
KeepAliveReceiver.cancelAlarm(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void subscribe(Object subscriber) {
|
||||||
|
try {
|
||||||
|
bus().register(subscriber);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
// already registered
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void unsubscribe(Object subscriber) {
|
||||||
|
try {
|
||||||
|
bus().unregister(subscriber);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
// already unregistered
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static Bus bus() {
|
public static Bus bus() {
|
||||||
return sBus;
|
return sBus;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
|
||||||
} else {
|
} else {
|
||||||
if (getDialog() != null)
|
if (getDialog() != null)
|
||||||
getDialog().getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
getDialog().getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||||
MainApp.bus().register(this);
|
MainApp.subscribe(this);
|
||||||
running = true;
|
running = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
MainApp.bus().unregister(this);
|
MainApp.unsubscribe(this);
|
||||||
running = false;
|
running = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue