Search in sources :

Example 1 with GetBalanceAndFormatResponse

use of run.wallet.iota.api.responses.GetBalanceAndFormatResponse in project run-wallet-android by runplay.

the class GetBalanceAndFormatRequestHandler method handle.

@Override
public ApiResponse handle(ApiRequest request) {
    int notificationId = Utils.createNewID();
    ApiResponse response;
    try {
        StopWatch stopWatch = new StopWatch();
        // stopWatch.
        // Log.e("BALF","Getting balances and format");
        response = new GetBalanceAndFormatResponse(apiProxy.getBalanceAndFormat(((GetBalanceAndFormatRequest) request).addresses, 0L, 0, stopWatch, 0));
        List<Input> inputs = ((GetBalanceAndFormatResponse) response).getInputs();
    } catch (ArgumentException e) {
        NetworkError error = new NetworkError();
        if (e instanceof ArgumentException) {
            if (e.getMessage().contains("Sending to a used address.") || e.getMessage().contains("Private key reuse detect!")) {
                final Activity activity = (Activity) context;
                Bundle bundle = new Bundle();
                bundle.putString("error", e.getMessage());
                KeyReuseDetectedDialog dialog = new KeyReuseDetectedDialog();
                dialog.setArguments(bundle);
                dialog.show(activity.getFragmentManager(), null);
                error.setErrorType(NetworkErrorType.KEY_REUSE_ERROR);
            }
        }
        if (error.getErrorType() != NetworkErrorType.KEY_REUSE_ERROR) {
            error.setErrorType(NetworkErrorType.NETWORK_ERROR);
        }
        response = error;
    }
    return response;
}
Also used : Input(jota.model.Input) Bundle(android.os.Bundle) NetworkError(run.wallet.iota.api.responses.error.NetworkError) Activity(android.app.Activity) ArgumentException(jota.error.ArgumentException) KeyReuseDetectedDialog(run.wallet.iota.ui.dialog.KeyReuseDetectedDialog) ApiResponse(run.wallet.iota.api.responses.ApiResponse) StopWatch(jota.utils.StopWatch) GetBalanceAndFormatResponse(run.wallet.iota.api.responses.GetBalanceAndFormatResponse)

Aggregations

Activity (android.app.Activity)1 Bundle (android.os.Bundle)1 ArgumentException (jota.error.ArgumentException)1 Input (jota.model.Input)1 StopWatch (jota.utils.StopWatch)1 ApiResponse (run.wallet.iota.api.responses.ApiResponse)1 GetBalanceAndFormatResponse (run.wallet.iota.api.responses.GetBalanceAndFormatResponse)1 NetworkError (run.wallet.iota.api.responses.error.NetworkError)1 KeyReuseDetectedDialog (run.wallet.iota.ui.dialog.KeyReuseDetectedDialog)1