Search in sources :

Example 1 with ApiRequest

use of run.wallet.iota.api.requests.ApiRequest in project run-wallet-android by runplay.

the class BasicRequestTask method doInBackground.

@Override
protected ApiResponse doInBackground(ApiRequest... params) {
    Context context = this.context.get();
    if (context != null) {
        start = new Date();
        ApiRequest apiRequest = params[0];
        tag = apiRequest.getClass().getCanonicalName();
        BasicApiProvider basicApi = new BasicApiProvider(context);
        ApiResponse response = basicApi.processRequest(apiRequest);
        return response;
    }
    // TaskManager.removeTask(tag);
    return null;
}
Also used : Context(android.content.Context) ApiRequest(run.wallet.iota.api.requests.ApiRequest) Date(java.util.Date) ApiResponse(run.wallet.iota.api.responses.ApiResponse)

Example 2 with ApiRequest

use of run.wallet.iota.api.requests.ApiRequest in project run-wallet-android by runplay.

the class IotaMessageApiProvider method loadRequestMap.

private void loadRequestMap() {
    Map<Class<? extends ApiRequest>, RequestHandler> requestHandlerMap = new HashMap<>();
    MessageSendRequestHandler sendMessageAction = new MessageSendRequestHandler(iotaApi, context);
    MessageNewAddressRequestHandler newAddressAction = new MessageNewAddressRequestHandler(iotaApi, context);
    MessageFirstLoadRequestHandler firstLoad = new MessageFirstLoadRequestHandler(iotaApi, context);
    requestHandlerMap.put(sendMessageAction.getType(), sendMessageAction);
    this.requestHandlerMap = requestHandlerMap;
}
Also used : MessageNewAddressRequestHandler(run.wallet.iota.api.handler.MessageNewAddressRequestHandler) MessageFirstLoadRequestHandler(run.wallet.iota.api.handler.MessageFirstLoadRequestHandler) MessageFirstLoadRequestHandler(run.wallet.iota.api.handler.MessageFirstLoadRequestHandler) RequestHandler(run.wallet.iota.api.handler.RequestHandler) MessageSendRequestHandler(run.wallet.iota.api.handler.MessageSendRequestHandler) MessageNewAddressRequestHandler(run.wallet.iota.api.handler.MessageNewAddressRequestHandler) HashMap(java.util.HashMap) MessageSendRequestHandler(run.wallet.iota.api.handler.MessageSendRequestHandler) ApiRequest(run.wallet.iota.api.requests.ApiRequest)

Example 3 with ApiRequest

use of run.wallet.iota.api.requests.ApiRequest in project run-wallet-android by runplay.

the class UiManager method displayInfoBar.

public static void displayInfoBar(Activity context, LinearLayout forView) {
    makeElements(context);
    forView.setBackgroundColor(B.getColor(context, AppTheme.getPrimaryDark()));
    try {
        List<ApiRequest> attaching = AppService.getRunningTasks();
        List<LinearLayout> processing = new ArrayList<>();
        if (!attaching.isEmpty()) {
            Seeds.Seed currentSeed = Store.getCurrentSeed();
            for (ApiRequest req : attaching) {
                if (req instanceof SendTransferRequest) {
                    SendTransferRequest str = (SendTransferRequest) req;
                    if (str.getSeed().id.equals(currentSeed.id)) {
                        if (str.getValue() == 0) {
                            processing.add(createProcessRunningPod(context, R.drawable.tran_white, context.getString(R.string.info_new_attach), 0));
                        } else {
                            processing.add(createProcessRunningPod(context, R.drawable.send_white, context.getString(R.string.info_transfer), str.getValue()));
                        }
                    }
                } else if (req instanceof GetAccountDataRequest) {
                    GetAccountDataRequest request = (GetAccountDataRequest) req;
                    if (request.getSeed().id.equals(currentSeed.id)) {
                        processing.add(createProcessRunningPod(context, R.drawable.refresh_white, context.getString(R.string.info_refresh), 0));
                    }
                } else if (req instanceof GetNewAddressRequest) {
                    GetNewAddressRequest request = (GetNewAddressRequest) req;
                    if (request.getSeed().id.equals(currentSeed.id)) {
                        processing.add(createProcessRunningPod(context, R.drawable.tran_white, context.getString(R.string.info_new_address), 0));
                    }
                } else if (req instanceof GetFirstLoadRequest) {
                    GetFirstLoadRequest request = (GetFirstLoadRequest) req;
                    if (request.getSeed().id.equals(currentSeed.id)) {
                        processing.add(createProcessRunningPod(context, R.drawable.refresh_white, context.getString(R.string.info_first_load), 0));
                    }
                } else if (req instanceof AuditAddressesRequest) {
                    AuditAddressesRequest request = (AuditAddressesRequest) req;
                    if (request.getSeed().id.equals(currentSeed.id)) {
                        processing.add(createProcessRunningPod(context, R.drawable.refresh_white, context.getString(R.string.info_audit), 0));
                    }
                } else if (req instanceof ReplayBundleRequest) {
                    ReplayBundleRequest request = (ReplayBundleRequest) req;
                    if (request.getSeed().id.equals(currentSeed.id)) {
                        processing.add(createProcessRunningPod(context, R.drawable.send_white, context.getString(R.string.info_resend), 0));
                    }
                } else if (req instanceof NudgeRequest) {
                    NudgeRequest request = (NudgeRequest) req;
                    if (request.getSeed().id.equals(currentSeed.id)) {
                        processing.add(createProcessRunningPod(context, R.drawable.send_white, context.getString(R.string.info_nudge), 0));
                    }
                } else if (req instanceof AutoNudgeRequest) {
                    // if(request.getSeed().id.equals(currentSeed.id)) {
                    processing.add(createProcessRunningPod(context, R.drawable.send_white, context.getString(R.string.auto), 0));
                // }
                } else if (req instanceof RefreshUsedAddressesRequest) {
                    // if(request.getSeed().id.equals(currentSeed.id)) {
                    processing.add(createProcessRunningPod(context, R.drawable.send_white, context.getString(R.string.info_audit), 0));
                // }
                }
            }
        }
        forView.removeAllViews();
        if (!processing.isEmpty()) {
            for (LinearLayout addview : processing) {
                forView.addView(addview);
            }
            forView.canScrollHorizontally(View.LAYOUT_DIRECTION_LTR);
            if (forView.getVisibility() != View.VISIBLE) {
                forView.setVisibility(View.VISIBLE);
                AnimationUtils.loadAnimation(context, R.anim.slide_in_from_bottom);
            }
        } else if (Store.getUsedAddressCheckResult() != null) {
            Snackbar.make(forView, Store.getUsedAddressCheckResult(), Snackbar.LENGTH_LONG).show();
            Store.setUsedAddressCheckResult(null);
        } else if (Store.getCurrentSeed().warnUsed) {
            SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
            boolean showused = prefs.getBoolean(Constants.PREFERENCES_SHOW_USED, true);
            TextView messy = new TextView(context);
            if (showused) {
                messy.setText(context.getString(R.string.usedAddressWarn));
            } else {
                messy.setText(context.getString(R.string.usedAddressSettings));
            }
            messy.setTextColor(Color.WHITE);
            messy.setPadding(30, 30, 30, 30);
            messy.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    Intent settings = new Intent(context, SettingsActivity.class);
                    context.startActivityForResult(settings, 0);
                }
            });
            forView.addView(messy);
            forView.canScrollHorizontally(View.LAYOUT_DIRECTION_LTR);
            if (forView.getVisibility() != View.VISIBLE) {
                AnimationUtils.loadAnimation(context, R.anim.slide_in_from_bottom);
            }
        } else {
            SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext());
            if (prefs.getBoolean(Constants.PREFERENCES_SHOW_CANCELLED, true) && !prefs.getBoolean(Constants.PREFERENCES_SHOW_ATTACH, true) && Store.getTransfers().size() > 15) {
                int count = prefs.getInt(Constants.PREF_MSG_MESSY, 0);
                if (count < 2) {
                    TextView messy = new TextView(context);
                    messy.setText(context.getString(R.string.message_messy_view));
                    messy.setTextColor(Color.WHITE);
                    messy.setPadding(30, 30, 30, 30);
                    // messy.setText
                    messy.setOnClickListener(new View.OnClickListener() {

                        @Override
                        public void onClick(View v) {
                            Intent settings = new Intent(context, SettingsActivity.class);
                            context.startActivityForResult(settings, 0);
                        }
                    });
                    forView.addView(messy);
                    forView.canScrollHorizontally(View.LAYOUT_DIRECTION_LTR);
                    if (forView.getVisibility() != View.VISIBLE) {
                        AnimationUtils.loadAnimation(context, R.anim.slide_in_from_bottom);
                    }
                    prefs.edit().putInt(Constants.PREF_MSG_MESSY, ++count).commit();
                }
            } else {
                AnimationUtils.loadAnimation(context, R.anim.slide_out_to_bottom);
            }
        }
    } catch (Exception e) {
    }
}
Also used : Seeds(run.wallet.iota.model.Seeds) GetNewAddressRequest(run.wallet.iota.api.requests.GetNewAddressRequest) ArrayList(java.util.ArrayList) AuditAddressesRequest(run.wallet.iota.api.requests.AuditAddressesRequest) ApiRequest(run.wallet.iota.api.requests.ApiRequest) RefreshUsedAddressesRequest(run.wallet.iota.api.requests.RefreshUsedAddressesRequest) SendTransferRequest(run.wallet.iota.api.requests.SendTransferRequest) TextView(android.widget.TextView) SharedPreferences(android.content.SharedPreferences) AutoNudgeRequest(run.wallet.iota.api.requests.AutoNudgeRequest) NudgeRequest(run.wallet.iota.api.requests.NudgeRequest) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) GetAccountDataRequest(run.wallet.iota.api.requests.GetAccountDataRequest) ReplayBundleRequest(run.wallet.iota.api.requests.ReplayBundleRequest) LinearLayout(android.widget.LinearLayout) AutoNudgeRequest(run.wallet.iota.api.requests.AutoNudgeRequest) SettingsActivity(run.wallet.iota.ui.activity.SettingsActivity) GetFirstLoadRequest(run.wallet.iota.api.requests.GetFirstLoadRequest)

Example 4 with ApiRequest

use of run.wallet.iota.api.requests.ApiRequest in project run-wallet-android by runplay.

the class BasicApiProvider method loadRequestMap.

private void loadRequestMap() {
    if (useRequestHandlerMap == null) {
        Map<Class<? extends ApiRequest>, RequestHandler> requestHandlerMap = new HashMap<>();
        WebGetExchangeRatesRequestHandler webExchangeAction = new WebGetExchangeRatesRequestHandler(context);
        WebGetExchangeRatesHistoryRequestHandler webExchangeHistoryAction = new WebGetExchangeRatesHistoryRequestHandler(context);
        requestHandlerMap.put(webExchangeAction.getType(), webExchangeAction);
        requestHandlerMap.put(webExchangeHistoryAction.getType(), webExchangeHistoryAction);
        useRequestHandlerMap = requestHandlerMap;
    }
}
Also used : WebGetExchangeRatesHistoryRequestHandler(run.wallet.iota.api.handler.WebGetExchangeRatesHistoryRequestHandler) RequestHandler(run.wallet.iota.api.handler.RequestHandler) WebGetExchangeRatesHistoryRequestHandler(run.wallet.iota.api.handler.WebGetExchangeRatesHistoryRequestHandler) WebGetExchangeRatesRequestHandler(run.wallet.iota.api.handler.WebGetExchangeRatesRequestHandler) HashMap(java.util.HashMap) ApiRequest(run.wallet.iota.api.requests.ApiRequest) WebGetExchangeRatesRequestHandler(run.wallet.iota.api.handler.WebGetExchangeRatesRequestHandler)

Example 5 with ApiRequest

use of run.wallet.iota.api.requests.ApiRequest in project run-wallet-android by runplay.

the class IotaApiProvider method loadRequestMap.

private void loadRequestMap() {
    Map<Class<? extends ApiRequest>, RequestHandler> requestHandlerMap = new HashMap<>();
    AddressSecurityChangeRequestHandler addressSecurity = new AddressSecurityChangeRequestHandler(iotaApi, context);
    AddNeighborsRequestHandler addNeighborsAction = new AddNeighborsRequestHandler(iotaApi, context);
    AuditAddressesRequestHandler auditAddresses = new AuditAddressesRequestHandler(iotaApi, context);
    AutoNudgeHandler autoNudge = new AutoNudgeHandler(iotaApi, context);
    RefreshUsedAddressesHandler refreshUsed = new RefreshUsedAddressesHandler(iotaApi, context);
    FindTransactionsRequestHandler findTransactionsAction = new FindTransactionsRequestHandler(iotaApi, context);
    GetBundleRequestHandler getBundleAction = new GetBundleRequestHandler(iotaApi, context);
    GetNeighborsRequestHandler getNeighborsAction = new GetNeighborsRequestHandler(iotaApi, context);
    GetNewAddressRequestHandler getNewAddressAction = new GetNewAddressRequestHandler(iotaApi, context);
    GetAccountDataRequestHandler getAccountDataAction = new GetAccountDataRequestHandler(iotaApi, context);
    RemoveNeighborsRequestHandler removeNeighborsAction = new RemoveNeighborsRequestHandler(iotaApi, context);
    ReplayBundleRequestHandler replayBundleAction = new ReplayBundleRequestHandler(iotaApi, context);
    SendTransferRequestHandler sendTransferAction = new SendTransferRequestHandler(iotaApi, context);
    NodeInfoRequestHandler nodeInfoAction = new NodeInfoRequestHandler(iotaApi, context);
    GetFirstLoadRequestHandler firstLoad = new GetFirstLoadRequestHandler(iotaApi, context);
    NudgeRequestHandler nudgeRequest = new NudgeRequestHandler(iotaApi, context);
    GetBalanceAndFormatRequestHandler getBalanceAndFormatRequest = new GetBalanceAndFormatRequestHandler(iotaApi, context);
    requestHandlerMap.put(refreshUsed.getType(), refreshUsed);
    requestHandlerMap.put(autoNudge.getType(), autoNudge);
    requestHandlerMap.put(nudgeRequest.getType(), nudgeRequest);
    requestHandlerMap.put(addressSecurity.getType(), addressSecurity);
    requestHandlerMap.put(auditAddresses.getType(), auditAddresses);
    requestHandlerMap.put(firstLoad.getType(), firstLoad);
    requestHandlerMap.put(addNeighborsAction.getType(), addNeighborsAction);
    requestHandlerMap.put(findTransactionsAction.getType(), findTransactionsAction);
    requestHandlerMap.put(getBundleAction.getType(), getBundleAction);
    requestHandlerMap.put(getNeighborsAction.getType(), getNeighborsAction);
    requestHandlerMap.put(getNewAddressAction.getType(), getNewAddressAction);
    requestHandlerMap.put(getAccountDataAction.getType(), getAccountDataAction);
    requestHandlerMap.put(removeNeighborsAction.getType(), removeNeighborsAction);
    requestHandlerMap.put(replayBundleAction.getType(), replayBundleAction);
    requestHandlerMap.put(sendTransferAction.getType(), sendTransferAction);
    requestHandlerMap.put(nodeInfoAction.getType(), nodeInfoAction);
    requestHandlerMap.put(getBalanceAndFormatRequest.getType(), getBalanceAndFormatRequest);
    this.requestHandlerMap = requestHandlerMap;
}
Also used : NodeInfoRequestHandler(run.wallet.iota.api.handler.NodeInfoRequestHandler) GetFirstLoadRequestHandler(run.wallet.iota.api.handler.GetFirstLoadRequestHandler) HashMap(java.util.HashMap) FindTransactionsRequestHandler(run.wallet.iota.api.handler.FindTransactionsRequestHandler) AutoNudgeHandler(run.wallet.iota.api.handler.AutoNudgeHandler) AuditAddressesRequestHandler(run.wallet.iota.api.handler.AuditAddressesRequestHandler) GetNeighborsRequestHandler(run.wallet.iota.api.handler.GetNeighborsRequestHandler) GetNewAddressRequestHandler(run.wallet.iota.api.handler.GetNewAddressRequestHandler) AddressSecurityChangeRequestHandler(run.wallet.iota.api.handler.AddressSecurityChangeRequestHandler) ApiRequest(run.wallet.iota.api.requests.ApiRequest) GetBundleRequestHandler(run.wallet.iota.api.handler.GetBundleRequestHandler) RemoveNeighborsRequestHandler(run.wallet.iota.api.handler.RemoveNeighborsRequestHandler) ReplayBundleRequestHandler(run.wallet.iota.api.handler.ReplayBundleRequestHandler) SendTransferRequestHandler(run.wallet.iota.api.handler.SendTransferRequestHandler) RefreshUsedAddressesHandler(run.wallet.iota.api.handler.RefreshUsedAddressesHandler) GetBalanceAndFormatRequestHandler(run.wallet.iota.api.handler.GetBalanceAndFormatRequestHandler) GetAccountDataRequestHandler(run.wallet.iota.api.handler.GetAccountDataRequestHandler) GetBundleRequestHandler(run.wallet.iota.api.handler.GetBundleRequestHandler) RemoveNeighborsRequestHandler(run.wallet.iota.api.handler.RemoveNeighborsRequestHandler) GetNewAddressRequestHandler(run.wallet.iota.api.handler.GetNewAddressRequestHandler) GetFirstLoadRequestHandler(run.wallet.iota.api.handler.GetFirstLoadRequestHandler) GetBalanceAndFormatRequestHandler(run.wallet.iota.api.handler.GetBalanceAndFormatRequestHandler) ReplayBundleRequestHandler(run.wallet.iota.api.handler.ReplayBundleRequestHandler) NudgeRequestHandler(run.wallet.iota.api.handler.NudgeRequestHandler) FindTransactionsRequestHandler(run.wallet.iota.api.handler.FindTransactionsRequestHandler) GetNeighborsRequestHandler(run.wallet.iota.api.handler.GetNeighborsRequestHandler) AddressSecurityChangeRequestHandler(run.wallet.iota.api.handler.AddressSecurityChangeRequestHandler) AuditAddressesRequestHandler(run.wallet.iota.api.handler.AuditAddressesRequestHandler) RequestHandler(run.wallet.iota.api.handler.RequestHandler) NodeInfoRequestHandler(run.wallet.iota.api.handler.NodeInfoRequestHandler) AddNeighborsRequestHandler(run.wallet.iota.api.handler.AddNeighborsRequestHandler) SendTransferRequestHandler(run.wallet.iota.api.handler.SendTransferRequestHandler) AddNeighborsRequestHandler(run.wallet.iota.api.handler.AddNeighborsRequestHandler) NudgeRequestHandler(run.wallet.iota.api.handler.NudgeRequestHandler) GetAccountDataRequestHandler(run.wallet.iota.api.handler.GetAccountDataRequestHandler)

Aggregations

ApiRequest (run.wallet.iota.api.requests.ApiRequest)7 Context (android.content.Context)3 HashMap (java.util.HashMap)3 RequestHandler (run.wallet.iota.api.handler.RequestHandler)3 ApiResponse (run.wallet.iota.api.responses.ApiResponse)3 Date (java.util.Date)2 Nodes (run.wallet.iota.model.Nodes)2 Intent (android.content.Intent)1 SharedPreferences (android.content.SharedPreferences)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 LinearLayout (android.widget.LinearLayout)1 TextView (android.widget.TextView)1 ArrayList (java.util.ArrayList)1 AddNeighborsRequestHandler (run.wallet.iota.api.handler.AddNeighborsRequestHandler)1 AddressSecurityChangeRequestHandler (run.wallet.iota.api.handler.AddressSecurityChangeRequestHandler)1 AuditAddressesRequestHandler (run.wallet.iota.api.handler.AuditAddressesRequestHandler)1 AutoNudgeHandler (run.wallet.iota.api.handler.AutoNudgeHandler)1 FindTransactionsRequestHandler (run.wallet.iota.api.handler.FindTransactionsRequestHandler)1 GetAccountDataRequestHandler (run.wallet.iota.api.handler.GetAccountDataRequestHandler)1