use of me.zhanghai.android.douya.network.api.ApiError in project Douya by DreaminginCodeZH.
the class RebroadcastBroadcastWriter method onErrorResponse.
@Override
public void onErrorResponse(VolleyError error) {
LogUtils.e(error.toString());
Context context = getContext();
ToastUtils.show(context.getString(mRebroadcast ? R.string.broadcast_rebroadcast_failed_format : R.string.broadcast_unrebroadcast_failed_format, ApiError.getErrorString(error, context)), context);
boolean notified = false;
if (mBroadcast != null && error instanceof ApiError) {
// Correct our local state if needed.
ApiError apiError = (ApiError) error;
Boolean shouldBeRebroadcasted = null;
if (apiError.code == Codes.RebroadcastBroadcast.ALREADY_REBROADCASTED) {
shouldBeRebroadcasted = true;
} else if (apiError.code == Codes.RebroadcastBroadcast.NOT_REBROADCASTED_YET) {
shouldBeRebroadcasted = false;
}
if (shouldBeRebroadcasted != null) {
mBroadcast.fixRebroadcasted(shouldBeRebroadcasted);
EventBusUtils.postAsync(new BroadcastUpdatedEvent(mBroadcast, this));
notified = true;
}
}
if (!notified) {
// Must notify to reset pending status. Off-screen items also needs to be invalidated.
EventBusUtils.postAsync(new BroadcastWriteFinishedEvent(mBroadcastId, this));
}
stopSelf();
}
use of me.zhanghai.android.douya.network.api.ApiError in project Douya by DreaminginCodeZH.
the class FollowUserWriter method onErrorResponse.
@Override
public void onErrorResponse(VolleyError error) {
LogUtils.e(error.toString());
Context context = getContext();
ToastUtils.show(context.getString(mFollow ? R.string.user_follow_failed_format : R.string.user_unfollow_failed_format, ApiError.getErrorString(error, context)), context);
boolean notified = false;
if (mUser != null && error instanceof ApiError) {
// Correct our local state if needed.
ApiError apiError = (ApiError) error;
Boolean shouldBeFollowed = null;
if (apiError.code == Codes.Followship.ALREADY_FOLLOWED) {
shouldBeFollowed = true;
} else if (apiError.code == Codes.Followship.NOT_FOLLOWED_YET) {
shouldBeFollowed = false;
}
if (shouldBeFollowed != null) {
mUser.fixFollowed(shouldBeFollowed);
EventBusUtils.postAsync(new UserUpdatedEvent(mUser, this));
notified = true;
}
}
if (!notified) {
// Must notify to reset pending status. Off-screen items also needs to be invalidated.
EventBusUtils.postAsync(new UserWriteFinishedEvent(mUserIdOrUid, this));
}
stopSelf();
}
use of me.zhanghai.android.douya.network.api.ApiError in project Douya by DreaminginCodeZH.
the class LikeBroadcastWriter method onErrorResponse.
@Override
public void onErrorResponse(VolleyError error) {
LogUtils.e(error.toString());
Context context = getContext();
ToastUtils.show(context.getString(mLike ? R.string.broadcast_like_failed_format : R.string.broadcast_unlike_failed_format, ApiError.getErrorString(error, context)), context);
boolean notified = false;
if (mBroadcast != null && error instanceof ApiError) {
// Correct our local state if needed.
ApiError apiError = (ApiError) error;
Boolean shouldBeLiked = null;
if (apiError.code == Codes.LikeBroadcast.ALREADY_LIKED) {
shouldBeLiked = true;
} else if (apiError.code == Codes.LikeBroadcast.NOT_LIKED_YET) {
shouldBeLiked = false;
}
if (shouldBeLiked != null) {
mBroadcast.fixLiked(shouldBeLiked);
EventBusUtils.postAsync(new BroadcastUpdatedEvent(mBroadcast, this));
notified = true;
}
}
if (!notified) {
// Must notify to reset pending status. Off-screen items also needs to be invalidated.
EventBusUtils.postAsync(new BroadcastWriteFinishedEvent(mBroadcastId, this));
}
stopSelf();
}
Aggregations