@Test public void getBalanceType(){ DelegationValue delegationValue = new DelegationValue(); delegationValue.setFree("234456"); delegationValue.setLock("345"); delegationValue.setMinDelegation("100"); presenter.setmDelegationValue(delegationValue); Wallet wallet = new Wallet(); wallet.setUuid("9eed1da8-58e9-4b10-8bea-2bfdd1cac433"); wallet.setAvatar("avatar_3"); wallet.setAddress("0x0d395e21b23f8d920f8556cbf573af9ba2ad1a59"); wallet.setChainId("101"); wallet.setName("Ella"); wallet.setKeystorePath("UTC--2020-06-28T06-36-42.751--b1ca4a13ee33ed68d097223f186f65864ecdb98c9b35c664566f096761649aa7d9c9c2bc317785a5c2580b305803e5f29aafce422e49579792623575215675e7.json"); Bech32Address bech32Address = new Bech32Address("lat1p5u4ugdj87xeyru92m9l2ua0nw326xjekflsf8","lax1p5u4ugdj87xeyru92m9l2ua0nw326xjeevdl8g"); wallet.setBech32Address(bech32Address); presenter.setmWallet(wallet); DelegateItemInfo delegateItemInfo = new DelegateItemInfo(); delegateItemInfo.setNodeName("测试"); delegateItemInfo.setNodeId("101"); presenter.setmDelegateDetail(delegateItemInfo); }
@Override public void getBalanceType() { if (mDelegateDetail == null) { return; } ServerUtils.getCommonApi().getDelegationValue(ApiRequestBody.newBuilder() .put("addr", mWallet.getPrefixAddress()) .put("nodeId", mDelegateDetail.getNodeId()) .build()) .compose(RxUtils.getSingleSchedulerTransformer()) .compose(bindToLifecycle()) .compose(LoadingTransformer.bindToSingleLifecycle(currentActivity())) .subscribe(new ApiSingleObserver<DelegationValue>() { @Override public void onApiSuccess(DelegationValue delegationValue) { if (isViewAttached()) { mDelegationValue = delegationValue; AccountBalance accountBalance = new AccountBalance(mWallet.getPrefixAddress(), delegationValue.getFree(), delegationValue.getLock()); WalletManager.getInstance().updateAccountBalance(accountBalance); mWallet = WalletManager.getInstance().getWalletByAddress(accountBalance.getPrefixAddress()); showWalletInfo(); list = delegationValue.getWithDrawBalanceList(); mWithDrawBalance = delegationValue.getDefaultShowWithDrawBalance(); if (mWithDrawBalance != null) { getView().showGas(mWithDrawBalance.getGasProvider().toSdkGasProvider()); double releasedSum = delegationValue.getReleasedSumAmount(); double delegatedSum = delegationValue.getDelegatedSumAmount(); getView().showMinDelegationInfo(NumberParserUtils.getPrettyNumber(AmountUtil.convertVonToLat(delegationValue.getMinDelegation()))); getView().showWithdrawBalance(mWithDrawBalance); getView().showsSelectDelegationsBtnVisibility(list != null && list.size() > 1 ? View.VISIBLE : View.GONE); if (delegatedSum + releasedSum <= 0) { getView().finishDelayed(); } } } } @Override public void onApiFailure(ApiResponse response) { super.onApiFailure(response); if (isViewAttached()) { showLongToast(R.string.msg_connect_timeout); } } }); }
WithDrawPresenter extends BasePresenter<WithDrawContract.View> implements WithDrawContract.Presenter { @Override public void getBalanceType() { if (mDelegateDetail == null) { return; } ServerUtils.getCommonApi().getDelegationValue(ApiRequestBody.newBuilder() .put("addr", mWallet.getPrefixAddress()) .put("nodeId", mDelegateDetail.getNodeId()) .build()) .compose(RxUtils.getSingleSchedulerTransformer()) .compose(bindToLifecycle()) .compose(LoadingTransformer.bindToSingleLifecycle(currentActivity())) .subscribe(new ApiSingleObserver<DelegationValue>() { @Override public void onApiSuccess(DelegationValue delegationValue) { if (isViewAttached()) { mDelegationValue = delegationValue; AccountBalance accountBalance = new AccountBalance(mWallet.getPrefixAddress(), delegationValue.getFree(), delegationValue.getLock()); WalletManager.getInstance().updateAccountBalance(accountBalance); mWallet = WalletManager.getInstance().getWalletByAddress(accountBalance.getPrefixAddress()); showWalletInfo(); list = delegationValue.getWithDrawBalanceList(); mWithDrawBalance = delegationValue.getDefaultShowWithDrawBalance(); if (mWithDrawBalance != null) { getView().showGas(mWithDrawBalance.getGasProvider().toSdkGasProvider()); double releasedSum = delegationValue.getReleasedSumAmount(); double delegatedSum = delegationValue.getDelegatedSumAmount(); getView().showMinDelegationInfo(NumberParserUtils.getPrettyNumber(AmountUtil.convertVonToLat(delegationValue.getMinDelegation()))); getView().showWithdrawBalance(mWithDrawBalance); getView().showsSelectDelegationsBtnVisibility(list != null && list.size() > 1 ? View.VISIBLE : View.GONE); if (delegatedSum + releasedSum <= 0) { getView().finishDelayed(); } } } } @Override public void onApiFailure(ApiResponse response) { super.onApiFailure(response); if (isViewAttached()) { showLongToast(R.string.msg_connect_timeout); } } }); } }
WithDrawPresenter extends BasePresenter<WithDrawContract.View> implements WithDrawContract.Presenter { @Override public void getBalanceType() { if (mDelegateDetail == null) { return; } ServerUtils.getCommonApi().getDelegationValue(ApiRequestBody.newBuilder() .put("addr", mWallet.getPrefixAddress()) .put("nodeId", mDelegateDetail.getNodeId()) .build()) .compose(RxUtils.getSingleSchedulerTransformer()) .compose(bindToLifecycle()) .compose(LoadingTransformer.bindToSingleLifecycle(currentActivity())) .subscribe(new ApiSingleObserver<DelegationValue>() { @Override public void onApiSuccess(DelegationValue delegationValue) { if (isViewAttached()) { mDelegationValue = delegationValue; AccountBalance accountBalance = new AccountBalance(mWallet.getPrefixAddress(), delegationValue.getFree(), delegationValue.getLock()); WalletManager.getInstance().updateAccountBalance(accountBalance); mWallet = WalletManager.getInstance().getWalletByAddress(accountBalance.getPrefixAddress()); showWalletInfo(); list = delegationValue.getWithDrawBalanceList(); mWithDrawBalance = delegationValue.getDefaultShowWithDrawBalance(); if (mWithDrawBalance != null) { getView().showGas(mWithDrawBalance.getGasProvider().toSdkGasProvider()); double releasedSum = delegationValue.getReleasedSumAmount(); double delegatedSum = delegationValue.getDelegatedSumAmount(); getView().showMinDelegationInfo(NumberParserUtils.getPrettyNumber(AmountUtil.convertVonToLat(delegationValue.getMinDelegation()))); getView().showWithdrawBalance(mWithDrawBalance); getView().showsSelectDelegationsBtnVisibility(list != null && list.size() > 1 ? View.VISIBLE : View.GONE); if (delegatedSum + releasedSum <= 0) { getView().finishDelayed(); } } } } @Override public void onApiFailure(ApiResponse response) { super.onApiFailure(response); if (isViewAttached()) { showLongToast(R.string.msg_connect_timeout); } } }); }  }
WithDrawPresenter extends BasePresenter<WithDrawContract.View> implements WithDrawContract.Presenter { @Override public void getBalanceType() { if (mDelegateDetail == null) { return; } ServerUtils.getCommonApi().getDelegationValue(ApiRequestBody.newBuilder() .put("addr", mWallet.getPrefixAddress()) .put("nodeId", mDelegateDetail.getNodeId()) .build()) .compose(RxUtils.getSingleSchedulerTransformer()) .compose(bindToLifecycle()) .compose(LoadingTransformer.bindToSingleLifecycle(currentActivity())) .subscribe(new ApiSingleObserver<DelegationValue>() { @Override public void onApiSuccess(DelegationValue delegationValue) { if (isViewAttached()) { mDelegationValue = delegationValue; AccountBalance accountBalance = new AccountBalance(mWallet.getPrefixAddress(), delegationValue.getFree(), delegationValue.getLock()); WalletManager.getInstance().updateAccountBalance(accountBalance); mWallet = WalletManager.getInstance().getWalletByAddress(accountBalance.getPrefixAddress()); showWalletInfo(); list = delegationValue.getWithDrawBalanceList(); mWithDrawBalance = delegationValue.getDefaultShowWithDrawBalance(); if (mWithDrawBalance != null) { getView().showGas(mWithDrawBalance.getGasProvider().toSdkGasProvider()); double releasedSum = delegationValue.getReleasedSumAmount(); double delegatedSum = delegationValue.getDelegatedSumAmount(); getView().showMinDelegationInfo(NumberParserUtils.getPrettyNumber(AmountUtil.convertVonToLat(delegationValue.getMinDelegation()))); getView().showWithdrawBalance(mWithDrawBalance); getView().showsSelectDelegationsBtnVisibility(list != null && list.size() > 1 ? View.VISIBLE : View.GONE); if (delegatedSum + releasedSum <= 0) { getView().finishDelayed(); } } } } @Override public void onApiFailure(ApiResponse response) { super.onApiFailure(response); if (isViewAttached()) { showLongToast(R.string.msg_connect_timeout); } } }); }  WithDrawBalance getmWithDrawBalance(); void setmWithDrawBalance(WithDrawBalance mWithDrawBalance); DelegateItemInfo getmDelegateDetail(); void setmDelegateDetail(DelegateItemInfo mDelegateDetail); DelegationValue getmDelegationValue(); void setmDelegationValue(DelegationValue mDelegationValue); Wallet getmWallet(); void setmWallet(Wallet mWallet); @Override void init(DelegateItemInfo delegateItemInfo); String getWalletAddress(); List<WithDrawBalance> getWithDrawBalanceList(); WithDrawBalance getWithDrawBalance(); double getMinDelegationAmount(); @Override void showWalletInfo(); void getEstimateGas(String prefixAddress, String nodeId); @Override void checkWithDrawAmount(String withdrawAmount); @Override void updateWithDrawButtonState(); @Override void getBalanceType(); @Override void getWithDrawGasPrice(String gasPrice); @Override void showSelectDelegationsDialogFragment(); @SuppressLint("CheckResult") @Override void submitWithDraw(); @SuppressLint("CheckResult") void withdraw(Credentials credentials, GasProvider gasProvider, String nodeId, String nodeName, String blockNum, String withdrawAmount, String nonce); }
WithDrawPresenter extends BasePresenter<WithDrawContract.View> implements WithDrawContract.Presenter { @Override public void getBalanceType() { if (mDelegateDetail == null) { return; } ServerUtils.getCommonApi().getDelegationValue(ApiRequestBody.newBuilder() .put("addr", mWallet.getPrefixAddress()) .put("nodeId", mDelegateDetail.getNodeId()) .build()) .compose(RxUtils.getSingleSchedulerTransformer()) .compose(bindToLifecycle()) .compose(LoadingTransformer.bindToSingleLifecycle(currentActivity())) .subscribe(new ApiSingleObserver<DelegationValue>() { @Override public void onApiSuccess(DelegationValue delegationValue) { if (isViewAttached()) { mDelegationValue = delegationValue; AccountBalance accountBalance = new AccountBalance(mWallet.getPrefixAddress(), delegationValue.getFree(), delegationValue.getLock()); WalletManager.getInstance().updateAccountBalance(accountBalance); mWallet = WalletManager.getInstance().getWalletByAddress(accountBalance.getPrefixAddress()); showWalletInfo(); list = delegationValue.getWithDrawBalanceList(); mWithDrawBalance = delegationValue.getDefaultShowWithDrawBalance(); if (mWithDrawBalance != null) { getView().showGas(mWithDrawBalance.getGasProvider().toSdkGasProvider()); double releasedSum = delegationValue.getReleasedSumAmount(); double delegatedSum = delegationValue.getDelegatedSumAmount(); getView().showMinDelegationInfo(NumberParserUtils.getPrettyNumber(AmountUtil.convertVonToLat(delegationValue.getMinDelegation()))); getView().showWithdrawBalance(mWithDrawBalance); getView().showsSelectDelegationsBtnVisibility(list != null && list.size() > 1 ? View.VISIBLE : View.GONE); if (delegatedSum + releasedSum <= 0) { getView().finishDelayed(); } } } } @Override public void onApiFailure(ApiResponse response) { super.onApiFailure(response); if (isViewAttached()) { showLongToast(R.string.msg_connect_timeout); } } }); }  WithDrawBalance getmWithDrawBalance(); void setmWithDrawBalance(WithDrawBalance mWithDrawBalance); DelegateItemInfo getmDelegateDetail(); void setmDelegateDetail(DelegateItemInfo mDelegateDetail); DelegationValue getmDelegationValue(); void setmDelegationValue(DelegationValue mDelegationValue); Wallet getmWallet(); void setmWallet(Wallet mWallet); @Override void init(DelegateItemInfo delegateItemInfo); String getWalletAddress(); List<WithDrawBalance> getWithDrawBalanceList(); WithDrawBalance getWithDrawBalance(); double getMinDelegationAmount(); @Override void showWalletInfo(); void getEstimateGas(String prefixAddress, String nodeId); @Override void checkWithDrawAmount(String withdrawAmount); @Override void updateWithDrawButtonState(); @Override void getBalanceType(); @Override void getWithDrawGasPrice(String gasPrice); @Override void showSelectDelegationsDialogFragment(); @SuppressLint("CheckResult") @Override void submitWithDraw(); @SuppressLint("CheckResult") void withdraw(Credentials credentials, GasProvider gasProvider, String nodeId, String nodeName, String blockNum, String withdrawAmount, String nonce);  }