當前位置: 首頁>>代碼示例>>Java>>正文


Java EventBus類代碼示例

本文整理匯總了Java中org.greenrobot.eventbus.EventBus的典型用法代碼示例。如果您正苦於以下問題:Java EventBus類的具體用法?Java EventBus怎麽用?Java EventBus使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


EventBus類屬於org.greenrobot.eventbus包,在下文中一共展示了EventBus類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: listen

import org.greenrobot.eventbus.EventBus; //導入依賴的package包/類
/**
 * Listen for client connections
 *
 * @throws IOException server socket cannot be created on port
 */
private void listen() throws IOException {
    try {
        Log.d(TAG, "listen: Create server socket");
        ServerSocket rtspServerSocket = new ServerSocket();
        rtspServerSocket.setReuseAddress(true);
        rtspServerSocket.bind(new InetSocketAddress(port));

        while (!Thread.interrupted()) {
            Log.d(TAG, "listening");

            // Blocking
            EventBus.getDefault().post(new RtspServerEvent.Connection(this, rtspServerSocket.accept()));
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
開發者ID:devinbrown7,項目名稱:streaminglib,代碼行數:23,代碼來源:RtspServer.java

示例2: onEvent

import org.greenrobot.eventbus.EventBus; //導入依賴的package包/類
@Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
public void onEvent(SyncEvent event) {
    switch (event.getCode()) {
        case SyncEvent.START_SYNC:
            showLoading();
            break;
        case SyncEvent.END_SYNC:
            hideLoading();
            EventBus.getDefault().post(new SyncEvent(SyncEvent.UPDATE_SYNC, ""));
            EventBus.getDefault().removeStickyEvent(event);
            break;
    }
    if(!event.getStatus().isEmpty()){
        Toast.makeText(this, event.getStatus(), Toast.LENGTH_SHORT).show();
    }
}
 
開發者ID:graviton57,項目名稱:DOUSalaries,代碼行數:17,代碼來源:MainActivity.java

示例3: onHandleIntent

import org.greenrobot.eventbus.EventBus; //導入依賴的package包/類
@Override
protected void onHandleIntent(@Nullable Intent intent) {
    isRunning = true;
    showForegroundNotification();
    name = intent.getStringExtra(EXTRA_ACTIVITY_TYPE);
    storage = new StorageUtil(name);
    startAccelerometer();
    try {
        Thread.sleep(Config.LENGTH_RECORDING_IN_MINUTES * 60 * 1000);
    } catch (InterruptedException e) {
    }
    stopAccelerometer();
    storage.close();
    RecorderFinishedEvent event = new RecorderFinishedEvent();
    event.activityType = name;
    EventBus.getDefault().post(event);
    isRunning = false;
    hideForegroundNotification();
    ToneGenerator beep = new ToneGenerator(AudioManager.STREAM_MUSIC, 500);
    beep.startTone(ToneGenerator.TONE_CDMA_HIGH_L, 1000);
}
 
開發者ID:apuder,項目名稱:ActivityMonitor,代碼行數:22,代碼來源:RecorderService.java

示例4: onProgressChanged

import org.greenrobot.eventbus.EventBus; //導入依賴的package包/類
@Override
public void onProgressChanged(final SeekBar seekBar,
                              final int progress,
                              final boolean fromUser) {
    if (!fromUser) {
        // Ignore all changes if they are not from user
        return;
    }

    // Ignore the next status update to avoid the seek bar to
    // be updated from a response sent before this request
    skipNextStatus = true;

    // Send request
    EventBus.getDefault().post(new RequestEvent(Cmd.VOLUME,
            String.valueOf(progress), true));
}
 
開發者ID:Alkisum,項目名稱:SofaTime,代碼行數:18,代碼來源:MainActivity.java

示例5: onDestroy

import org.greenrobot.eventbus.EventBus; //導入依賴的package包/類
@Override
public void onDestroy() {
    isRun = false;
    EventBus.getDefault().post(new MessageEvent(MessageEvent.QHB_SERVICE_STATE, false));
    EventBus.getDefault().unregister(this);
    mQHBNotificationManager.stopNotification();
    unregisterReceiver(mBroadcastReceiver);
    super.onDestroy();
    LogUtils.printOut(TAG, "QHBService onDestroy");
    if(mPkgAccessibilityJobMap != null) {
        mPkgAccessibilityJobMap.clear();
    }
    if(mAccessibilityJobs != null && !mAccessibilityJobs.isEmpty()) {
        for (IAccessibilityJob job : mAccessibilityJobs) {
            job.onDestroy();
        }
        mAccessibilityJobs.clear();
    }

    mAccessibilityJobs = null;
    mPkgAccessibilityJobMap = null;
}
 
開發者ID:A-Miracle,項目名稱:QiangHongBao,代碼行數:23,代碼來源:QHBService.java

示例6: GpioHandler

import org.greenrobot.eventbus.EventBus; //導入依賴的package包/類
private GpioHandler() {
    EventBus.getDefault().register(this);
    mContext = ContextHolder.getAppContext();
    manager = new PeripheralManagerService();
    try {
        mAlarmGpio = manager.openGpio(GPIO_ALARM_TRIGGER);
        mAlarmGpio.setDirection(Gpio.DIRECTION_OUT_INITIALLY_LOW);

        mMotion = new Button(GPIO_ALARM_MOTION,
                Button.LogicState.PRESSED_WHEN_HIGH
        );

        mMotion.setOnButtonEventListener(this);
    } catch (IOException e) {
        Log.e(BurglarAlarmConstants.LOG_TAG, "IOException :" + e);
    }

}
 
開發者ID:freeloki,項目名稱:AndroidThings-BurglarAlarm,代碼行數:19,代碼來源:GpioHandler.java

示例7: onCreateDialog

import org.greenrobot.eventbus.EventBus; //導入依賴的package包/類
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    DateTime currentDateTime = new DateTime();
    int currentHour = currentDateTime.getHourOfDay();
    int currentMinute = currentDateTime.getMinuteOfHour();
    final Bundle args = getArguments();

    MinTimePickerDialog timePickerDialog = new MinTimePickerDialog(getActivity(), R.style.MyPicker,
            (view, hourOfDay, minute) -> {
                DateTime dateTime = new DateTime(
                        args.getInt(ARGUMENT_PICKED_YEAR),
                        args.getInt(ARGUMENT_PICKED_MONTH) + 1,
                        args.getInt(ARGUMENT_PICKED_DAY), hourOfDay, minute);
                EventBus.getDefault().post(new ReminderSetEvent(dateTime.getMillis()));
            }, currentHour, currentMinute, DateFormat.is24HourFormat(getActivity()));
    if (args.getBoolean(ARGUMENT_IS_TODAY)) {
        timePickerDialog.setMin(currentHour, currentMinute);
    }

    return timePickerDialog;
}
 
開發者ID:Laaidback,項目名稱:A.scribe,代碼行數:23,代碼來源:TimePickerDialogFragment.java

示例8: streamLine

import org.greenrobot.eventbus.EventBus; //導入依賴的package包/類
private void streamLine(GcodeCommand gcodeCommand){

        String command = gcodeCommand.getCommandString();
        int commandSize = command.length() + 1;
        if(commandSize <= 1) return;

        // Wait until there is room, if necessary.
        while (MAX_RX_SERIAL_BUFFER < (CURRENT_RX_SERIAL_BUFFER + command.length() + 1)) {
            try {
                completedCommands.take();
                if(activeCommandSizes.size() > 0) CURRENT_RX_SERIAL_BUFFER -= activeCommandSizes.removeFirst();
            } catch (InterruptedException e) {
                Log.e(TAG, e.getMessage(), e);
                return;
            }

            if(!shouldContinue) return;
        }

        if(shouldContinue){
            activeCommandSizes.offer(commandSize);
            CURRENT_RX_SERIAL_BUFFER += commandSize;
            EventBus.getDefault().post(gcodeCommand);
        }

    }
 
開發者ID:zeevy,項目名稱:grblcontroller,代碼行數:27,代碼來源:FileStreamerIntentService.java

示例9: onCreate

import org.greenrobot.eventbus.EventBus; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // If you want to handle sticky message, please comment out the following code
    EventBus.getDefault().register(this);
}
 
開發者ID:InnoFang,項目名稱:Android-Code-Demos,代碼行數:9,代碼來源:MainActivity.java

示例10: onClick

import org.greenrobot.eventbus.EventBus; //導入依賴的package包/類
public void onClick(View view) {
    switch (view.getId()) {
        case R.id.intent_to_second_button:
            startActivity(new Intent(MainActivity.this, SecondActivity.class));
            break;
        case R.id.handle_sticky_button:
            EventBus.getDefault().register(this);
            break;
    }
    startActivity(new Intent(MainActivity.this, SecondActivity.class));
}
 
開發者ID:InnoFang,項目名稱:Android-Code-Demos,代碼行數:12,代碼來源:MainActivity.java

示例11: execute

import org.greenrobot.eventbus.EventBus; //導入依賴的package包/類
private static void execute(final WorkerTask task) {
    isInstalling = true;
    new Thread(new Runnable() {
        @Override
        public void run() {
            task.run();
            isInstalling = false;

            // dispatch resulting event
            EventBus.getDefault().post(task.result());
        }
    }).start();
}
 
開發者ID:SUTFutureCoder,項目名稱:localcloud_fe,代碼行數:14,代碼來源:UpdatesInstaller.java

示例12: setDataList

import org.greenrobot.eventbus.EventBus; //導入依賴的package包/類
public void setDataList(final List<OnlineModel> modelss, final int position) {


        Observable.just(models)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Action1<List<OnlineModel>>() {
                    @Override
                    public void call(List<OnlineModel> onlineModels) {
                        synchronized (models) {
                            if (models.size() == modelss.size()) {
                                models.clear();
                                models.addAll(modelss);
                                notifyItemChanged(position);
                            } else if (models.size() < modelss.size()) {
                                models.clear();
                                models.addAll(modelss);
                                notifyItemInserted(0);
                            } else if (models.size() > modelss.size()) { //刪除
                                notifyItemRemoved(position);
                                models.clear();
                                models.addAll(modelss);
                            }
                            EventBus.getDefault().post(new OnlineEvent(1, models.size(), 0));
                        }
                    }
                });

    }
 
開發者ID:ANDROIDTODO,項目名稱:Transmission,代碼行數:29,代碼來源:OnlineRecyclerAdapter.java

示例13: close

import org.greenrobot.eventbus.EventBus; //導入依賴的package包/類
public void close() throws IOException {
    if (mSocket != null) {
        mSocket.close();
        mExecutor.shutdownNow();
        mSocket = null;
        mOutputStream = null;
        mExecutor = null;
        EventBus.getDefault().post(new ConnectionStateChangeEvent(false));
    }
}
 
開發者ID:feifadaima,項目名稱:https-github.com-hyb1996-NoRootScriptDroid,代碼行數:11,代碼來源:SublimePluginClient.java

示例14: onCreate

import org.greenrobot.eventbus.EventBus; //導入依賴的package包/類
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_game);

    EventBus.getDefault().register(this);
    init();
    initUIandEvent();
}
 
開發者ID:wzc25151,項目名稱:lrs_android,代碼行數:10,代碼來源:GameActivity.java

示例15: channelInactive

import org.greenrobot.eventbus.EventBus; //導入依賴的package包/類
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
    super.channelInactive(ctx);
    try {
        EventBus.getDefault().post(new ChannelEvent(EventType.ON_INACTIVE, null));
    }catch (Exception e){
        e.printStackTrace();
    }
}
 
開發者ID:dovakinlink,項目名稱:netty-dovakin-android-client,代碼行數:10,代碼來源:NGLSClientHandler.java


注:本文中的org.greenrobot.eventbus.EventBus類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。