本文整理汇总了Java中com.squareup.otto.Subscribe类的典型用法代码示例。如果您正苦于以下问题:Java Subscribe类的具体用法?Java Subscribe怎么用?Java Subscribe使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Subscribe类属于com.squareup.otto包,在下文中一共展示了Subscribe类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onGetInactivePhotos
import com.squareup.otto.Subscribe; //导入依赖的package包/类
@Subscribe
public void onGetInactivePhotos(OnGetInactivePhotosEvent event) {
handler.post(new Runnable() {
@Override
public void run() {
List<MyPhoto> list = new ArrayList<>();
if (event != null) {
for (Photo p : event.photos) {
MyPhoto photo = new MyPhoto(p);
list.add(photo);
}
adapter.setData(list);
adapter.notifyDataSetChanged();
}
}
});
}
示例2: onWSTrafficEvent
import com.squareup.otto.Subscribe; //导入依赖的package包/类
@Subscribe
public void onWSTrafficEvent(WSConnectionManager.WSTrafficEvent event) {
boolean shouldRefresh = false;
if (event.isSlowConnection()) {
if (isWSTrafficSlow.compareAndSet(false, true)) {
shouldRefresh = true;
showToast("Bad Connection: " + event.getMessage() + "!");
}
} else {
if (isWSTrafficSlow.compareAndSet(true, false)) {
shouldRefresh = true;
}
}
if (shouldRefresh) {
refresh();
}
}
示例3: onOauthResult
import com.squareup.otto.Subscribe; //导入依赖的package包/类
@Subscribe
public void onOauthResult(SSOBusEvent event) {
switch (event.getType()) {
case SSOBusEvent.TYPE_GET_TOKEN:
SocialToken token = event.getToken();
Log.i(TAG, "onOauthResult#BusEvent.TYPE_GET_TOKEN " + token.toString());
break;
case SSOBusEvent.TYPE_GET_USER:
SocialUser user = event.getUser();
Log.i(TAG, "onOauthResult#BusEvent.TYPE_GET_USER " + user.toString());
Toast.makeText(SsoAllActivity.this, "ShareBusEvent.TYPE_GET_USER \n\r" + user.toString(), Toast.LENGTH_SHORT).show();
break;
case SSOBusEvent.TYPE_FAILURE:
Exception e = event.getException();
Log.i(TAG, "onOauthResult#BusEvent.TYPE_FAILURE " + e.toString());
break;
case SSOBusEvent.TYPE_CANCEL:
Log.i(TAG, "onOauthResult#BusEvent.TYPE_CANCEL");
break;
}
}
示例4: onOauthResult
import com.squareup.otto.Subscribe; //导入依赖的package包/类
@Subscribe
public void onOauthResult(SSOBusEvent event) {
switch (event.getType()) {
case SSOBusEvent.TYPE_GET_TOKEN:
SocialToken token = event.getToken();
Log.i(TAG, "onOauthResult#BusEvent.TYPE_GET_TOKEN " + token.toString());
break;
case SSOBusEvent.TYPE_GET_USER:
SocialUser user = event.getUser();
Log.i(TAG, "onOauthResult#BusEvent.TYPE_GET_USER " + user.toString());
break;
case SSOBusEvent.TYPE_FAILURE:
Exception e = event.getException();
Log.i(TAG, "onOauthResult#BusEvent.TYPE_FAILURE " + e.toString());
break;
case SSOBusEvent.TYPE_CANCEL:
Log.i(TAG, "onOauthResult#BusEvent.TYPE_CANCEL");
break;
}
}
示例5: onPokemonListReceived
import com.squareup.otto.Subscribe; //导入依赖的package包/类
@Subscribe
public void onPokemonListReceived(PokemonList pokemonList) {
/*
Both GetPokemonListUseCase invocations end here, either we requested the first page
or every next page
*/
if (totalPokemon == 0) {
// First time hide the screen loading
screen.hideLoading();
} else {
// Every next time we remove the bottom list loading progress
loadingNewPage = false;
screen.hideListLoading();
}
// Adding the fetched data to the RecyclerView
screen.addToPokemonList(pokemonList.getPokemonList());
// We need these variables for infinite scrolling
lastPageSize = pokemonList.getPageSize();
totalPokemon += lastPageSize;
nextPageLink = pokemonList.getNextLink();
}
示例6: onPokemonListError
import com.squareup.otto.Subscribe; //导入依赖的package包/类
@Subscribe
public void onPokemonListError(PokemonListError error) {
// Both GetPokemonListUseCase invocations end here
// Hiding the appropriate loading progress
if (totalPokemon == 0) {
screen.hideLoading();
screen.showNoInternetPanel();
} else {
loadingNewPage = false;
screen.hideListLoading();
// Showing the appropriate dialog
if (error.isNetworkError()) {
screen.showNoInternetError();
} else {
screen.showError(error);
}
}
}
示例7: setSubscriber
import com.squareup.otto.Subscribe; //导入依赖的package包/类
@Override
protected Object setSubscriber() {
return new Object() {
@Subscribe
public void onPokemonListReceived(PokemonList pokemonList) {
// Just post back the response and unregister the listener
post(pokemonList);
unregisterUseCaseSubscriber();
}
@Subscribe
public void onPokemonListError(PokemonListError error) {
// Just post back the error and unregister the listener
post(error);
unregisterUseCaseSubscriber();
}
};
}
示例8: setSubscriber
import com.squareup.otto.Subscribe; //导入依赖的package包/类
@Override
protected Object setSubscriber() {
return new Object() {
@Subscribe
public void onPokemonDetailsReceived(PokemonDetails details) {
// Save the data to the cache
dataCache.addPokemonDetails(details);
// Post it back to the PokemonDetailsPresenter
post(details);
// No need for the subscriber anymore
unregisterUseCaseSubscriber();
}
@Subscribe
public void onPokemonDetailsError(PokemonDetailsError error) {
// Post the error back to the PokemonDetailsPresenter
post(error);
// No need for the subscriber anymore
unregisterUseCaseSubscriber();
}
};
}
示例9: onDeletePostEvent
import com.squareup.otto.Subscribe; //导入依赖的package包/类
@Subscribe
public void onDeletePostEvent(DeletePostEvent event) {
String postId = event.post.getId();
Log.i(TAG, "[onDeletePostEvent] post id = %s", postId);
Post realmPost = mRealm.where(Post.class).equalTo("id", postId).findFirst();
if (realmPost == null) {
RuntimeException e = new IllegalArgumentException("Trying to delete post with non-existent id = " + postId);
Log.exception(e);
} else if (realmPost.hasPendingAction(PendingAction.CREATE)) {
deleteModel(realmPost);
getBus().post(new PostDeletedEvent(postId));
} else {
// don't delete locally until the remote copy is deleted
clearAndSetPendingActionOnPost(realmPost, PendingAction.DELETE);
getBus().post(new PostDeletedEvent(postId));
// DON'T trigger a sync here, because it is automatically triggered by the post list anyway
// triggering it twice causes crashes due to invalid Realm objects (deleted twice)
//getBus().post(new SyncPostsEvent(false));
}
}
示例10: onFileUploadErrorEvent
import com.squareup.otto.Subscribe; //导入依赖的package包/类
@Subscribe
public void onFileUploadErrorEvent(FileUploadErrorEvent event) {
if (event.apiFailure.error != null) {
Log.exception(new FileUploadFailedException(event.apiFailure.error));
} else if (event.apiFailure.response != null) {
try {
String responseStr = event.apiFailure.response.errorBody().string();
Log.exception(new FileUploadFailedException(responseStr));
} catch (IOException e) {
Log.exception(new Exception("Error while recording file upload exception, " +
"see previous exception for details", e));
}
}
Toast.makeText(mActivity, R.string.image_upload_failed, Toast.LENGTH_SHORT).show();
// the activity could have been destroyed and re-created
if (mUploadProgress != null) {
mUploadProgress.dismiss();
mUploadProgress = null;
}
mImageUploadDoneAction = null;
mMarkdownEditSelectionState = null;
}
示例11: onUserLoadedEvent
import com.squareup.otto.Subscribe; //导入依赖的package包/类
@Subscribe
public void onUserLoadedEvent(UserLoadedEvent event) {
if (event.user.getProfileImage() != null) {
if (event.user.getProfileImage().isEmpty()) {
return;
}
String blogUrl = AccountManager.getActiveBlogUrl();
String imageUrl = NetworkUtils.makeAbsoluteUrl(blogUrl, event.user.getProfileImage());
getPicasso()
.load(imageUrl)
.transform(new BorderedCircleTransformation())
.fit()
.into(mUserImageView);
} else {
// Crashlytics issue #77
Log.w(TAG, "user image is null!");
}
}
示例12: onPostsLoadedEvent
import com.squareup.otto.Subscribe; //导入依赖的package包/类
@Subscribe
public void onPostsLoadedEvent(PostsLoadedEvent event) {
// this exists to let animation run to completion because posts are loaded
// twice on launch: once cached data, and once from the network
if (mPosts.equals(event.posts)) {
return;
}
mPosts.clear();
mPosts.addAll(event.posts);
if (mPosts.size() >= event.postsFetchLimit) {
CharSequence message = Html.fromHtml(getString(R.string.post_limit_exceeded,
getString(R.string.app_name), event.postsFetchLimit,
"https://github.com/vickychijwani/quill/issues/81"));
mPostAdapter.showFooter(message);
} else {
mPostAdapter.hideFooter();
}
mPostAdapter.notifyDataSetChanged();
}
示例13: onLogoutStatusEvent
import com.squareup.otto.Subscribe; //导入依赖的package包/类
@Subscribe
public void onLogoutStatusEvent(LogoutStatusEvent event) {
if (!event.succeeded && event.hasPendingActions) {
final AlertDialog alertDialog = new AlertDialog.Builder(this)
.setMessage(getString(R.string.unsynced_changes_msg))
.setPositiveButton(R.string.dont_logout, (dialog, which) -> {
dialog.dismiss();
})
.setNegativeButton(R.string.logout, (dialog, which) -> {
dialog.dismiss();
getBus().post(new LogoutEvent(AccountManager.getActiveBlogUrl(), true));
})
.create();
alertDialog.show();
} else {
finish();
Intent logoutIntent = new Intent(this, LoginActivity.class);
startActivity(logoutIntent);
}
}
示例14: onPostSyncedEvent
import com.squareup.otto.Subscribe; //导入依赖的package包/类
@Subscribe
public void onPostSyncedEvent(PostSyncedEvent event) {
if (event.post != null && event.post.getId().equals(mPost.getId())) {
// Use the synced post, as the server could have modified it (e.g., if the slug clashes).
// Since syncing happens *asynchronously* (relative to the time the SavePostEvent was
// fired), using unsafeUpdatePost() WILL overwrite the user's edits! So, update the
// existing post with whatever properties *could* have been updated by the server *and*
// are NOT user-modifiable. The change will automatically propagate to the editor and
// other fragments because they share the object reference directly.
mPost.setSlug(event.post.getSlug());
if (mbPreviewPost) {
mHandler.removeCallbacks(mSaveTimeoutRunnable);
startBrowserActivity(PostUtils.getPostUrl(mPost));
if (mProgressDialog != null) {
mProgressDialog.dismiss();
}
mbPreviewPost = false;
}
}
}
示例15: postCommentLike
import com.squareup.otto.Subscribe; //导入依赖的package包/类
@Subscribe
public void postCommentLike(Account.sendCommentLike sendReply) throws Exception {
application.getWebService()
.sendCommentLike(sendReply.id_post_comment, MySharedPreferences.getUserId(preferences), "1",MySharedPreferences.getUserId(preferences), MySharedPreferences.getUserToken(preferences), sendReply.id_post_comment)
.observeOn(AndroidSchedulers.mainThread())
.retryWhen(new RetryWithDelay(3,2000))
.subscribe(new BaseSubscriber<SuccessResponse>() {
@Override
public void onNext(SuccessResponse userResponse) {
// Send notification to user with id_user_name ID
// Toast.makeText(PostsDetailsActivity.this, "success comment like", Toast.LENGTH_SHORT).show();
}
@Override
public void onError(Throwable e) {
Crashlytics.logException(e);
}
});
}