Search in sources :

Example 1 with IbcToken

use of wannabit.io.cosmostaion.dao.IbcToken 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 IbcToken

use of wannabit.io.cosmostaion.dao.IbcToken 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 IbcToken

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

the class WDp method allAssetToBtc.

public static BigDecimal allAssetToBtc(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 btcValue = btcValue(baseData, coin.denom, amount, mainDivideDecimal(baseChain));
                totalValue = totalValue.add(btcValue);
            } else if (baseChain.equals(OSMOSIS_MAIN) && coin.denom.equals(TOKEN_ION)) {
                BigDecimal amount = baseData.getAvailable(coin.denom);
                BigDecimal btcValue = btcValue(baseData, coin.denom, amount, 6);
                totalValue = totalValue.add(btcValue);
            } else if (baseChain.equals(SIF_MAIN) && coin.denom.startsWith("c")) {
                BigDecimal amount = baseData.getAvailable(coin.denom);
                int decimal = WUtil.getSifCoinDecimal(baseData, coin.denom);
                BigDecimal btcValue = btcValue(baseData, coin.denom.substring(1), amount, decimal);
                totalValue = totalValue.add(btcValue);
            } else if (baseChain.equals(KAVA_MAIN)) {
                if (coin.denom.equals(mainDenom(baseChain))) {
                    BigDecimal amount = baseData.getAllMainAsset(coin.denom);
                    BigDecimal btcValue = btcValue(baseData, TOKEN_KAVA, amount, mainDivideDecimal(baseChain));
                    totalValue = totalValue.add(btcValue);
                } else {
                    BigDecimal convertAmount = convertTokenToKava(baseData, coin.denom);
                    BigDecimal btcValue = btcValue(baseData, TOKEN_KAVA, convertAmount, mainDivideDecimal(baseChain));
                    totalValue = totalValue.add(btcValue);
                }
            } else if (coin.denom.startsWith("ibc/")) {
                BigDecimal amount = baseData.getAvailable(coin.denom);
                IbcToken ibcToken = baseData.getIbcToken(coin.denom);
                if (ibcToken != null && ibcToken.auth) {
                    BigDecimal btcValue = btcValue(baseData, ibcToken.base_denom, amount, ibcToken.decimal);
                    totalValue = totalValue.add(btcValue);
                }
            }
        }
    } else if (baseChain.equals(BNB_MAIN)) {
        for (Balance balance : baseData.mBalances) {
            if (balance.symbol.equals(mainDenom(baseChain))) {
                BigDecimal amount = baseData.getAllBnbTokenAmount(balance.symbol);
                BigDecimal btcValue = btcValue(baseData, TOKEN_BNB, amount, mainDivideDecimal(baseChain));
                totalValue = totalValue.add(btcValue);
            } else {
                BigDecimal amount = baseData.getAllBnbTokenAmount(balance.symbol);
                BigDecimal convertAmount = WUtil.getBnbConvertAmount(baseData, balance.symbol, amount);
                BigDecimal btcValue = btcValue(baseData, TOKEN_BNB, convertAmount, mainDivideDecimal(baseChain));
                totalValue = totalValue.add(btcValue);
            }
        }
    } else if (baseChain.equals(OKEX_MAIN)) {
        for (Balance balance : baseData.mBalances) {
            if (balance.symbol.equals(mainDenom(baseChain))) {
                BigDecimal amount = baseData.getAllExToken(balance.symbol);
                BigDecimal btcValue = btcValue(baseData, TOKEN_OK, amount, mainDivideDecimal(baseChain));
                totalValue = totalValue.add(btcValue);
            } else {
                BigDecimal convertAmount = convertTokenToOkt(baseData, balance.symbol);
                BigDecimal btcValue = btcValue(baseData, TOKEN_OK, convertAmount, mainDivideDecimal(baseChain));
                totalValue = totalValue.add(btcValue);
            }
        }
    } else {
        for (Balance balance : baseData.mBalances) {
            if (balance.symbol.equals(mainDenom(baseChain))) {
                BigDecimal amount = baseData.getAllMainAssetOld(balance.symbol);
                BigDecimal btcValue = btcValue(baseData, balance.symbol, amount, mainDivideDecimal(baseChain));
                totalValue = totalValue.add(btcValue);
            } else {
            }
        }
    }
    return totalValue;
}
Also used : Coin(wannabit.io.cosmostaion.model.type.Coin) IbcToken(wannabit.io.cosmostaion.dao.IbcToken) Balance(wannabit.io.cosmostaion.dao.Balance) BigDecimal(java.math.BigDecimal)

Example 4 with IbcToken

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

the class MainTokensFragment method onUpdateView.

private void onUpdateView() {
    final String mainDenom = WDp.mainDenom(getMainActivity().mBaseChain);
    mCW20Grpc = getBaseDao().getCw20sGrpc(getMainActivity().mBaseChain);
    mNativeGrpc.clear();
    mIbcAuthedGrpc.clear();
    mPoolGrpc.clear();
    mEtherGrpc.clear();
    mIbcUnknownGrpc.clear();
    mGravityDexGrpc.clear();
    mInjectivePoolGrpc.clear();
    mKavaBep2Grpc.clear();
    mEtcGrpc.clear();
    mUnknownGrpc.clear();
    for (Coin coin : getBaseDao().mGrpcBalance) {
        if (coin.denom.equalsIgnoreCase(mainDenom)) {
            mNativeGrpc.add(coin);
        } else if (coin.isIbc()) {
            final IbcToken ibcToken = getBaseDao().getIbcToken(coin.getIbcHash());
            if (ibcToken != null && ibcToken.auth) {
                mIbcAuthedGrpc.add(coin);
            } else {
                mIbcUnknownGrpc.add(coin);
            }
        } else if (getMainActivity().mBaseChain.equals(OSMOSIS_MAIN) && coin.osmosisAmm() || getMainActivity().mBaseChain.equals(CRESCENT_MAIN) && coin.crescnetPool()) {
            mPoolGrpc.add(coin);
        } else if (getMainActivity().mBaseChain.equals(OSMOSIS_MAIN) && coin.denom.equalsIgnoreCase(TOKEN_ION) || getMainActivity().mBaseChain.equals(EMONEY_MAIN) && coin.denom.startsWith("e") || getMainActivity().mBaseChain.equals(CRESCENT_MAIN) && coin.denom.equalsIgnoreCase(TOKEN_BCRE) || getMainActivity().mBaseChain.equals(NYX_MAIN) && coin.denom.equalsIgnoreCase(TOKEN_NYM)) {
            mNativeGrpc.add(coin);
        } else if (getMainActivity().mBaseChain.equals(SIF_MAIN) && coin.denom.startsWith("c") || getMainActivity().mBaseChain.equals(GRABRIDGE_MAIN) && coin.denom.startsWith("gravity") || getMainActivity().mBaseChain.equals(INJ_MAIN) && coin.denom.startsWith("peggy")) {
            mEtherGrpc.add(coin);
        } else if (getMainActivity().mBaseChain.equals(COSMOS_MAIN) && coin.denom.startsWith("pool")) {
            mGravityDexGrpc.add(coin);
        } else if (getMainActivity().mBaseChain.equals(INJ_MAIN) && coin.denom.startsWith("share")) {
            mInjectivePoolGrpc.add(coin);
        } else if (getMainActivity().mBaseChain.equals(KAVA_MAIN)) {
            if (coin.denom.equals(TOKEN_HARD) || coin.denom.equalsIgnoreCase(TOKEN_USDX) || coin.denom.equalsIgnoreCase(TOKEN_SWP)) {
                mNativeGrpc.add(coin);
            } else if (coin.denom.equalsIgnoreCase(TOKEN_HTLC_KAVA_BNB) || coin.denom.equalsIgnoreCase(TOKEN_HTLC_KAVA_BTCB) || coin.denom.equalsIgnoreCase(TOKEN_HTLC_KAVA_XRPB) || coin.denom.equalsIgnoreCase(TOKEN_HTLC_KAVA_BUSD)) {
                mKavaBep2Grpc.add(coin);
            } else if (coin.denom.equalsIgnoreCase("btch") || coin.denom.equalsIgnoreCase("hbtc")) {
                mEtcGrpc.add(coin);
            }
        } else {
            mUnknownGrpc.add(coin);
        }
    }
    mNative.clear();
    mEtc.clear();
    mUnKnown.clear();
    for (Balance balance : getBaseDao().mBalances) {
        if (balance.symbol.equalsIgnoreCase(mainDenom)) {
            mNative.add(balance);
        } else if (getMainActivity().mBaseChain.equals(BNB_MAIN)) {
            mEtc.add(balance);
        } else if (getMainActivity().mBaseChain.equals(OKEX_MAIN)) {
            mEtc.add(balance);
        } else {
            mUnKnown.add(balance);
        }
    }
    if (isGRPC(getMainActivity().mBaseChain)) {
        WUtil.onSortingCoins(mNativeGrpc, getMainActivity().mBaseChain);
        WUtil.onSortingGravityPool(mGravityDexGrpc, getBaseDao());
        WUtil.onSortingOsmosisPool(getMainActivity().mBaseChain, mPoolGrpc);
        WUtil.onSortingInjectivePool(mInjectivePoolGrpc);
    } else if (getMainActivity().mBaseChain.equals(BNB_MAIN) || getMainActivity().mBaseChain.equals(OKEX_MAIN)) {
        WUtil.onSortingNativeCoins(mEtc, getMainActivity().mBaseChain);
    } else {
        WUtil.onSortingNativeCoins(mNative, getMainActivity().mBaseChain);
    }
    if (isGRPC(getMainActivity().mBaseChain)) {
        if (getBaseDao().mGrpcBalance != null && getBaseDao().mGrpcBalance.size() > 0) {
            mTokensAdapter.notifyDataSetChanged();
            mEmptyToken.setVisibility(View.GONE);
            mRecyclerView.setVisibility(View.VISIBLE);
        } else {
            mEmptyToken.setVisibility(View.VISIBLE);
            mRecyclerView.setVisibility(View.GONE);
        }
    } else {
        if (getBaseDao().mBalances != null && getBaseDao().mBalances.size() > 0) {
            mTokensAdapter.notifyDataSetChanged();
            mEmptyToken.setVisibility(View.GONE);
            mRecyclerView.setVisibility(View.VISIBLE);
        } else {
            mEmptyToken.setVisibility(View.VISIBLE);
            mRecyclerView.setVisibility(View.GONE);
        }
    }
}
Also used : Coin(wannabit.io.cosmostaion.model.type.Coin) IbcToken(wannabit.io.cosmostaion.dao.IbcToken) Balance(wannabit.io.cosmostaion.dao.Balance)

Example 5 with IbcToken

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

the class WUtil method dpKavaTokenName.

public static String dpKavaTokenName(Context c, BaseData baseData, TextView textView, String denom) {
    if (denom.equalsIgnoreCase(TOKEN_KAVA)) {
        textView.setTextColor(c.getResources().getColor(R.color.colorKava));
        textView.setText(R.string.str_kava_c);
    } else if (denom.equalsIgnoreCase(TOKEN_HARD)) {
        textView.setTextColor(c.getResources().getColor(R.color.colorHard));
        textView.setText("HARD");
    } else if (denom.equalsIgnoreCase(TOKEN_USDX)) {
        textView.setTextColor(c.getResources().getColor(R.color.colorUsdx));
        textView.setText("USDX");
    } else if (denom.equalsIgnoreCase(TOKEN_SWP)) {
        textView.setTextColor(c.getResources().getColor(R.color.colorSwp));
        textView.setText("SWP");
    } else if (denom.equalsIgnoreCase(TOKEN_HTLC_KAVA_BNB)) {
        textView.setTextColor(c.getResources().getColor(R.color.colorWhite));
        textView.setText("BNB");
    } else if (denom.equalsIgnoreCase(TOKEN_HTLC_KAVA_XRPB) || denom.equalsIgnoreCase("xrbp")) {
        textView.setTextColor(c.getResources().getColor(R.color.colorWhite));
        textView.setText("XRPB");
    } else if (denom.equalsIgnoreCase(TOKEN_HTLC_KAVA_BUSD)) {
        textView.setTextColor(c.getResources().getColor(R.color.colorWhite));
        textView.setText("BUSD");
    } else if (denom.contains("btc")) {
        textView.setTextColor(c.getResources().getColor(R.color.colorWhite));
        textView.setText("BTCB");
    } else if (denom.startsWith("ibc/")) {
        textView.setTextColor(c.getResources().getColor(R.color.colorWhite));
        IbcToken ibcToken = baseData.getIbcToken(denom.replaceAll("ibc/", ""));
        if (ibcToken != null && ibcToken.auth) {
            if (ibcToken.base_denom.startsWith("cw20:")) {
                String cAddress = ibcToken.base_denom.replaceAll("cw20:", "");
                for (Cw20Assets assets : baseData.mCw20Assets) {
                    if (assets.contract_address.equalsIgnoreCase(cAddress)) {
                        textView.setText(assets.denom.toUpperCase());
                    }
                }
            } else {
                textView.setText(ibcToken.display_denom.toUpperCase());
            }
        } else {
            textView.setText("UnKnown");
        }
    }
    return denom;
}
Also used : IbcToken(wannabit.io.cosmostaion.dao.IbcToken) Cw20Assets(wannabit.io.cosmostaion.dao.Cw20Assets) SpannableString(android.text.SpannableString)

Aggregations

IbcToken (wannabit.io.cosmostaion.dao.IbcToken)14 Cw20Assets (wannabit.io.cosmostaion.dao.Cw20Assets)7 BigDecimal (java.math.BigDecimal)6 Coin (wannabit.io.cosmostaion.model.type.Coin)5 SpannableString (android.text.SpannableString)4 Assets (wannabit.io.cosmostaion.dao.Assets)4 Balance (wannabit.io.cosmostaion.dao.Balance)3 Intent (android.content.Intent)2 View (android.view.View)2 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 CardView (androidx.cardview.widget.CardView)2 RecyclerView (androidx.recyclerview.widget.RecyclerView)2 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)2 CertificateException (java.security.cert.CertificateException)2 ArrayList (java.util.ArrayList)2 JSONException (org.json.JSONException)2 BalancerPool (osmosis.gamm.poolmodels.balancer.BalancerPool)2 IBCTokenDetailActivity (wannabit.io.cosmostaion.activities.tokenDetail.IBCTokenDetailActivity)2 IbcPath (wannabit.io.cosmostaion.dao.IbcPath)2