本文整理汇总了Java中org.greenrobot.eventbus.EventBus.getDefault方法的典型用法代码示例。如果您正苦于以下问题:Java EventBus.getDefault方法的具体用法?Java EventBus.getDefault怎么用?Java EventBus.getDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.greenrobot.eventbus.EventBus
的用法示例。
在下文中一共展示了EventBus.getDefault方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: subscribeToSystemEvents
import org.greenrobot.eventbus.EventBus; //导入方法依赖的package包/类
/**
* Subscribes to system events of current device. Events emitted to EventBus listener.
*
* @throws ParticleCloudException Failure to subscribe to system events.
* @see <a href="https://github.com/greenrobot/EventBus">EventBus</a>
*/
@MainThread
public void subscribeToSystemEvents() throws ParticleCloudException {
try {
EventBus eventBus = EventBus.getDefault();
subscriptions.add(subscribeToSystemEvent("spark/status", (eventName, particleEvent) ->
sendUpdateStatusChange(eventBus, particleEvent.dataPayload)));
subscriptions.add(subscribeToSystemEvent("spark/flash/status", (eventName, particleEvent) ->
sendUpdateFlashChange(eventBus, particleEvent.dataPayload)));
subscriptions.add(subscribeToSystemEvent("spark/device/app-hash", (eventName, particleEvent) ->
sendSystemEventBroadcast(new DeviceStateChange(ParticleDevice.this,
ParticleDeviceState.APP_HASH_UPDATED), eventBus)));
subscriptions.add(subscribeToSystemEvent("spark/status/safe-mode", (eventName, particleEvent) ->
sendSystemEventBroadcast(new DeviceStateChange(ParticleDevice.this,
ParticleDeviceState.SAFE_MODE_UPDATER), eventBus)));
subscriptions.add(subscribeToSystemEvent("spark/safe-mode-updater/updating", (eventName, particleEvent) ->
sendSystemEventBroadcast(new DeviceStateChange(ParticleDevice.this,
ParticleDeviceState.ENTERED_SAFE_MODE), eventBus)));
} catch (IOException e) {
log.d("Failed to auto-subscribe to system events");
throw new ParticleCloudException(e);
}
}
示例2: buildForScope
import org.greenrobot.eventbus.EventBus; //导入方法依赖的package包/类
public AsyncExecutor buildForScope(Object executionContext) {
if (eventBus == null) {
eventBus = EventBus.getDefault();
}
if (threadPool == null) {
threadPool = Executors.newCachedThreadPool();
}
if (failureEventType == null) {
failureEventType = ThrowableFailureEvent.class;
}
return new AsyncExecutor(threadPool, eventBus, failureEventType, executionContext);
}
示例3: onAccessibilityEvent
import org.greenrobot.eventbus.EventBus; //导入方法依赖的package包/类
@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
final EventBus eventBus = EventBus.getDefault();
L.d("界面有变化.发送消息..." );
String mainService = "com.example.a90678.wechat_group_send_17_07_02_17_35.main.MainService";
if (ServiceManager.isServiceWork(this,
mainService)) {
// eventBus.post(new ScreenCaptureService.ContentChange());
} else {
startService(new Intent(this, MainService.class));
}
}
示例4: UserManager
import org.greenrobot.eventbus.EventBus; //导入方法依赖的package包/类
@Inject
public UserManager(@ApplicationContext Context context, UserDataStore userDataStore, GithubService service) {
this.mContext = context;
this.mUserDataStore = userDataStore;
this.mEventBus = EventBus.getDefault();
this.mGithubService = service;
}
示例5: onStart
import org.greenrobot.eventbus.EventBus; //导入方法依赖的package包/类
@Override
public void onStart() {
super.onStart();
final EventBus eventBus = EventBus.getDefault();
if (!eventBus.isRegistered(this)) {
eventBus.register(this);
}
// ensure that www folder installed on external storage;
// if not - install it
isPluginReadyForWork = isPluginReadyForWork();
if (!isPluginReadyForWork) {
dontReloadOnStart = true;
installWwwFolder();
return;
}
// reload only if we on local storage
if (!dontReloadOnStart) {
dontReloadOnStart = true;
redirectToLocalStorageIndexPage();
}
// install update if there is anything to install
if (chcpXmlConfig.isAutoInstallIsAllowed() &&
!UpdatesInstaller.isInstalling() &&
!UpdatesLoader.isExecuting() &&
!TextUtils.isEmpty(pluginInternalPrefs.getReadyForInstallationReleaseVersionName())) {
installUpdate(null);
}
}
示例6: getEventBus
import org.greenrobot.eventbus.EventBus; //导入方法依赖的package包/类
/** eventBus!=null ? eventBus: EventBus.getDefault() */
EventBus getEventBus() {
return eventBus!=null ? eventBus: EventBus.getDefault();
}
示例7: MainService
import org.greenrobot.eventbus.EventBus; //导入方法依赖的package包/类
private MainService() {
mEventBus = EventBus.getDefault();
mSubServices = new ConcurrentHashMap<>();
}
示例8: SubService
import org.greenrobot.eventbus.EventBus; //导入方法依赖的package包/类
private SubService() {
mEventBus = EventBus.getDefault();
}
示例9: providesEventBus
import org.greenrobot.eventbus.EventBus; //导入方法依赖的package包/类
@Provides
@Singleton
EventBus providesEventBus(MyApp application) {
return EventBus.getDefault();
}
示例10: provideEventBus
import org.greenrobot.eventbus.EventBus; //导入方法依赖的package包/类
@Provides
@Singleton
EventBus provideEventBus() {
return EventBus.getDefault();
}
示例11: provideEventBus
import org.greenrobot.eventbus.EventBus; //导入方法依赖的package包/类
@Provides
@ApplicationScope
public EventBus provideEventBus() {
return EventBus.getDefault();
}
示例12: onCreate
import org.greenrobot.eventbus.EventBus; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
// getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
// CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) toolbar.getLayoutParams();
// params.setMargins(0,getStatusBarHeight(), 0, 0);
// toolbar.setLayoutParams(params);
setSupportActionBar(toolbar);
btn = (TextView) findViewById(R.id.bt);
Typeface Font = Typeface.createFromAsset(this.getAssets(), "iconfont.ttf");
btn.setText(getResources().getText(R.string.setting));
btn.setTypeface(Font);
Log.d("eee", "on create()");
showSteps = (TextView) findViewById(R.id.showSteps);
mLayout = findViewById(R.id.mylayout);
on_off = (Switch) findViewById(R.id.on_off);
foreground_model = (Switch) findViewById(R.id.foreground_model);
sharedPreferences = getSharedPreferences("conf", MODE_PRIVATE);
detectService();
bus = EventBus.getDefault();
bus.register(this);
Realm realm = Realm.getDefaultInstance();
StepModel result = realm.where(StepModel.class)
.equalTo("date", DateTimeHelper.getToday())
.findFirst();
numSteps = result == null ? 0 : result.getNumSteps();
bus.post(true);
updateShowSteps();
realm.close();
drawChart();
}
示例13: HermesEventBus
import org.greenrobot.eventbus.EventBus; //导入方法依赖的package包/类
/**
*
* 1. Consider more about the interleaving, especially when the service is being connected or disconnected.
*
* 2. Pay attention to the following cases:
*
* (1) Write-after-write hazard
* Before the connection succeeds, e1, e2 and e3 are put into the queue.
* Then when the connection succeeds, they are posted one by one.
* However, after e1 is posted, we post another event e4.
* I should guarantee that e4 is posted after e3.
*
* (2) Read-after-write hazard
* Before the connection succeeds, some sticky events (e1, e2 and e3)
* are put into the queue.
* Then when the connection succeeds, they are posted one by one.
* However, after e1 is posted, we get a sticky event.
* I should guarantee that we get e3 rather than e1.
*
*/
private HermesEventBus() {
mEventBus = EventBus.getDefault();
mRemoteApis = new ObjectCanary2<IMainService>();
}