Search in sources :

Example 41 with Subscribe

use of org.greenrobot.eventbus.Subscribe in project PhotoNoter by yydcdut.

the class HomePresenterImpl method onCategoryDeleteEvent.

@Subscribe(threadMode = ThreadMode.MAIN)
public void onCategoryDeleteEvent(CategoryDeleteEvent categoryDeleteEvent) {
    mRxCategory.getAllCategories().observeOn(AndroidSchedulers.mainThread()).subscribe(categories -> {
        int beforeCategoryId = mCategoryId;
        for (Category category : categories) {
            if (category.isCheck()) {
                mCategoryId = category.getId();
                break;
            }
        }
        mHomeView.updateCategoryList(categories);
        if (mCategoryId != beforeCategoryId) {
            mHomeView.changePhotos4Category(mCategoryId);
        }
    }, (throwable -> YLog.e(throwable)));
}
Also used : Context(android.content.Context) RxPhotoNote(com.yydcdut.note.model.rx.RxPhotoNote) PhotoNoteDeleteEvent(com.yydcdut.note.bus.PhotoNoteDeleteEvent) AndroidSchedulers(rx.android.schedulers.AndroidSchedulers) Intent(android.content.Intent) RxUser(com.yydcdut.note.model.rx.RxUser) Inject(javax.inject.Inject) CategoryUpdateEvent(com.yydcdut.note.bus.CategoryUpdateEvent) UserImageEvent(com.yydcdut.note.bus.UserImageEvent) Const(com.yydcdut.note.utils.Const) ContextLife(com.yydcdut.note.injector.ContextLife) EventBus(org.greenrobot.eventbus.EventBus) Category(com.yydcdut.note.entity.Category) FilePathUtils(com.yydcdut.note.utils.FilePathUtils) PermissionUtils(com.yydcdut.note.utils.PermissionUtils) RxCategory(com.yydcdut.note.model.rx.RxCategory) CategoryMoveEvent(com.yydcdut.note.bus.CategoryMoveEvent) IHomePresenter(com.yydcdut.note.presenters.home.IHomePresenter) IHomeView(com.yydcdut.note.views.home.IHomeView) PhotoNoteCreateEvent(com.yydcdut.note.bus.PhotoNoteCreateEvent) ThreadMode(org.greenrobot.eventbus.ThreadMode) CategoryEditEvent(com.yydcdut.note.bus.CategoryEditEvent) Subscribe(org.greenrobot.eventbus.Subscribe) Permission(com.yydcdut.note.utils.permission.Permission) ComparatorFactory(com.yydcdut.note.model.compare.ComparatorFactory) ImageLoaderManager(com.yydcdut.note.utils.ImageManager.ImageLoaderManager) CategoryCreateEvent(com.yydcdut.note.bus.CategoryCreateEvent) CategoryDeleteEvent(com.yydcdut.note.bus.CategoryDeleteEvent) AspectPermission(com.yydcdut.note.aspect.permission.AspectPermission) Activity(android.app.Activity) YLog(com.yydcdut.note.utils.YLog) IView(com.yydcdut.note.views.IView) Category(com.yydcdut.note.entity.Category) RxCategory(com.yydcdut.note.model.rx.RxCategory) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 42 with Subscribe

use of org.greenrobot.eventbus.Subscribe in project ride-read-android by Ride-Read.

the class ChatActivity method onEvent.

@Subscribe(threadMode = ThreadMode.MAIN)
public void onEvent(ImTypeMessageEvent event) {
    if (null != imConversation && null != event && imConversation.getConversationId().equals(event.conversation.getConversationId())) {
        if (event.message instanceof AVIMTextMessage) {
            String msg = ((AVIMTextMessage) event.message).getText();
            ChatMessage chatMessage = new ChatMessage(0, R.mipmap.me, menberId, msg, null);
            adapter.addMessage(chatMessage);
            adapter.notifyDataSetChanged();
            chatlist.smoothScrollToPosition(adapter.getCount() - 1);
        }
    }
}
Also used : ChatMessage(com.rideread.rideread.bean.ChatMessage) AVIMTextMessage(com.avos.avoscloud.im.v2.messages.AVIMTextMessage) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 43 with Subscribe

use of org.greenrobot.eventbus.Subscribe in project ride-read-android by Ride-Read.

the class ChatSingleActivity method onResendMsg.

/**
     * 重新发送已经发送失败的消息
     */
@Subscribe(threadMode = MAIN)
public void onResendMsg(ImTypeMsgResendEvent event) {
    if (null != mImConversation && null != event) {
        if (AVIMMessage.AVIMMessageStatus.AVIMMessageStatusFailed == event.message.getMessageStatus() && mImConversation.getConversationId().equals(event.message.getConversationId())) {
            mImConversation.sendMessage(event.message, new AVIMConversationCallback() {

                @Override
                public void done(AVIMException e) {
                    mMsgAdapter.notifyDataSetChanged();
                }
            });
            mMsgAdapter.notifyDataSetChanged();
        }
    }
}
Also used : AVIMConversationCallback(com.avos.avoscloud.im.v2.callback.AVIMConversationCallback) AVIMException(com.avos.avoscloud.im.v2.AVIMException) Subscribe(org.greenrobot.eventbus.Subscribe)

Aggregations

Subscribe (org.greenrobot.eventbus.Subscribe)43 Intent (android.content.Intent)7 SiteModel (org.wordpress.android.fluxc.model.SiteModel)5 NotificationManager (android.app.NotificationManager)3 NotificationCompat (android.support.v4.app.NotificationCompat)3 Activity (android.app.Activity)2 PendingIntent (android.app.PendingIntent)2 Context (android.content.Context)2 Cursor (android.database.Cursor)2 AspectPermission (com.yydcdut.note.aspect.permission.AspectPermission)2 CategoryCreateEvent (com.yydcdut.note.bus.CategoryCreateEvent)2 CategoryDeleteEvent (com.yydcdut.note.bus.CategoryDeleteEvent)2 CategoryEditEvent (com.yydcdut.note.bus.CategoryEditEvent)2 CategoryMoveEvent (com.yydcdut.note.bus.CategoryMoveEvent)2 CategoryUpdateEvent (com.yydcdut.note.bus.CategoryUpdateEvent)2 PhotoNoteCreateEvent (com.yydcdut.note.bus.PhotoNoteCreateEvent)2 PhotoNoteDeleteEvent (com.yydcdut.note.bus.PhotoNoteDeleteEvent)2 UserImageEvent (com.yydcdut.note.bus.UserImageEvent)2 Category (com.yydcdut.note.entity.Category)2 ContextLife (com.yydcdut.note.injector.ContextLife)2