当前位置: 首页>>代码示例>>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;未经允许,请勿转载。