本文整理汇总了Java中de.greenrobot.event.EventBus类的典型用法代码示例。如果您正苦于以下问题:Java EventBus类的具体用法?Java EventBus怎么用?Java EventBus使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EventBus类属于de.greenrobot.event包,在下文中一共展示了EventBus类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addFavorite
import de.greenrobot.event.EventBus; //导入依赖的package包/类
private void addFavorite(String code, final MenuItem item) {
showLoading();
item.setEnabled(false);
FoodApi.addFavorite(code, this.activity, new JsonCallback(this.activity) {
public void ok(JSONObject object) {
super.ok(object);
item.setTitle(R.string.ia);
item.setIcon(R.drawable.a3a);
EventBus.getDefault().post(new FoodCollectEvent().setIsCollect(true));
}
public void onFinish() {
super.onFinish();
FoodDetailActivity.this.dismissLoading();
if (item != null) {
item.setEnabled(true);
}
}
});
}
示例2: onEventMainThread
import de.greenrobot.event.EventBus; //导入依赖的package包/类
public void onEventMainThread(RefreshDietEvent refreshDietEvent) {
RecordApi.getEatings(this.record_on, this, new JsonCallback(this) {
public void ok(JSONObject object) {
super.ok(object);
List<RecordFood> recordFoods = FastJsonUtils.parseList(object.optString("data"),
RecordFood.class);
List<RecordPhoto> recordPhotos = FastJsonUtils.parseList(object.optString
("diet_photos"), RecordPhoto.class);
DietSportCalendarActivity.this.clearDietList();
DietSportCalendarActivity.this.initDietUI(recordFoods, recordPhotos);
EventBus.getDefault().post(new RefreshCalorieEvent(recordFoods, recordPhotos));
}
public void onFinish() {
super.onFinish();
}
});
}
示例3: onLocalLoginOk
import de.greenrobot.event.EventBus; //导入依赖的package包/类
/**
* 1. 加载本地信息
* 2. 请求正规群信息 , 与本地进行对比
* 3. version groupId 请求
* */
public void onLocalLoginOk(){
logger.i("group#loadFromDb");
if(!EventBus.getDefault().isRegistered(inst)){
EventBus.getDefault().registerSticky(inst);
}
// 加载本地group
List<GroupEntity> localGroupInfoList = dbInterface.loadAllGroup();
for(GroupEntity groupInfo:localGroupInfoList){
groupMap.put(groupInfo.getPeerId(),groupInfo);
}
triggerEvent(new GroupEvent(GroupEvent.Event.GROUP_INFO_OK));
}
示例4: updateActivity
import de.greenrobot.event.EventBus; //导入依赖的package包/类
private void updateActivity() {
showLoading();
RecordApi.updateCustomActivity(this.mRecordSport, getActivity(), new JsonCallback
(getActivity()) {
public void ok(JSONObject object) {
super.ok(object);
AddCustomSportFragment.this.dismissAllowingStateLoss();
if (AddCustomSportFragment.this.mRecordSport != null) {
EventBus.getDefault().post(new SportEvent().setRecordSport
(AddCustomSportFragment.this.mRecordSport).setEditType(1));
}
}
public void onFinish() {
super.onFinish();
AddCustomSportFragment.this.dismissLoading();
}
});
}
示例5: recordMc
import de.greenrobot.event.EventBus; //导入依赖的package包/类
private void recordMc(String action, Date day) {
if (day != null) {
JsonParams params = new JsonParams();
params.put("record_on", DateHelper.format(day));
if (McLatest.ACTION_START.equals(action)) {
params.put("mc_status", "1");
} else if (McLatest.ACTION_END.equals(action)) {
params.put("mc_status", "2");
}
RecordApi.postMcRecords(this.activity, params, new JsonCallback(this.activity) {
public void ok(JSONObject object) {
super.ok(object);
if (!PeriodCalendarActivity.this.isFinishing()) {
PeriodCalendarActivity.this.requestRecords();
PeriodCalendarActivity.this.setResult(-1);
EventBus.getDefault().post(new PeriodEvent());
MobclickAgent.onEvent(PeriodCalendarActivity.this.ctx, Event
.tool_updateMcRecordOK);
MobclickAgent.onEvent(PeriodCalendarActivity.this.ctx, Event.tool_recordOK);
}
}
});
}
}
示例6: onCreate
import de.greenrobot.event.EventBus; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
logger.d("MainActivity#savedInstanceState:%s", savedInstanceState);
//todo eric when crash, this will be called, why?
if (savedInstanceState != null) {
logger.w("MainActivity#crashed and restarted, just exit");
jumpToLoginPage();
finish();
}
// 在这个地方加可能会有问题吧
EventBus.getDefault().register(this);
imServiceConnector.connect(this);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.tt_activity_main);
initTab();
initFragment();
setFragmentIndicator(0);
}
示例7: execute
import de.greenrobot.event.EventBus; //导入依赖的package包/类
@Override
public void execute() throws Throwable {
RestAdapter restAdapter = new RestAdapter.Builder().setEndpoint(context.getString(R.string.weather_url)).build();
Apis apis = restAdapter.create(Apis.class);
apis.getWeatherData(6359304, Locale.getDefault().getLanguage(), "metric", "43cd5e05d25e37bdffbad27e42619e3f", new Callback<WeatherResponse>() {
@Override
public void success(WeatherResponse weatherResponse, Response response) {
EventBus.getDefault().post(weatherResponse);
}
@Override
public void failure(RetrofitError error) {
EventBus.getDefault().post(new WeatherResponse());
}
});
}
示例8: deleteActivity
import de.greenrobot.event.EventBus; //导入依赖的package包/类
private void deleteActivity() {
if (HttpUtils.isNetworkAvailable(getActivity())) {
showLoading();
RecordApi.deleteActivity(this.mRecordSport.id, getActivity(), new JsonCallback
(getActivity()) {
public void ok(JSONObject object) {
super.ok(object);
EventBus.getDefault().post(new SportEvent().setIndex(AddSportFragment.this
.mIndex).setEditType(3));
AddSportFragment.this.dismissAllowingStateLoss();
}
public void onFinish() {
super.onFinish();
AddSportFragment.this.dismissLoading();
}
});
return;
}
new SportRecordDao(getActivity()).delete(this.mRecordSport);
dismissAllowingStateLoss();
EventBus.getDefault().post(new SportEvent().setIndex(this.mIndex).setEditType(3));
}
示例9: deleteActivity
import de.greenrobot.event.EventBus; //导入依赖的package包/类
private void deleteActivity() {
showLoading();
RecordApi.deleteActivity(this.mRecordSport.id, getActivity(), new JsonCallback
(getActivity()) {
public void ok(JSONObject object) {
super.ok(object);
AddCustomSportFragment.this.dismissAllowingStateLoss();
if (AddCustomSportFragment.this.mRecordSport != null) {
EventBus.getDefault().post(new SportEvent().setIndex(AddCustomSportFragment
.this.mIndex).setRecordSport(AddCustomSportFragment.this
.mRecordSport).setEditType(3));
}
}
public void onFinish() {
super.onFinish();
AddCustomSportFragment.this.dismissLoading();
}
});
}
示例10: deletePhotoEating
import de.greenrobot.event.EventBus; //导入依赖的package包/类
private void deletePhotoEating() {
if (this.mRecordPhoto != null) {
showLoading();
RecordApi.deleteDietPhotos(this.activity, this.mRecordPhoto.id, new JsonCallback(this
.activity) {
public void ok(JSONObject object) {
super.ok(object);
if (EditCameraRecordActivity.this.mRecordPhoto != null) {
EventBus.getDefault().post(new PhotoDietEvent().setTimeType
(EditCameraRecordActivity.this.mRecordPhoto.time_type).setIndex
(EditCameraRecordActivity.this.mIndex).setEditType(3));
EditCameraRecordActivity.this.finish();
}
}
public void onFinish() {
super.onFinish();
EditCameraRecordActivity.this.dismissLoading();
}
});
}
}
示例11: syncAllEatings
import de.greenrobot.event.EventBus; //导入依赖的package包/类
public static void syncAllEatings() {
if (HttpUtils.isNetworkAvailable(MyApplication.getContext())) {
final FoodRecordDao dao = new FoodRecordDao(MyApplication.getContext());
List<RecordFood> records = dao.getList();
if (records != null && records.size() != 0) {
RecordApi.batchCreateEatings(records, MyApplication.getContext(), new
JsonCallback(MyApplication.getContext()) {
public void ok(JSONObject object) {
super.ok(object);
dao.deleteAll();
EventBus.getDefault().post(new RefreshDietEvent());
}
public void fail(String message) {
}
});
}
}
}
示例12: onCreateView
import de.greenrobot.event.EventBus; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
imServiceConnector.connect(getActivity());
EventBus.getDefault().register(this);
if (null != curView) {
((ViewGroup) curView.getParent()).removeView(curView);
return curView;
}
curView = inflater.inflate(R.layout.tt_fragment_my, topContentView);
initRes();
return curView;
}
示例13: deletePhotoEating
import de.greenrobot.event.EventBus; //导入依赖的package包/类
private void deletePhotoEating(final RecordPhoto recordPhoto, final int index) {
showLoading();
RecordApi.deleteDietPhotos(this.activity, recordPhoto.id, new JsonCallback(this.activity) {
public void ok(JSONObject object) {
super.ok(object);
if (recordPhoto != null) {
EventBus.getDefault().post(new PhotoDietEvent().setTimeType(recordPhoto
.time_type).setIndex(index).setEditType(3));
FoodListActivity.this.initView();
FoodListActivity.this.refreshTotal();
}
}
public void onFinish() {
super.onFinish();
FoodListActivity.this.dismissLoading();
}
});
}
示例14: onCreate
import de.greenrobot.event.EventBus; //导入依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
initListeners();
ButterKnife.bind(this);
initviews();
initUser();
EventBus.getDefault().register(this);
if (Shared.getUserInfo() != null)
messageLogin();
//Shared.saveCookie("JSESSIONID=BC167CAE0D37C231FD75CB3CC030E6FF");
Log.i("lin", "----lin----> + getCookie " + Shared.getCookie());
//KLog.i("----ooo----> uid"+ Shared.getUserInfo().getUid());
}
示例15: updateEating
import de.greenrobot.event.EventBus; //导入依赖的package包/类
private void updateEating() {
showLoading();
RecordApi.updateEating(this.mRecordFood.id, paramsWithFoodRecord(), getActivity(), new
JsonCallback(getActivity()) {
public void ok(JSONObject object) {
super.ok(object);
AddCustomDietFragment.this.dismissLoading();
AddCustomDietFragment.this.dismissAllowingStateLoss();
RecordFood recordFood = (RecordFood) FastJsonUtils.fromJson(object, RecordFood
.class);
if (recordFood != null) {
EventBus.getDefault().post(new TimeTypeDietEvent().setBeforeTimeType
(AddCustomDietFragment.this.mRecordFood.time_type).setRecordFood
(recordFood).setIndex(AddCustomDietFragment.this.mIndex));
}
}
public void onFinish() {
super.onFinish();
AddCustomDietFragment.this.dismissLoading();
}
});
}