Search in sources :

Example 1 with RunReplayBundleResponse

use of jota.dto.response.RunReplayBundleResponse in project run-wallet-android by runplay.

the class ReplayBundleRequestHandler method handle.

@Override
public ApiResponse handle(ApiRequest request) {
    ApiResponse response;
    int notificationId = Utils.createNewID();
    // NotificationHelper.requestNotification(context, R.drawable.send_white, context.getString(R.string.notification_replay_bundle_request_title), notificationId);
    if (Store.getNodeInfo() == null) {
        NodeInfoRequestHandler.getNodeInfo(apiProxy, context);
    }
    try {
        RunReplayBundleResponse jresponse = apiProxy.replayBundle(((ReplayBundleRequest) request).getHash(), ((ReplayBundleRequest) request).getDepth(), ((ReplayBundleRequest) request).getMinWeightMagnitude());
        response = new ReplayBundleResponse(context, ((ReplayBundleRequest) request).getSeed(), jresponse);
    } catch (ArgumentException e) {
        NetworkError error = new NetworkError();
        error.setErrorType(NetworkErrorType.INVALID_HASH_ERROR);
        response = error;
    }
    if (!AppService.isAppStarted()) {
        if (response instanceof ReplayBundleResponse && Arrays.asList(((ReplayBundleResponse) response).getSuccessfully()).contains(true)) {
            NotificationHelper.responseNotification(context, R.drawable.ic_replay, context.getString(R.string.notification_replay_bundle_response_succeeded_title), notificationId);
        } else if (response instanceof NetworkError) {
            NotificationHelper.responseNotification(context, R.drawable.ic_replay, context.getString(R.string.notification_replay_bundle_response_failed_title), notificationId);
        }
    } else {
        NotificationHelper.vibrate(context);
    }
    return response;
}
Also used : ReplayBundleResponse(run.wallet.iota.api.responses.ReplayBundleResponse) RunReplayBundleResponse(jota.dto.response.RunReplayBundleResponse) ReplayBundleRequest(run.wallet.iota.api.requests.ReplayBundleRequest) NetworkError(run.wallet.iota.api.responses.error.NetworkError) ArgumentException(jota.error.ArgumentException) RunReplayBundleResponse(jota.dto.response.RunReplayBundleResponse) ApiResponse(run.wallet.iota.api.responses.ApiResponse)

Aggregations

RunReplayBundleResponse (jota.dto.response.RunReplayBundleResponse)1 ArgumentException (jota.error.ArgumentException)1 ReplayBundleRequest (run.wallet.iota.api.requests.ReplayBundleRequest)1 ApiResponse (run.wallet.iota.api.responses.ApiResponse)1 ReplayBundleResponse (run.wallet.iota.api.responses.ReplayBundleResponse)1 NetworkError (run.wallet.iota.api.responses.error.NetworkError)1