use of wannabit.io.cosmostaion.task.TaskResult in project cosmostation-android by cosmostation.
the class ValidatorActivity method onCheckReInvest.
private void onCheckReInvest() {
if (!mAccount.hasPrivateKey) {
AlertDialogUtils.showDoubleButtonDialog(this, getString(R.string.str_only_observe_title), getString(R.string.str_only_observe_msg), Html.fromHtml("<font color=\"#9C6CFF\">" + getString(R.string.str_add_mnemonics) + "</font>"), view -> onAddMnemonicForAccount(), getString(R.string.str_close), null);
return;
}
BigDecimal feeAmount = WUtil.getEstimateGasFeeAmount(getBaseContext(), mBaseChain, CONST_PW_TX_REINVEST, 0);
List<String> availableFeeDenomList = Lists.newArrayList();
for (String denom : WDp.getGasDenomList(mBaseChain)) {
if (getBaseDao().getAvailable(denom).compareTo(feeAmount) >= 0) {
availableFeeDenomList.add(denom);
}
}
if (availableFeeDenomList.isEmpty()) {
Toast.makeText(getBaseContext(), R.string.error_not_enough_fee, Toast.LENGTH_SHORT).show();
return;
}
if (getBaseDao().getReward(WDp.mainDenom(mBaseChain), mValOpAddress).compareTo(BigDecimal.ZERO) <= 0) {
Toast.makeText(getBaseContext(), R.string.error_not_enough_reward, Toast.LENGTH_SHORT).show();
return;
}
new WithdrawAddressGrpcTask(getBaseApplication(), new TaskListener() {
@Override
public void onTaskResponse(TaskResult result) {
String rewardAddress = (String) result.resultData;
if (rewardAddress == null || !rewardAddress.equals(mAccount.address)) {
Toast.makeText(getBaseContext(), R.string.error_reward_address_changed_msg, Toast.LENGTH_SHORT).show();
return;
} else {
Intent reinvest = new Intent(ValidatorActivity.this, ReInvestActivity.class);
reinvest.putExtra("valOpAddress", mValOpAddress);
startActivity(reinvest);
}
}
}, mBaseChain, mAccount).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
use of wannabit.io.cosmostaion.task.TaskResult in project cosmostation-android by cosmostation.
the class ProfileStep0Fragment method onClick.
@Override
public void onClick(View v) {
if (v.equals(mCancelBtn)) {
getSActivity().onBeforeStep();
} else if (v.equals(mNextBtn)) {
String dtag = mProfileDtag.getText().toString().trim();
String nickname = mProfileNickname.getText().toString().trim();
String bio = mProfileBio.getText().toString().trim();
if (dtag.isEmpty()) {
Toast.makeText(getSActivity(), getSActivity().getString(R.string.error_no_profile_dtag), Toast.LENGTH_SHORT).show();
return;
}
if (!Pattern.matches("^[A-Za-z0-9_]+$", dtag) || dtag.length() < 6 || dtag.length() > 30) {
Toast.makeText(getSActivity(), getSActivity().getString(R.string.error_profile_dtag_count), Toast.LENGTH_SHORT).show();
return;
}
new DesmosProfileGrpcTask(getBaseApplication(), new TaskListener() {
@Override
public void onTaskResponse(TaskResult result) {
if (!result.isSuccess) {
getSActivity().mDtag = dtag;
getSActivity().mNickname = nickname;
getSActivity().mBio = bio;
getSActivity().mCoverImg = mCoverHash;
getSActivity().mProfileImg = mProfileHash;
getSActivity().onNextStep();
} else {
Toast.makeText(getSActivity(), getSActivity().getString(R.string.error_already_registered_dtag), Toast.LENGTH_SHORT).show();
return;
}
}
}, getSActivity().mBaseChain, dtag).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} else if (v.equals(mImgAdd)) {
misProfile = true;
tedPermission();
} else if (v.equals(mProfileImg)) {
misProfile = false;
tedPermission();
} else if (v.equals(mImgDel)) {
onUpdateImgView(true, null);
mCoverHash = null;
}
}
use of wannabit.io.cosmostaion.task.TaskResult in project cosmostation-android by cosmostation.
the class BaseActivity method onStartMoonpaySignature.
public void onStartMoonpaySignature(String fiat) {
String query = "?apiKey=" + getString(R.string.moon_pay_public_key);
if (mBaseChain.equals(COSMOS_MAIN)) {
query = query + "¤cyCode=atom";
} else if (mBaseChain.equals(BNB_MAIN)) {
query = query + "¤cyCode=bnb";
} else if (mBaseChain.equals(KAVA_MAIN)) {
query = query + "¤cyCode=kava";
} else if (mBaseChain.equals(BAND_MAIN)) {
query = query + "¤cyCode=band";
}
query = query + "&walletAddress=" + mAccount.address + "&baseCurrencyCode=" + fiat;
final String data = query;
new MoonPayTask(getBaseApplication(), new TaskListener() {
@Override
public void onTaskResponse(TaskResult result) {
if (result.isSuccess) {
try {
String en = URLEncoder.encode((String) result.resultData, "UTF-8");
Intent guideIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.url_moon_pay) + data + "&signature=" + en));
startActivity(guideIntent);
} catch (Exception e) {
Toast.makeText(getBaseContext(), R.string.error_network_error, Toast.LENGTH_SHORT).show();
}
} else {
Toast.makeText(getBaseContext(), R.string.error_network_error, Toast.LENGTH_SHORT).show();
}
}
}, query).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
}
use of wannabit.io.cosmostaion.task.TaskResult in project cosmostation-android by cosmostation.
the class NftMyHolder method onBindNFT.
public void onBindNFT(NFTListActivity activity, String denomId, String tokenId) {
itemRoot.setCardBackgroundColor(activity.getResources().getColor(R.color.colorTransBgIris));
itemMyNftImg.setClipToOutline(true);
new NFTokenInfoGrpcTask(activity.getBaseApplication(), new TaskListener() {
@Override
public void onTaskResponse(TaskResult result) {
if (result.isSuccess) {
if (activity.mBaseChain.equals(IRIS_MAIN)) {
QueryOuterClass.QueryNFTResponse irisResponse = (QueryOuterClass.QueryNFTResponse) result.resultData;
if (irisResponse != null) {
try {
Glide.with(activity).load(irisResponse.getNft().getUri()).diskCacheStrategy(DiskCacheStrategy.ALL).placeholder(R.drawable.icon_nft_none).error(R.drawable.icon_nft_none).fitCenter().into(itemMyNftImg);
} catch (Exception e) {
}
itemMyNftTitle.setText(irisResponse.getNft().getName());
itemMyNftContent.setText(WUtil.getNftDescription(irisResponse.getNft().getData()));
itemRoot.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(activity, NFTokenDetailActivity.class);
intent.putExtra("irisResponse", irisResponse);
intent.putExtra("mDenomId", denomId);
intent.putExtra("mTokenId", tokenId);
activity.startActivity(intent);
}
});
}
} else if (activity.mBaseChain.equals(CRYPTO_MAIN)) {
chainmain.nft.v1.Nft.BaseNFT myCryptoNftInfo = (chainmain.nft.v1.Nft.BaseNFT) result.resultData;
if (myCryptoNftInfo != null) {
try {
Glide.with(activity).load(WUtil.getNftImgUrl(myCryptoNftInfo.getData())).diskCacheStrategy(DiskCacheStrategy.ALL).placeholder(R.drawable.icon_nft_none).error(R.drawable.icon_nft_none).into(itemMyNftImg);
} catch (Exception e) {
}
itemMyNftTitle.setText(myCryptoNftInfo.getName());
itemMyNftContent.setText(WUtil.getNftDescription(myCryptoNftInfo.getData()));
itemRoot.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(activity, NFTokenDetailActivity.class);
intent.putExtra("myNftInfo", myCryptoNftInfo);
intent.putExtra("mDenomId", denomId);
intent.putExtra("mTokenId", tokenId);
activity.startActivity(intent);
}
});
}
}
}
}
}, activity.mBaseChain, denomId, tokenId).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Aggregations