本文整理汇总了Java中org.simple.eventbus.EventBus类的典型用法代码示例。如果您正苦于以下问题:Java EventBus类的具体用法?Java EventBus怎么用?Java EventBus使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EventBus类属于org.simple.eventbus包,在下文中一共展示了EventBus类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onStartCommand
import org.simple.eventbus.EventBus; //导入依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
if (intent.getBooleanExtra(PAUSE_DOWNLOAD, false)) {
queue.pause();
return START_REDELIVER_INTENT;
}
VideoDownLoadInfo video = (VideoDownLoadInfo) intent.getSerializableExtra(VIDEOS_INFO);
EventBus.getDefault().postSticky(video,EventBusTags.CACHE_DOWNLOAD_BEGIN);
videos.put(video.getId()+"",video);
File dir = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Sunny_Videos");
if (!dir.exists()) {
dir.mkdirs();
}
DaoMaster master = GreenDaoHelper.getInstance().create(video.getDbName()).getMaster();
master.newSession().startAsyncSession().insertOrReplace(video);
File file = new File(dir.getAbsolutePath(), video.getId() + ".mp4");
BaseDownloadTask task = (FileDownloader.getImpl().create(video.getVideo().getPlayUrl()).setPath(file.getAbsolutePath()).setTag(video.getId()+""));
task.setListener(new CommonDownloadListener());
queue.enqueue(task);
if (isInit){
queue.resume();
isInit = false;
}
return START_NOT_STICKY;
}
示例2: onCreate
import org.simple.eventbus.EventBus; //导入依赖的package包/类
@Nullable
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mApplication = (BaseApplication) getApplication();
//如果intent包含了此字段,并且为true说明不加入到list
// 默认为false,如果不需要管理(比如不需要在退出所有activity(killAll)时,退出此activity就在intent加此字段为true)
boolean isNotAdd = false;
if (getIntent() != null)
isNotAdd = getIntent().getBooleanExtra(IS_NOT_ADD_ACTIVITY_LIST, false);
if (!isNotAdd)
mApplication.getAppManager().addActivity(this);
if (useEventBus())//如果要使用eventbus请将此方法返回true
EventBus.getDefault().register(this);//注册到事件主线
setContentView(initView());
//绑定到butterknife
mUnbinder = ButterKnife.bind(this);
ComponentInject();//依赖注入
initData();
}
示例3: onCreate
import org.simple.eventbus.EventBus; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
EventBus.getDefault().register(this);
LoggerManager.i(TAG, "getRequestedOrientation:" + (getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED));
//先判断xml没有设置屏幕模式避免将开发者本身想设置的覆盖掉
if (getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
setRequestedOrientation(getOrientation());
}
super.onCreate(savedInstanceState);
mContext = this;
FastStackUtil.getInstance().push(this);
initSwipeBack();
beforeSetContentView();
mContentView = View.inflate(mContext, getContentLayout(), null);
setContentView(mContentView);
mUnBinder = ButterKnife.bind(this);
setNavigationBar();
mIsViewLoaded = true;
beforeInitView();
initView(savedInstanceState);
}
示例4: onDestroy
import org.simple.eventbus.EventBus; //导入依赖的package包/类
@Override
protected void onDestroy() {
super.onDestroy();
if (mPresenter != null) mPresenter.onDestroy();//释放资源
if (mUnbinder != Unbinder.EMPTY) mUnbinder.unbind();
if (useEventBus())//如果要使用eventbus请将此方法返回true
EventBus.getDefault().unregister(this);
this.mPresenter = null;
this.mUnbinder = null;
this.mApplication = null;
}
示例5: onCreate
import org.simple.eventbus.EventBus; //导入依赖的package包/类
@Nullable
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mApplication = (BaseApplication) getApplication();
if (useEventBus())//如果要使用eventbus请将此方法返回true
EventBus.getDefault().register(this);//注册到事件主线
setContentView(initView());
//绑定到butterknife
mUnbinder = ButterKnife.bind(this);
ComponentInject();//依赖注入
initData();
}
示例6: onCreate
import org.simple.eventbus.EventBus; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.pay_result);
api = WXAPIFactory.createWXAPI(this, Constant.APP_ID);
api.handleIntent(getIntent(), this);
EventBus.getDefault().register(this);
}
示例7: onDestroy
import org.simple.eventbus.EventBus; //导入依赖的package包/类
@Override
public void onDestroy() {
super.onDestroy();
if (mPresenter != null) mPresenter.onDestroy();//释放资源
if (useEventBus())//如果要使用eventbus请将此方法返回true
EventBus.getDefault().unregister(this);
this.mPresenter = null;
this.mActivity = null;
this.mRootView = null;
this.mUnbinder = null;
}
示例8: SnackbarText
import org.simple.eventbus.EventBus; //导入依赖的package包/类
/**
* 用snackbar显示
*
* @param text
*/
public static void SnackbarText(String text) {
Message message = new Message();
message.what = SHOW_SNACKBAR;
message.obj = text;
message.arg1 = 0;
EventBus.getDefault().post(message, APPMANAGER_MESSAGE);
}
示例9: startActivity
import org.simple.eventbus.EventBus; //导入依赖的package包/类
/**
* 跳转界面3
*
* @param
* @param homeActivityClass
*/
public static void startActivity(Class homeActivityClass) {
Message message = new Message();
message.what = START_ACTIVITY;
message.obj = homeActivityClass;
EventBus.getDefault().post(message, APPMANAGER_MESSAGE);
}
示例10: onDestroy
import org.simple.eventbus.EventBus; //导入依赖的package包/类
@Override
public void onDestroy() {
super.onDestroy();
EventBus.getDefault().unregister(this);
unDisposeAll();
this.mCompositeDisposable = null;
}
示例11: onCreate
import org.simple.eventbus.EventBus; //导入依赖的package包/类
public void onCreate(Bundle savedInstanceState) {
if (iActivity.useEventBus())//如果要使用eventbus请将此方法返回true
EventBus.getDefault().register(mActivity);//注册到事件主线
iActivity.setupActivityComponent(((App) mActivity.getApplication()).getAppComponent());//依赖注入
try {
int layoutResID = iActivity.initView();
if (layoutResID != 0)//如果initView返回0,框架则不会调用setContentView()
mActivity.setContentView(layoutResID);
} catch (Exception e) {
e.printStackTrace();
}
//绑定到butterknife
mUnbinder = ButterKnife.bind(mActivity);
iActivity.initData();
}
示例12: onDestroy
import org.simple.eventbus.EventBus; //导入依赖的package包/类
@Override
public void onDestroy() {
if (useEventBus())//如果要使用eventbus请将此方法返回true
EventBus.getDefault().unregister(this);//解除注册eventbus
unSubscribe();//解除订阅
if (mModel != null) {
mModel.onDestroy();
this.mModel = null;
}
this.mRootView = null;
this.mCompositeSubscription = null;
}
示例13: onDestroy
import org.simple.eventbus.EventBus; //导入依赖的package包/类
@Override
protected void onDestroy() {
super.onDestroy();
mApplication.getAppManager().removeActivity(this);
if (mPresenter != null) mPresenter.onDestroy();//释放资源
if (mUnbinder != Unbinder.EMPTY) mUnbinder.unbind();
if (useEventBus())//如果要使用eventbus请将此方法返回true
EventBus.getDefault().unregister(this);
this.mPresenter = null;
this.mUnbinder = null;
this.mApplication = null;
}
示例14: onCreate
import org.simple.eventbus.EventBus; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
photo_id = getArguments().getInt("photo_id");
mProduct = (PhotoDetails.Product) getArguments().getSerializable("mProduct");
EventBus.getDefault().register(this);
}
示例15: release
import org.simple.eventbus.EventBus; //导入依赖的package包/类
/**
* 释放资源
*/
public void release() {
EventBus.getDefault().unregister(this);
mActivityList.clear();
mActivityList = null;
mCurrentActivity = null;
mApplication = null;
}