Search in sources :

Example 1 with Assets

use of wannabit.io.cosmostaion.dao.Assets in project cosmostation-android by cosmostation.

the class WDp method showCoinDp.

public static void showCoinDp(Context c, BaseData baseData, Coin coin, TextView denomTv, TextView amountTv, BaseChain chain) {
    if (isGRPC(chain) && coin.isIbc()) {
        IbcToken ibcToken = baseData.getIbcToken(coin.getIbcHash());
        if (ibcToken != null && ibcToken.auth) {
            denomTv.setTextColor(c.getResources().getColor(R.color.colorWhite));
            denomTv.setText(ibcToken.display_denom.toUpperCase());
            amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), ibcToken.decimal, ibcToken.decimal));
        } else {
            denomTv.setTextColor(c.getResources().getColor(R.color.colorWhite));
            denomTv.setText("Unknown");
            amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), 6, 6));
        }
    } else if (chain.equals(COSMOS_MAIN)) {
        if (coin.denom.equals(TOKEN_ATOM)) {
            DpMainDenom(c, chain.getChain(), denomTv);
            amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), 6, 6));
        } else {
            denomTv.setTextColor(c.getResources().getColor(R.color.colorWhite));
            amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), 6, 6));
            denomTv.setText(coin.denom.toUpperCase());
        }
    } else if (chain.equals(IRIS_MAIN)) {
        if (coin.denom.equals(TOKEN_IRIS)) {
            DpMainDenom(c, chain.getChain(), denomTv);
        } else {
            denomTv.setTextColor(c.getResources().getColor(R.color.colorWhite));
            denomTv.setText(coin.denom.toUpperCase());
        }
        amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), 6, 6));
    } else if (chain.equals(KAVA_MAIN)) {
        if (coin.denom.equals(TOKEN_KAVA)) {
            DpMainDenom(c, chain.getChain(), denomTv);
        } else if (coin.denom.equals(TOKEN_HARD)) {
            denomTv.setText(coin.denom.toUpperCase());
            denomTv.setTextColor(c.getResources().getColor(R.color.colorHard));
        } else if (coin.denom.equals(TOKEN_USDX)) {
            denomTv.setText(coin.denom.toUpperCase());
            denomTv.setTextColor(c.getResources().getColor(R.color.colorUsdx));
        } else if (coin.denom.equals(TOKEN_SWP)) {
            denomTv.setText(coin.denom.toUpperCase());
            denomTv.setTextColor(c.getResources().getColor(R.color.colorSwp));
        } else {
            denomTv.setText(coin.denom.toUpperCase());
            denomTv.setTextColor(c.getResources().getColor(R.color.colorWhite));
        }
        amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), WUtil.getKavaCoinDecimal(coin), WUtil.getKavaCoinDecimal(coin)));
    } else if (chain.equals(IOV_MAIN)) {
        if (coin.denom.equals(TOKEN_IOV)) {
            DpMainDenom(c, chain.getChain(), denomTv);
        } else {
            denomTv.setText(coin.denom.toUpperCase());
        }
        amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), 6, 6));
    } else if (chain.equals(BNB_MAIN)) {
        if (coin.denom.equals(TOKEN_BNB)) {
            DpMainDenom(c, chain.getChain(), denomTv);
        } else {
            denomTv.setText(coin.denom.toUpperCase());
        }
        amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), 8, 8));
    } else if (chain.equals(BAND_MAIN)) {
        if (coin.denom.equals(TOKEN_BAND)) {
            DpMainDenom(c, chain.getChain(), denomTv);
        } else {
            denomTv.setTextColor(c.getResources().getColor(R.color.colorWhite));
            denomTv.setText(coin.denom.toUpperCase());
        }
        amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), 6, 6));
    } else if (chain.equals(OKEX_MAIN)) {
        if (coin.denom.equals(TOKEN_OK)) {
            DpMainDenom(c, chain.getChain(), denomTv);
        } else {
            denomTv.setText(coin.denom.toUpperCase());
        }
        amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), 0, 18));
    } else if (chain.equals(CERTIK_MAIN)) {
        if (coin.denom.equals(TOKEN_CERTIK)) {
            DpMainDenom(c, chain.getChain(), denomTv);
        } else {
            denomTv.setTextColor(c.getResources().getColor(R.color.colorWhite));
            denomTv.setText(coin.denom.toUpperCase());
        }
        amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), 6, 6));
    } else if (chain.equals(SECRET_MAIN)) {
        if (coin.denom.equals(TOKEN_SECRET)) {
            DpMainDenom(c, chain.getChain(), denomTv);
        } else {
            denomTv.setTextColor(c.getResources().getColor(R.color.colorWhite));
            denomTv.setText(coin.denom.toUpperCase());
        }
        amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), 6, 6));
    } else if (chain.equals(AKASH_MAIN)) {
        if (coin.denom.equals(TOKEN_AKASH)) {
            DpMainDenom(c, chain.getChain(), denomTv);
        } else {
            denomTv.setTextColor(c.getResources().getColor(R.color.colorWhite));
            denomTv.setText(coin.denom.toUpperCase());
        }
        amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), 6, 6));
    } else if (chain.equals(PERSIS_MAIN)) {
        if (coin.denom.equals(TOKEN_XPRT)) {
            DpMainDenom(c, chain.getChain(), denomTv);
        } else {
            denomTv.setTextColor(c.getResources().getColor(R.color.colorWhite));
            denomTv.setText(coin.denom.toUpperCase());
        }
        amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), 6, 6));
    } else if (chain.equals(SENTINEL_MAIN)) {
        if (coin.denom.equals(TOKEN_DVPN)) {
            DpMainDenom(c, chain.getChain(), denomTv);
        } else {
            denomTv.setTextColor(c.getResources().getColor(R.color.colorWhite));
            denomTv.setText(coin.denom.toUpperCase());
        }
        amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), 6, 6));
    } else if (chain.equals(FETCHAI_MAIN)) {
        if (coin.denom.equals(TOKEN_FET)) {
            DpMainDenom(c, chain.getChain(), denomTv);
        } else {
            denomTv.setTextColor(c.getResources().getColor(R.color.colorWhite));
            denomTv.setText(coin.denom.toUpperCase());
        }
        amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), 18, 18));
    } else if (chain.equals(CRYPTO_MAIN)) {
        if (coin.denom.equals(TOKEN_CRO)) {
            DpMainDenom(c, chain.getChain(), denomTv);
        } else {
            denomTv.setTextColor(c.getResources().getColor(R.color.colorWhite));
            denomTv.setText(coin.denom.toUpperCase());
        }
        amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), 8, 8));
    } else if (chain.equals(SIF_MAIN)) {
        int decimal = WUtil.getSifCoinDecimal(coin.denom);
        if (coin.denom.equals(TOKEN_SIF)) {
            DpMainDenom(c, chain.getChain(), denomTv);
        } else if (coin.denom.startsWith("c")) {
            denomTv.setText(coin.denom.substring(1).toUpperCase());
            denomTv.setTextColor(c.getResources().getColor(R.color.colorWhite));
        } else {
            denomTv.setText(coin.denom.toUpperCase());
            denomTv.setTextColor(c.getResources().getColor(R.color.colorWhite));
        }
        amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), decimal, decimal));
    } else if (chain.equals(KI_MAIN)) {
        if (coin.denom.equals(TOKEN_KI)) {
            DpMainDenom(c, chain.getChain(), denomTv);
        } else {
            denomTv.setTextColor(c.getResources().getColor(R.color.colorWhite));
            denomTv.setText(coin.denom.toUpperCase());
        }
        amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), 6, 6));
    } else if (chain.equals(OSMOSIS_MAIN)) {
        if (coin.denom.equals(TOKEN_OSMOSIS)) {
            DpMainDenom(c, chain.getChain(), denomTv);
            amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), 6, 6));
        } else if (coin.denom.equals(TOKEN_ION)) {
            denomTv.setText("ION");
            denomTv.setTextColor(c.getResources().getColor(R.color.colorIon));
            amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), 6, 6));
        } else if (coin.osmosisAmm()) {
            denomTv.setText(coin.osmosisAmmDpDenom());
            denomTv.setTextColor(c.getResources().getColor(R.color.colorWhite));
            amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), 18, 18));
        } else {
            denomTv.setText(coin.denom.toUpperCase());
            denomTv.setTextColor(c.getResources().getColor(R.color.colorWhite));
            amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), 6, 6));
        }
    } else if (chain.equals(MEDI_MAIN)) {
        if (coin.denom.equals(TOKEN_MEDI)) {
            DpMainDenom(c, chain.getChain(), denomTv);
        } else {
            denomTv.setTextColor(c.getResources().getColor(R.color.colorWhite));
            denomTv.setText(coin.denom.toUpperCase());
        }
        amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), 6, 6));
    } else if (chain.equals(EMONEY_MAIN)) {
        if (coin.denom.equals(TOKEN_NGM)) {
            DpMainDenom(c, chain.getChain(), denomTv);
        } else {
            denomTv.setText(coin.denom.toUpperCase());
            denomTv.setTextColor(c.getResources().getColor(R.color.colorWhite));
        }
        amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), 6, 6));
    } else if (chain.equals(RIZON_MAIN)) {
        if (coin.denom.equals(TOKEN_RIZON)) {
            DpMainDenom(c, chain.getChain(), denomTv);
        } else {
            denomTv.setTextColor(c.getResources().getColor(R.color.colorWhite));
            denomTv.setText(coin.denom.toUpperCase());
        }
        amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), 6, 6));
    } else if (chain.equals(JUNO_MAIN)) {
        if (coin.denom.equals(TOKEN_JUNO)) {
            DpMainDenom(c, chain.getChain(), denomTv);
        } else {
            denomTv.setTextColor(c.getResources().getColor(R.color.colorWhite));
            denomTv.setText(coin.denom.toUpperCase());
        }
        amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), 6, 6));
    } else if (chain.equals(REGEN_MAIN)) {
        if (coin.denom.equals(TOKEN_REGEN)) {
            DpMainDenom(c, chain.getChain(), denomTv);
        } else {
            denomTv.setTextColor(c.getResources().getColor(R.color.colorWhite));
            denomTv.setText(coin.denom.toUpperCase());
        }
        amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), 6, 6));
    } else if (chain.equals(BITCANNA_MAIN)) {
        if (coin.denom.equals(TOKEN_BITCANNA)) {
            DpMainDenom(c, chain.getChain(), denomTv);
        } else {
            denomTv.setTextColor(c.getResources().getColor(R.color.colorWhite));
            denomTv.setText(coin.denom.toUpperCase());
        }
        amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), 6, 6));
    } else if (chain.equals(ALTHEA_MAIN)) {
        if (coin.denom.equals(TOKEN_ALTHEA)) {
            DpMainDenom(c, chain.getChain(), denomTv);
        } else {
            denomTv.setTextColor(c.getResources().getColor(R.color.colorWhite));
            denomTv.setText(coin.denom.toUpperCase());
        }
        amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), 6, 6));
    } else if (chain.equals(STARGAZE_MAIN)) {
        if (coin.denom.equals(TOKEN_STARGAZE)) {
            DpMainDenom(c, chain.getChain(), denomTv);
        } else {
            denomTv.setTextColor(c.getResources().getColor(R.color.colorWhite));
            denomTv.setText(coin.denom.toUpperCase());
        }
        amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), 6, 6));
    } else if (chain.equals(GRABRIDGE_MAIN)) {
        int decimal = WUtil.getGBridgeCoinDecimal(baseData, coin.denom);
        if (coin.denom.equals(TOKEN_GRABRIDGE)) {
            DpMainDenom(c, chain.getChain(), denomTv);
        } else if (coin.denom.startsWith("gravity")) {
            final Assets assets = baseData.getAsset(coin.denom);
            if (assets != null) {
                denomTv.setText(assets.origin_symbol);
                denomTv.setTextColor(c.getResources().getColor(R.color.colorWhite));
            }
        } else {
            denomTv.setTextColor(c.getResources().getColor(R.color.colorWhite));
            denomTv.setText(coin.denom.toUpperCase());
        }
        amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), decimal, decimal));
    } else if (chain.equals(COMDEX_MAIN)) {
        if (coin.denom.equals(TOKEN_COMDEX)) {
            DpMainDenom(c, chain.getChain(), denomTv);
        } else {
            denomTv.setTextColor(c.getResources().getColor(R.color.colorWhite));
            denomTv.setText(coin.denom.toUpperCase());
        }
        amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), 6, 6));
    } else if (chain.equals(INJ_MAIN)) {
        if (coin.denom.equals(TOKEN_INJ)) {
            DpMainDenom(c, chain.getChain(), denomTv);
            amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), 18, 18));
        } else if (coin.denom.startsWith("peggy")) {
            final Assets assets = baseData.getAsset(coin.denom);
            if (assets != null) {
                denomTv.setText(assets.origin_symbol);
                denomTv.setTextColor(c.getResources().getColor(R.color.colorWhite));
                amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), assets.decimal, assets.decimal));
            }
        } else {
            denomTv.setText(coin.denom.toUpperCase());
            denomTv.setTextColor(c.getResources().getColor(R.color.colorWhite));
            amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), 18, 18));
        }
    } else if (chain.equals(BITSONG_MAIN)) {
        if (coin.denom.equals(TOKEN_BITSONG)) {
            DpMainDenom(c, chain.getChain(), denomTv);
        } else {
            denomTv.setTextColor(c.getResources().getColor(R.color.colorWhite));
            denomTv.setText(coin.denom.toUpperCase());
        }
        amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), 6, 6));
    } else if (chain.equals(DESMOS_MAIN)) {
        if (coin.denom.equals(TOKEN_DESMOS)) {
            DpMainDenom(c, chain.getChain(), denomTv);
        } else {
            denomTv.setTextColor(c.getResources().getColor(R.color.colorWhite));
            denomTv.setText(coin.denom.toUpperCase());
        }
        amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), 6, 6));
    } else if (chain.equals(LUM_MAIN)) {
        if (coin.denom.equals(TOKEN_LUM)) {
            DpMainDenom(c, chain.getChain(), denomTv);
        } else {
            denomTv.setTextColor(c.getResources().getColor(R.color.colorWhite));
            denomTv.setText(coin.denom.toUpperCase());
        }
        amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), 6, 6));
    } else if (chain.equals(CHIHUAHUA_MAIN)) {
        if (coin.denom.equals(TOKEN_CHIHUAHUA)) {
            DpMainDenom(c, chain.getChain(), denomTv);
        } else {
            denomTv.setTextColor(c.getResources().getColor(R.color.colorWhite));
            denomTv.setText(coin.denom.toUpperCase());
        }
        amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), 6, 6));
    } else if (chain.equals(AXELAR_MAIN)) {
        if (coin.denom.equals(TOKEN_AXELAR)) {
            DpMainDenom(c, chain.getChain(), denomTv);
        } else {
            denomTv.setTextColor(c.getResources().getColor(R.color.colorWhite));
            denomTv.setText(coin.denom.toUpperCase());
        }
        amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), 6, 6));
    } else if (chain.equals(KONSTELL_MAIN)) {
        if (coin.denom.equals(TOKEN_DARC)) {
            DpMainDenom(c, chain.getChain(), denomTv);
        } else {
            denomTv.setTextColor(c.getResources().getColor(R.color.colorWhite));
            denomTv.setText(coin.denom.toUpperCase());
        }
        amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), 6, 6));
    } else if (chain.equals(UMEE_MAIN)) {
        if (coin.denom.equals(TOKEN_UMEE)) {
            DpMainDenom(c, chain.getChain(), denomTv);
        } else {
            denomTv.setTextColor(c.getResources().getColor(R.color.colorWhite));
            denomTv.setText(coin.denom.toUpperCase());
        }
        amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), 6, 6));
    } else if (chain.equals(EVMOS_MAIN)) {
        if (coin.denom.equals(TOKEN_EVMOS)) {
            DpMainDenom(c, chain.getChain(), denomTv);
        } else {
            denomTv.setTextColor(c.getResources().getColor(R.color.colorWhite));
            denomTv.setText(coin.denom.toUpperCase());
        }
        amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), 18, 18));
    } else if (chain.equals(CUDOS_MAIN)) {
        if (coin.denom.equals(TOKEN_CUDOS)) {
            DpMainDenom(c, chain.getChain(), denomTv);
        } else {
            denomTv.setTextColor(c.getResources().getColor(R.color.colorWhite));
            denomTv.setText(coin.denom.toUpperCase());
        }
        amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), 18, 18));
    } else if (chain.equals(PROVENANCE_MAIN)) {
        if (coin.denom.equals(TOKEN_HASH)) {
            DpMainDenom(c, chain.getChain(), denomTv);
        } else {
            denomTv.setTextColor(c.getResources().getColor(R.color.colorWhite));
            denomTv.setText(coin.denom.toUpperCase());
        }
        amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), 9, 9));
    } else if (chain.equals(COSMOS_TEST)) {
        if (coin.denom.equals(TOKEN_COSMOS_TEST)) {
            DpMainDenom(c, chain.getChain(), denomTv);
        } else {
            denomTv.setTextColor(c.getResources().getColor(R.color.colorWhite));
            denomTv.setText(coin.denom.toUpperCase());
        }
        amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), 6, 6));
    } else if (chain.equals(IRIS_TEST)) {
        if (coin.denom.equals(TOKEN_IRIS_TEST)) {
            DpMainDenom(c, chain.getChain(), denomTv);
        } else {
            denomTv.setTextColor(c.getResources().getColor(R.color.colorWhite));
            denomTv.setText(coin.denom.toUpperCase());
        }
        amountTv.setText(getDpAmount2(c, new BigDecimal(coin.amount), 6, 6));
    }
}
Also used : IbcToken(wannabit.io.cosmostaion.dao.IbcToken) Assets(wannabit.io.cosmostaion.dao.Assets) Cw20Assets(wannabit.io.cosmostaion.dao.Cw20Assets) BigDecimal(java.math.BigDecimal)

Example 2 with Assets

use of wannabit.io.cosmostaion.dao.Assets in project cosmostation-android by cosmostation.

the class WUtil method DpSifTokenImg.

public static void DpSifTokenImg(BaseData baseData, ImageView imageView, String denom) {
    if (denom != null) {
        if (denom.equalsIgnoreCase(TOKEN_SIF)) {
            Picasso.get().cancelRequest(imageView);
            imageView.setImageResource(R.drawable.tokensifchain);
        } else if (denom.startsWith("c")) {
            Assets assets = baseData.getAsset(denom);
            if (assets != null) {
                Picasso.get().load(ASSET_IMG_URL + assets.logo).fit().placeholder(R.drawable.token_ic).error(R.drawable.token_ic).into(imageView);
            }
        } else if (denom.startsWith("ibc/")) {
            IbcToken ibcToken = baseData.getIbcToken(denom.replaceAll("ibc/", ""));
            try {
                Picasso.get().load(ibcToken.moniker).fit().placeholder(R.drawable.token_default_ibc).error(R.drawable.token_default_ibc).into(imageView);
            } catch (Exception e) {
            }
        }
    }
}
Also used : IbcToken(wannabit.io.cosmostaion.dao.IbcToken) Assets(wannabit.io.cosmostaion.dao.Assets) Cw20Assets(wannabit.io.cosmostaion.dao.Cw20Assets) JSONException(org.json.JSONException) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) CertificateException(java.security.cert.CertificateException)

Example 3 with Assets

use of wannabit.io.cosmostaion.dao.Assets in project cosmostation-android by cosmostation.

the class MainTokensFragment method onBindErcToken.

// with Erc gRPC
private void onBindErcToken(TokensAdapter.AssetHolder holder, int position) {
    final Coin coin = mEtherGrpc.get(position);
    final Assets assets = getBaseDao().getAsset(coin.denom);
    if (assets != null) {
        holder.itemSymbol.setText(assets.origin_symbol);
        holder.itemSymbol.setTextColor(getResources().getColor(R.color.colorWhite));
        holder.itemInnerSymbol.setText("");
        holder.itemFullName.setText(assets.display_symbol);
        Picasso.get().load(ASSET_IMG_URL + assets.logo).fit().placeholder(R.drawable.token_ic).error(R.drawable.token_ic).into(holder.itemImg);
        BigDecimal totalAmount = getBaseDao().getAvailable(assets.denom);
        holder.itemBalance.setText(WDp.getDpAmount2(getContext(), totalAmount, assets.decimal, 6));
        holder.itemValue.setText(WDp.dpUserCurrencyValue(getBaseDao(), assets.origin_symbol, totalAmount, assets.decimal));
        holder.itemRoot.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getMainActivity(), BridgeTokenGrpcActivity.class);
                intent.putExtra("denom", assets.denom);
                startActivity(intent);
            }
        });
    }
}
Also used : Coin(wannabit.io.cosmostaion.model.type.Coin) Assets(wannabit.io.cosmostaion.dao.Assets) Cw20Assets(wannabit.io.cosmostaion.dao.Cw20Assets) Intent(android.content.Intent) ImageView(android.widget.ImageView) CardView(androidx.cardview.widget.CardView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) BridgeTokenGrpcActivity(wannabit.io.cosmostaion.activities.tokenDetail.BridgeTokenGrpcActivity) BigDecimal(java.math.BigDecimal)

Example 4 with Assets

use of wannabit.io.cosmostaion.dao.Assets in project cosmostation-android by cosmostation.

the class TokenDetailSupportHolder method onBindBridgeToken.

public void onBindBridgeToken(Context c, BaseChain baseChain, BaseData baseData, String denom) {
    final Assets assets = baseData.getAsset(denom);
    if (assets != null) {
        mAvailableAmount = baseData.getAvailable(assets.denom);
        mTvTotal.setText(WDp.getDpAmount2(c, mAvailableAmount, assets.decimal, assets.decimal));
        mTvAvailable.setText(WDp.getDpAmount2(c, mAvailableAmount, assets.decimal, assets.decimal));
    }
}
Also used : Cw20Assets(wannabit.io.cosmostaion.dao.Cw20Assets) Assets(wannabit.io.cosmostaion.dao.Assets)

Example 5 with Assets

use of wannabit.io.cosmostaion.dao.Assets in project cosmostation-android by cosmostation.

the class WDp method allAssetToUserCurrency.

public static BigDecimal allAssetToUserCurrency(BaseChain baseChain, BaseData baseData) {
    BigDecimal totalValue = BigDecimal.ZERO;
    if (isGRPC(baseChain)) {
        for (Coin coin : baseData.mGrpcBalance) {
            if (coin.denom.equals(mainDenom(baseChain))) {
                BigDecimal amount = baseData.getAllMainAsset(mainDenom(baseChain));
                BigDecimal assetValue = userCurrencyValue(baseData, coin.denom, amount, mainDivideDecimal(baseChain));
                totalValue = totalValue.add(assetValue);
            } else if (baseChain.equals(COSMOS_MAIN) && coin.denom.startsWith("pool")) {
                BigDecimal amount = baseData.getAvailable(coin.denom);
                BigDecimal assetValue = userCurrencyValue(baseData, coin.denom, amount, 6);
                totalValue = totalValue.add(assetValue);
            } else if (baseChain.equals(OSMOSIS_MAIN) && coin.denom.equals(TOKEN_ION) || baseChain.equals(CRESCENT_MAIN) && coin.denom.equals(TOKEN_BCRE) || baseChain.equals(NYX_MAIN) && coin.denom.equals(TOKEN_NYM)) {
                BigDecimal amount = baseData.getAvailable(coin.denom);
                BigDecimal assetValue = userCurrencyValue(baseData, coin.denom, amount, 6);
                totalValue = totalValue.add(assetValue);
            } else if (baseChain.equals(OSMOSIS_MAIN) && coin.denom.contains("gamm/pool")) {
                BigDecimal amount = baseData.getAvailable(coin.denom);
                BigDecimal assetValue = userCurrencyValue(baseData, coin.denom, amount, 18);
                totalValue = totalValue.add(assetValue);
            } else if (baseChain.equals(SIF_MAIN) && coin.denom.startsWith("c")) {
                BigDecimal amount = baseData.getAvailable(coin.denom);
                int decimal = WUtil.getSifCoinDecimal(baseData, coin.denom);
                BigDecimal assetValue = userCurrencyValue(baseData, coin.denom.substring(1), amount, decimal);
                totalValue = totalValue.add(assetValue);
            } else if (baseChain.equals(EMONEY_MAIN) || coin.denom.startsWith("e")) {
                BigDecimal available = baseData.getAvailable(coin.denom);
                totalValue = totalValue.add(userCurrencyValue(baseData, coin.denom, available, 6));
            } else if (baseChain.equals(KAVA_MAIN) && !coin.isIbc()) {
                BigDecimal amount = baseData.getAvailable(coin.denom);
                amount = amount.add(baseData.getVesting(coin.denom));
                String kavaDenom = WDp.getKavaBaseDenom(coin.denom);
                int kavaDecimal = WUtil.getKavaCoinDecimal(baseData, coin.denom);
                BigDecimal assetValue = userCurrencyValue(baseData, kavaDenom, amount, kavaDecimal);
                totalValue = totalValue.add(assetValue);
            } else if (baseChain.equals(GRABRIDGE_MAIN) && coin.denom.startsWith("gravity")) {
                Assets assets = baseData.getAsset(coin.denom);
                BigDecimal available = baseData.getAvailable(assets.denom);
                totalValue = totalValue.add(userCurrencyValue(baseData, assets.origin_symbol, available, assets.decimal));
            } else if (baseChain.equals(INJ_MAIN) && coin.denom.startsWith("peggy")) {
                Assets assets = baseData.getAsset(coin.denom);
                BigDecimal available = baseData.getAvailable(assets.denom);
                totalValue = totalValue.add(userCurrencyValue(baseData, assets.origin_symbol, available, assets.decimal));
            } else if (coin.isIbc()) {
                BigDecimal amount = baseData.getAvailable(coin.denom);
                IbcToken ibcToken = baseData.getIbcToken(coin.denom);
                if (ibcToken != null && ibcToken.auth) {
                    BigDecimal assetValue = userCurrencyValue(baseData, ibcToken.base_denom, amount, ibcToken.decimal);
                    totalValue = totalValue.add(assetValue);
                }
            }
        }
        if (baseData.getCw20sGrpc(baseChain).size() > 0) {
            for (Cw20Assets assets : baseData.getCw20sGrpc(baseChain)) {
                BigDecimal amount = assets.getAmount();
                totalValue = totalValue.add(userCurrencyValue(baseData, assets.denom, amount, assets.decimal));
            }
        }
    } else if (baseChain.equals(BNB_MAIN)) {
        for (Balance balance : baseData.mBalances) {
            if (balance.symbol.equals(mainDenom(baseChain))) {
                BigDecimal amount = baseData.getAllBnbTokenAmount(balance.symbol);
                BigDecimal assetValue = userCurrencyValue(baseData, TOKEN_BNB, amount, mainDivideDecimal(baseChain));
                totalValue = totalValue.add(assetValue);
            } else {
                BigDecimal amount = baseData.getAllBnbTokenAmount(balance.symbol);
                BigDecimal convertAmount = WUtil.getBnbConvertAmount(baseData, balance.symbol, amount);
                BigDecimal assetValue = userCurrencyValue(baseData, TOKEN_BNB, convertAmount, mainDivideDecimal(baseChain));
                totalValue = totalValue.add(assetValue);
            }
        }
    } else if (baseChain.equals(OKEX_MAIN)) {
        for (Balance balance : baseData.mBalances) {
            if (balance.symbol.equals(mainDenom(baseChain))) {
                BigDecimal amount = baseData.getAllExToken(balance.symbol);
                BigDecimal assetValue = userCurrencyValue(baseData, TOKEN_OK, amount, mainDivideDecimal(baseChain));
                totalValue = totalValue.add(assetValue);
            } else {
                BigDecimal convertAmount = convertTokenToOkt(baseData, balance.symbol);
                BigDecimal assetValue = userCurrencyValue(baseData, TOKEN_OK, convertAmount, mainDivideDecimal(baseChain));
                totalValue = totalValue.add(assetValue);
            }
        }
    } else {
        for (Balance balance : baseData.mBalances) {
            if (balance.symbol.equals(mainDenom(baseChain))) {
                BigDecimal amount = baseData.getAllMainAssetOld(balance.symbol);
                BigDecimal assetValue = userCurrencyValue(baseData, balance.symbol, amount, mainDivideDecimal(baseChain));
                totalValue = totalValue.add(assetValue);
            } else {
            }
        }
    }
    return totalValue;
}
Also used : Coin(wannabit.io.cosmostaion.model.type.Coin) IbcToken(wannabit.io.cosmostaion.dao.IbcToken) Assets(wannabit.io.cosmostaion.dao.Assets) Cw20Assets(wannabit.io.cosmostaion.dao.Cw20Assets) Cw20Assets(wannabit.io.cosmostaion.dao.Cw20Assets) SpannableString(android.text.SpannableString) Balance(wannabit.io.cosmostaion.dao.Balance) BigDecimal(java.math.BigDecimal)

Aggregations

Assets (wannabit.io.cosmostaion.dao.Assets)7 Cw20Assets (wannabit.io.cosmostaion.dao.Cw20Assets)6 BigDecimal (java.math.BigDecimal)5 IbcToken (wannabit.io.cosmostaion.dao.IbcToken)4 Coin (wannabit.io.cosmostaion.model.type.Coin)2 Intent (android.content.Intent)1 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 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)1 CertificateException (java.security.cert.CertificateException)1 JSONException (org.json.JSONException)1 BridgeTokenGrpcActivity (wannabit.io.cosmostaion.activities.tokenDetail.BridgeTokenGrpcActivity)1 Balance (wannabit.io.cosmostaion.dao.Balance)1