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);
}
}
}
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;
}
}
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();
}
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));
}
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);
}
}
}
}
Aggregations