当前位置: 首页>>代码示例>>Java>>正文


Java EventBus.getDefault方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:Datatellit,项目名称:xlight_android_native,代码行数:29,代码来源:ParticleDevice.java

示例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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:AsyncExecutor.java

示例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));
        }
    }
 
开发者ID:kaixuanluo,项目名称:pc-android-controller-android,代码行数:13,代码来源:BaseAccessService.java

示例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;
}
 
开发者ID:duyp,项目名称:mvvm-template,代码行数:8,代码来源:UserManager.java

示例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);
    }
}
 
开发者ID:SUTFutureCoder,项目名称:localcloud_fe,代码行数:33,代码来源:HotCodePushPlugin.java

示例6: getEventBus

import org.greenrobot.eventbus.EventBus; //导入方法依赖的package包/类
/** eventBus!=null ? eventBus: EventBus.getDefault() */
EventBus getEventBus() {
    return eventBus!=null ? eventBus: EventBus.getDefault();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:5,代码来源:ErrorDialogConfig.java

示例7: MainService

import org.greenrobot.eventbus.EventBus; //导入方法依赖的package包/类
private MainService() {
    mEventBus = EventBus.getDefault();
    mSubServices = new ConcurrentHashMap<>();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:5,代码来源:MainService.java

示例8: SubService

import org.greenrobot.eventbus.EventBus; //导入方法依赖的package包/类
private SubService() {
    mEventBus = EventBus.getDefault();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:4,代码来源:SubService.java

示例9: providesEventBus

import org.greenrobot.eventbus.EventBus; //导入方法依赖的package包/类
@Provides
@Singleton
EventBus providesEventBus(MyApp application) {
    return EventBus.getDefault();
}
 
开发者ID:kocur,项目名称:Obd2-Tracker,代码行数:6,代码来源:AppModule.java

示例10: provideEventBus

import org.greenrobot.eventbus.EventBus; //导入方法依赖的package包/类
@Provides
@Singleton
EventBus provideEventBus() {
    return EventBus.getDefault();
}
 
开发者ID:duyp,项目名称:mvvm-template,代码行数:6,代码来源:AppModule.java

示例11: provideEventBus

import org.greenrobot.eventbus.EventBus; //导入方法依赖的package包/类
@Provides
@ApplicationScope
public EventBus provideEventBus() {
    return EventBus.getDefault();
}
 
开发者ID:tresorit,项目名称:ZeroKit-Android-SDK,代码行数:6,代码来源:EventBusModule.java

示例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();


    }
 
开发者ID:gojuukaze,项目名称:healthgo,代码行数:43,代码来源:MainActivity.java

示例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>();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:HermesEventBus.java


注:本文中的org.greenrobot.eventbus.EventBus.getDefault方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。