Search in sources :

Example 16 with Subscribe

use of org.greenrobot.eventbus.Subscribe in project WordPress-Android by wordpress-mobile.

the class WordPress method onAccountChanged.

@SuppressWarnings("unused")
@Subscribe(threadMode = ThreadMode.MAIN)
public void onAccountChanged(OnAccountChanged event) {
    if (!FluxCUtils.isSignedInWPComOrHasWPOrgSite(mAccountStore, mSiteStore)) {
        flushHttpCache();
        // Analytics resets
        AnalyticsTracker.endSession(false);
        AnalyticsTracker.clearAllData();
        // disable passcode lock
        AbstractAppLock appLock = AppLockManager.getInstance().getAppLock();
        if (appLock != null) {
            appLock.setPassword(null);
        }
    }
}
Also used : AbstractAppLock(org.wordpress.passcodelock.AbstractAppLock) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 17 with Subscribe

use of org.greenrobot.eventbus.Subscribe in project WordPress-Android by wordpress-mobile.

the class CommentDetailFragment method onCommentChanged.

// OnChanged events
@SuppressWarnings("unused")
@Subscribe(threadMode = ThreadMode.MAIN)
public void onCommentChanged(OnCommentChanged event) {
    setProgressVisible(false);
    // Moderating comment
    if (event.causeOfChange == CommentAction.PUSH_COMMENT) {
        onCommentModerated(event);
        mPreviousStatus = null;
        return;
    }
    // New comment (reply)
    if (event.causeOfChange == CommentAction.CREATE_NEW_COMMENT) {
        onCommentCreated(event);
        return;
    }
    // Like/Unlike
    if (event.causeOfChange == CommentAction.LIKE_COMMENT) {
        onCommentLiked(event);
        return;
    }
    if (event.isError()) {
        AppLog.i(T.TESTS, "event error type: " + event.error.type + " - message: " + event.error.message);
        if (isAdded() && !TextUtils.isEmpty(event.error.message)) {
            ToastUtils.showToast(getActivity(), event.error.message);
        }
        return;
    }
    if (mCommentIdToFetch != 0) {
        CommentModel comment = mCommentStore.getCommentBySiteAndRemoteId(mSite, mCommentIdToFetch);
        setComment(comment, mSite);
        mCommentIdToFetch = 0;
    }
}
Also used : CommentModel(org.wordpress.android.fluxc.model.CommentModel) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 18 with Subscribe

use of org.greenrobot.eventbus.Subscribe in project WordPress-Android by wordpress-mobile.

the class NewBlogFragment method onSiteChanged.

@SuppressWarnings("unused")
@Subscribe(threadMode = ThreadMode.MAIN)
public void onSiteChanged(OnSiteChanged event) {
    AppLog.i(T.NUX, event.toString());
    // Sites updated, we can finish this.
    if (getActivity() == null) {
        return;
    }
    endProgress();
    Intent intent = new Intent();
    SiteModel site = mSiteStore.getSiteBySiteId(mNewSiteRemoteId);
    intent.putExtra(SitePickerActivity.KEY_LOCAL_ID, site.getId());
    getActivity().setResult(Activity.RESULT_OK, intent);
    getActivity().finish();
}
Also used : Intent(android.content.Intent) SiteModel(org.wordpress.android.fluxc.model.SiteModel) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 19 with Subscribe

use of org.greenrobot.eventbus.Subscribe in project WordPress-Android by wordpress-mobile.

the class SignInFragment method onDiscoverySucceeded.

@SuppressWarnings("unused")
@Subscribe(threadMode = ThreadMode.MAIN)
public void onDiscoverySucceeded(OnDiscoveryResponse event) {
    if (event.isError()) {
        AppLog.e(T.API, "onDiscoveryResponse has error: " + event.error.name() + " - " + event.error.toString());
        handleDiscoveryError(event.error, event.failedEndpoint);
        return;
    }
    AppLog.i(T.NUX, "Discovery succeeded, endpoint: " + event.xmlRpcEndpoint);
    RefreshSitesXMLRPCPayload selfhostedPayload = new RefreshSitesXMLRPCPayload();
    selfhostedPayload.username = mUsername;
    selfhostedPayload.password = mPassword;
    selfhostedPayload.url = event.xmlRpcEndpoint;
    mDispatcher.dispatch(SiteActionBuilder.newFetchSitesXmlRpcAction(selfhostedPayload));
}
Also used : RefreshSitesXMLRPCPayload(org.wordpress.android.fluxc.store.SiteStore.RefreshSitesXMLRPCPayload) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 20 with Subscribe

use of org.greenrobot.eventbus.Subscribe in project WordPress-Android by wordpress-mobile.

the class MediaGalleryPickerActivity method onMediaListFetched.

@SuppressWarnings("unused")
@Subscribe(threadMode = ThreadMode.MAIN)
public void onMediaListFetched(OnMediaListFetched event) {
    mIsFetching = false;
    if (event.isError()) {
        mHasRetrievedAllMedia = true;
        mGridAdapter.setHasRetrievedAll(true);
        String message = null;
        switch(event.error.type) {
            case GENERIC_ERROR:
                message = getString(R.string.error_refresh_media);
                break;
        }
        if (message != null) {
            Toast.makeText(MediaGalleryPickerActivity.this, message, Toast.LENGTH_SHORT).show();
        }
    } else {
        mHasRetrievedAllMedia = !event.canLoadMore;
        mGridAdapter.setHasRetrievedAll(mHasRetrievedAllMedia);
        if (mMediaStore.getSiteMediaCount(mSite) == 0 && mHasRetrievedAllMedia) {
            // There is no media at all
            noMediaFinish();
        }
        // the activity may be gone by the time this finishes, so check for it
        if (!isFinishing()) {
            if (mFilteredItems != null && !mFilteredItems.isEmpty()) {
                Cursor cursor = mMediaStore.getSiteImagesExcludingIdsAsCursor(mSite, mFilteredItems);
                mGridAdapter.setCursor(cursor);
            } else {
                Cursor cursor = mMediaStore.getSiteImagesAsCursor(mSite);
                mGridAdapter.setCursor(cursor);
            }
        }
    }
}
Also used : Cursor(android.database.Cursor) 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