當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。