Search in sources :

Example 1 with TaskResult

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);
}
Also used : WithdrawAddressGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.WithdrawAddressGrpcTask) TaskListener(wannabit.io.cosmostaion.task.TaskListener) TaskResult(wannabit.io.cosmostaion.task.TaskResult) Intent(android.content.Intent) SpannableString(android.text.SpannableString) BigDecimal(java.math.BigDecimal)

Example 2 with TaskResult

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;
    }
}
Also used : DesmosProfileGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.DesmosProfileGrpcTask) TaskListener(wannabit.io.cosmostaion.task.TaskListener) TaskResult(wannabit.io.cosmostaion.task.TaskResult)

Example 3 with TaskResult

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 + "&currencyCode=atom";
    } else if (mBaseChain.equals(BNB_MAIN)) {
        query = query + "&currencyCode=bnb";
    } else if (mBaseChain.equals(KAVA_MAIN)) {
        query = query + "&currencyCode=kava";
    } else if (mBaseChain.equals(BAND_MAIN)) {
        query = query + "&currencyCode=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);
}
Also used : MoonPayTask(wannabit.io.cosmostaion.task.FetchTask.MoonPayTask) TaskListener(wannabit.io.cosmostaion.task.TaskListener) TaskResult(wannabit.io.cosmostaion.task.TaskResult) Intent(android.content.Intent) WriterException(com.google.zxing.WriterException)

Example 4 with TaskResult

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);
}
Also used : NFTokenInfoGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.NFTokenInfoGrpcTask) Intent(android.content.Intent) QueryOuterClass(irismod.nft.QueryOuterClass) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) CardView(androidx.cardview.widget.CardView) TaskListener(wannabit.io.cosmostaion.task.TaskListener) TaskResult(wannabit.io.cosmostaion.task.TaskResult) Nft(irismod.nft.Nft) NFTokenDetailActivity(wannabit.io.cosmostaion.activities.tokenDetail.NFTokenDetailActivity)

Aggregations

TaskListener (wannabit.io.cosmostaion.task.TaskListener)4 TaskResult (wannabit.io.cosmostaion.task.TaskResult)4 Intent (android.content.Intent)3 SpannableString (android.text.SpannableString)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 CardView (androidx.cardview.widget.CardView)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 WriterException (com.google.zxing.WriterException)1 Nft (irismod.nft.Nft)1 QueryOuterClass (irismod.nft.QueryOuterClass)1 BigDecimal (java.math.BigDecimal)1 NFTokenDetailActivity (wannabit.io.cosmostaion.activities.tokenDetail.NFTokenDetailActivity)1 MoonPayTask (wannabit.io.cosmostaion.task.FetchTask.MoonPayTask)1 DesmosProfileGrpcTask (wannabit.io.cosmostaion.task.gRpcTask.DesmosProfileGrpcTask)1 NFTokenInfoGrpcTask (wannabit.io.cosmostaion.task.gRpcTask.NFTokenInfoGrpcTask)1 WithdrawAddressGrpcTask (wannabit.io.cosmostaion.task.gRpcTask.WithdrawAddressGrpcTask)1