use of im.actor.core.network.RpcException in project actor-platform by actorapp.
the class CursorReceiverActor method perform.
@Override
protected void perform(final Peer peer, final long date) {
ApiOutPeer outPeer = buidOutPeer(peer);
if (outPeer == null) {
return;
}
request(new RequestMessageReceived(outPeer, date), new RpcCallback<ResponseVoid>() {
@Override
public void onResult(ResponseVoid response) {
onCompleted(peer, date);
}
@Override
public void onError(RpcException e) {
CursorReceiverActor.this.onError(peer, date);
}
});
}
use of im.actor.core.network.RpcException in project actor-platform by actorapp.
the class OwnAvatarChangeActor method removeAvatar.
public void removeAvatar() {
if (currentChangeTask != 0) {
context().getFilesModule().cancelUpload(currentChangeTask);
currentChangeTask = 0;
}
currentChangeTask = RandomUtils.nextRid();
context().getProfileModule().getOwnAvatarVM().getUploadState().change(new AvatarUploadState(null, true));
final long currentRid = currentChangeTask;
request(new RequestRemoveAvatar(), new RpcCallback<ResponseSeq>() {
@Override
public void onResult(ResponseSeq response) {
updates().onUpdateReceived(new SeqUpdate(response.getSeq(), response.getState(), UpdateUserAvatarChanged.HEADER, new UpdateUserAvatarChanged(myUid(), null).toByteArray()));
// After update applied turn of uploading state
updates().onUpdateReceived(new ExecuteAfter(response.getSeq(), () -> self().send(new AvatarChanged(currentRid))));
}
@Override
public void onError(RpcException e) {
if (currentRid != currentChangeTask) {
return;
}
currentChangeTask = 0;
context().getProfileModule().getOwnAvatarVM().getUploadState().change(new AvatarUploadState(null, false));
}
});
}
use of im.actor.core.network.RpcException in project actor-platform by actorapp.
the class ChatFragment method onTextSent.
@Override
public void onTextSent(String sequence) {
if (sequence.trim().length() > 0) {
if (editRid == 0) {
if (currentQuote != null) {
messenger().sendMessage(peer, currentQuote + sequence);
currentQuote = null;
hideQuote();
} else {
messenger().sendMessage(peer, sequence);
}
} else {
messenger().updateMessage(peer, sequence, editRid).failure(e -> {
Activity activity = getActivity();
if (activity != null) {
RpcException re = (RpcException) e;
String error;
if (re.getTag().equals("NOT_IN_TIME_WINDOW")) {
error = getString(R.string.edit_message_error_slowpoke);
} else if (re.getTag().equals("NOT_LAST_MESSAGE")) {
error = getString(R.string.edit_message_error_not_last);
} else {
error = re.getMessage();
}
Toast.makeText(activity, error, Toast.LENGTH_LONG).show();
}
});
editRid = 0;
hideQuote();
}
findInputBar().setText("");
}
}
use of im.actor.core.network.RpcException in project actor-platform by actorapp.
the class Authentication method requestCompleteOauth.
@Deprecated
public Command<AuthState> requestCompleteOauth(final String code) {
return callback -> request(new RequestCompleteOAuth2(modules.getPreferences().getString(KEY_TRANSACTION_HASH), code), new RpcCallback<ResponseAuth>() {
@Override
public void onResult(ResponseAuth response) {
onLoggedIn(callback, response);
}
@Override
public void onError(final RpcException e) {
if ("EMAIL_EXPIRED".equals(e.getTag())) {
resetAuth();
} else if ("EMAIL_UNOCCUPIED".equals(e.getTag())) {
state = AuthState.SIGN_UP;
callback.onResult(AuthState.SIGN_UP);
return;
}
Runtime.postToMainThread(() -> {
Log.e(TAG, e);
callback.onError(e);
});
}
});
}
use of im.actor.core.network.RpcException in project actor-platform by actorapp.
the class I18nEngine method formatErrorText.
@ObjectiveCName("formatErrorTextWithError:")
public String formatErrorText(Object o) {
if (o instanceof RpcException) {
RpcException e = (RpcException) o;
String res = Errors.mapError(e.getTag(), null);
if (res != null) {
return get(res);
} else {
if (e.getMessage().equals("")) {
return e.getTag();
} else {
return e.getMessage();
}
}
} else if (o instanceof Exception) {
return ((Exception) o).getMessage();
} else {
return "" + o;
}
}
Aggregations