Ignore harmless errors (un)subscribing to the message bus.
This commit is contained in:
parent
3b19db14fd
commit
79458a1c73
|
@ -245,12 +245,27 @@ public class MainApp extends Application {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public void stopKeepAliveService() {
|
||||
if (keepAliveReceiver != null)
|
||||
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() {
|
||||
return sBus;
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
|
|||
} else {
|
||||
if (getDialog() != null)
|
||||
getDialog().getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
MainApp.bus().register(this);
|
||||
MainApp.subscribe(this);
|
||||
running = true;
|
||||
}
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
|
|||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
MainApp.bus().unregister(this);
|
||||
MainApp.unsubscribe(this);
|
||||
running = false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue