mirror of
https://gitee.com/zhangsken/AndroidIDE.git
synced 2026-10-16 07:49:44 +08:00
fix: do not reinstall default EventBus instance if already installed (fixes #809)
This commit is contained in:
@@ -69,7 +69,7 @@ class IDEApplication : BaseApplication() {
|
||||
.addIndex(ProjectsApiEventsIndex())
|
||||
.addIndex(LspApiEventsIndex())
|
||||
.addIndex(LspJavaEventsIndex())
|
||||
.installDefaultEventBus()
|
||||
.installDefaultEventBus(true)
|
||||
|
||||
AppCompatDelegate.setDefaultNightMode(uiMode)
|
||||
|
||||
|
||||
@@ -168,15 +168,23 @@ public class EventBusBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
public EventBus installDefaultEventBus() {
|
||||
return installDefaultEventBus(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Installs the default EventBus returned by {@link EventBus#getDefault()} using this builders'
|
||||
* values. Must be done only once before the first usage of the default EventBus.
|
||||
*
|
||||
* @throws EventBusException if there's already a default EventBus instance in place
|
||||
*/
|
||||
public EventBus installDefaultEventBus() {
|
||||
public EventBus installDefaultEventBus(boolean ignoreIfInstalled) {
|
||||
synchronized (EventBus.class) {
|
||||
if (EventBus.defaultInstance != null) {
|
||||
if (ignoreIfInstalled) {
|
||||
return EventBus.defaultInstance;
|
||||
}
|
||||
|
||||
throw new EventBusException(
|
||||
"Default instance already exists."
|
||||
+ " It may be only set once before it's used the first time to ensure consistent behavior.");
|
||||
|
||||
Reference in New Issue
Block a user