Search in sources :

Example 1 with BnbToken

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

the class MainTokensFragment method onBindNativeItem.

// with native tokens
private void onBindNativeItem(TokensAdapter.AssetHolder holder, int position) {
    final Balance balance = mNative.get(position);
    if (getMainActivity().mBaseChain.equals(BNB_MAIN)) {
        final String denom = mNative.get(position).symbol;
        final BigDecimal amount = getBaseDao().getAllBnbTokenAmount(denom);
        final BnbToken bnbToken = getBaseDao().getBnbToken(denom);
        if (bnbToken != null) {
            holder.itemSymbol.setText(bnbToken.original_symbol.toUpperCase());
            holder.itemInnerSymbol.setText("(" + bnbToken.symbol + ")");
            holder.itemFullName.setText("Binance Chain Native Coin");
            holder.itemImg.setImageDrawable(getResources().getDrawable(R.drawable.bnb_token_img));
            holder.itemSymbol.setTextColor(WDp.getChainColor(getContext(), BNB_MAIN));
            holder.itemBalance.setText(WDp.getDpAmount2(getContext(), amount, 0, 6));
            holder.itemValue.setText(WDp.dpUserCurrencyValue(getBaseDao(), TOKEN_BNB, amount, 0));
        }
        holder.itemRoot.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getMainActivity(), StakingTokenDetailActivity.class);
                startActivity(intent);
            }
        });
    } else if (getMainActivity().mBaseChain.equals(OKEX_MAIN)) {
        final OkToken okToken = getBaseDao().okToken(balance.symbol);
        holder.itemSymbol.setText(okToken.original_symbol.toUpperCase());
        holder.itemInnerSymbol.setText("(" + okToken.symbol + ")");
        holder.itemFullName.setText("OKC Staking Coin");
        if (balance.symbol.equals(TOKEN_OK)) {
            holder.itemSymbol.setTextColor(WDp.getChainColor(getContext(), getMainActivity().mBaseChain));
            holder.itemImg.setImageDrawable(getResources().getDrawable(R.drawable.token_okx));
            BigDecimal totalAmount = getBaseDao().getAllExToken(balance.symbol);
            holder.itemBalance.setText(WDp.getDpAmount2(getContext(), totalAmount, 0, 6));
            holder.itemValue.setText(WDp.dpUserCurrencyValue(getBaseDao(), balance.symbol, totalAmount, 0));
        }
        holder.itemRoot.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getMainActivity(), StakingTokenDetailActivity.class);
                startActivity(intent);
            }
        });
    }
}
Also used : BnbToken(wannabit.io.cosmostaion.dao.BnbToken) Intent(android.content.Intent) OkToken(wannabit.io.cosmostaion.dao.OkToken) StakingTokenDetailActivity(wannabit.io.cosmostaion.activities.tokenDetail.StakingTokenDetailActivity) Balance(wannabit.io.cosmostaion.dao.Balance) ImageView(android.widget.ImageView) CardView(androidx.cardview.widget.CardView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) BigDecimal(java.math.BigDecimal)

Example 2 with BnbToken

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

the class NativeTokenDetailActivity method onUpdateView.

private void onUpdateView() {
    mBtnAddressPopup.setCardBackgroundColor(WDp.getChainBgColor(NativeTokenDetailActivity.this, mBaseChain));
    if (mBaseChain.equals(OKEX_MAIN)) {
        final OkToken okToken = getBaseDao().okToken(mDenom);
        Picasso.get().load(OKEX_COIN_IMG_URL + okToken.original_symbol + ".png").placeholder(R.drawable.token_ic).error(R.drawable.token_ic).fit().into(mToolbarSymbolImg);
        mToolbarSymbol.setText(okToken.original_symbol.toUpperCase());
        mToolbarSymbol.setTextColor(getResources().getColor(R.color.colorWhite));
        BigDecimal convertedOktAmount = WDp.convertTokenToOkt(getBaseDao(), mDenom);
        mTotalValue.setText(WDp.dpUserCurrencyValue(getBaseDao(), TOKEN_OK, convertedOktAmount, 0));
        if (okToken.original_symbol.equalsIgnoreCase("okb")) {
            mItemPerPrice.setText(WDp.dpPerUserCurrencyValue(getBaseDao(), "okb"));
            mItemUpDownPrice.setText(WDp.dpValueChange(getBaseDao(), "okb"));
            final BigDecimal lastUpDown = WDp.valueChange(getBaseDao(), "okb");
            if (lastUpDown.compareTo(BigDecimal.ZERO) > 0) {
                mItemUpDownImg.setVisibility(View.VISIBLE);
                mItemUpDownImg.setImageDrawable(getResources().getDrawable(R.drawable.ic_price_up));
            } else if (lastUpDown.compareTo(BigDecimal.ZERO) < 0) {
                mItemUpDownImg.setVisibility(View.VISIBLE);
                mItemUpDownImg.setImageDrawable(getResources().getDrawable(R.drawable.ic_price_down));
            } else {
                mItemUpDownImg.setVisibility(View.INVISIBLE);
            }
        } else {
            mItemPerPrice.setText("");
            mItemUpDownPrice.setText("");
            mItemUpDownImg.setVisibility(View.INVISIBLE);
        }
    } else if (mBaseChain.equals(BNB_MAIN)) {
        final BigDecimal amount = getBaseDao().getAllBnbTokenAmount(mDenom);
        final BnbToken bnbToken = getBaseDao().getBnbToken(mDenom);
        Picasso.get().load(BINANCE_TOKEN_IMG_URL + bnbToken.original_symbol + ".png").placeholder(R.drawable.token_ic).error(R.drawable.token_ic).fit().into(mToolbarSymbolImg);
        mToolbarSymbol.setText(bnbToken.original_symbol.toUpperCase());
        mToolbarSymbol.setTextColor(getResources().getColor(R.color.colorWhite));
        BigDecimal convertedBnbAmount = WUtil.getBnbConvertAmount(getBaseDao(), mDenom, amount);
        mTotalValue.setText(WDp.dpUserCurrencyValue(getBaseDao(), TOKEN_BNB, convertedBnbAmount, 0));
        mItemPerPrice.setText(WUtil.dpBnbTokenUserCurrencyPrice(getBaseDao(), mDenom));
        mItemUpDownPrice.setText("");
        mItemUpDownImg.setVisibility(View.INVISIBLE);
    }
    mAddress.setText(mAccount.address);
    mKeyState.setColorFilter(ContextCompat.getColor(getBaseContext(), R.color.colorGray0), android.graphics.PorterDuff.Mode.SRC_IN);
    if (mAccount.hasPrivateKey) {
        mKeyState.setColorFilter(WDp.getChainColor(getBaseContext(), mBaseChain), android.graphics.PorterDuff.Mode.SRC_IN);
    }
    mSwipeRefreshLayout.setRefreshing(false);
}
Also used : BnbToken(wannabit.io.cosmostaion.dao.BnbToken) OkToken(wannabit.io.cosmostaion.dao.OkToken) BigDecimal(java.math.BigDecimal)

Example 3 with BnbToken

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

the class BaseActivity method onTaskResponse.

@Override
public void onTaskResponse(TaskResult result) {
    // WLog.w("onTaskResponse " + result.taskType + "   " + mTaskCount);
    if (isFinishing())
        return;
    if (result.taskType == BaseConstant.TASK_PUSH_STATUS_UPDATE) {
        if (result.isSuccess) {
            mAccount = getBaseDao().onUpdatePushEnabled(mAccount, (boolean) result.resultData);
        }
        invalidateOptionsMenu();
        return;
    } else if (result.taskType == BaseConstant.TASK_FETCH_PRICE_INFO) {
        if (result.isSuccess && result.resultData != null) {
            getBaseDao().mPrices.clear();
            ArrayList<Price> tempPrice = new ArrayList<>();
            tempPrice = (ArrayList<Price>) result.resultData;
            for (Price price : tempPrice) {
                getBaseDao().mPrices.add(price);
            }
        }
    }
    mTaskCount--;
    if (result.taskType == BaseConstant.TASK_FETCH_ACCOUNT) {
        mAccount = getBaseDao().onSelectAccount(getBaseDao().getLastUser());
        getBaseDao().mBalances = getBaseDao().onSelectBalance(mAccount.id);
    // WLog.w("getBaseDao().mBalances " + getBaseDao().mBalances.size());
    } else if (result.taskType == TASK_FETCH_NODE_INFO) {
        getBaseDao().mNodeInfo = (NodeInfo) result.resultData;
        mTaskCount = mTaskCount + 1;
        new StationParamInfoTask(getBaseApplication(), this, mBaseChain, getBaseDao().getChainId()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    } else if (result.taskType == TASK_FETCH_OKEX_ALL_VALIDATORS) {
        ArrayList<Validator> allValis = (ArrayList<Validator>) result.resultData;
        if (allValis != null) {
            getBaseDao().mAllValidators = allValis;
        }
    } else if (result.taskType == BaseConstant.TASK_FETCH_BNB_TOKENS) {
        ArrayList<BnbToken> tempTokens = (ArrayList<BnbToken>) result.resultData;
        if (tempTokens != null) {
            for (BnbToken token : tempTokens) {
                token.type = BnbToken.BNB_TOKEN_TYPE_BEP2;
                getBaseDao().mBnbTokens.add(token);
            }
        }
    } else if (result.taskType == BaseConstant.TASK_FETCH_BNB_MINI_TOKENS) {
        ArrayList<BnbToken> tempTokens = (ArrayList<BnbToken>) result.resultData;
        if (tempTokens != null) {
            for (BnbToken token : tempTokens) {
                token.type = BnbToken.BNB_TOKEN_TYPE_MINI;
                getBaseDao().mBnbTokens.add(token);
            }
        }
    } else if (result.taskType == TASK_FETCH_BNB_TICKER) {
        ArrayList<BnbTicker> tempTickers = (ArrayList<BnbTicker>) result.resultData;
        if (tempTickers != null) {
            getBaseDao().mBnbTickers.addAll(tempTickers);
        }
    } else if (result.taskType == TASK_FETCH_BNB_MINI_TICKER) {
        ArrayList<BnbTicker> tempTickers = (ArrayList<BnbTicker>) result.resultData;
        if (tempTickers != null) {
            getBaseDao().mBnbTickers.addAll(tempTickers);
        }
    } else if (result.taskType == TASK_FETCH_BNB_FEES) {
        getBaseDao().mBnbFees.clear();
        if (result.isSuccess && result.resultData != null) {
            getBaseDao().mBnbFees = (ArrayList<ResBnbFee>) result.resultData;
        }
    } else if (result.taskType == TASK_FETCH_OK_ACCOUNT_BALANCE) {
        if (result.isSuccess) {
            getBaseDao().mBalances = getBaseDao().onSelectBalance(mAccount.id);
        }
    // WLog.w("getBaseDao().mBalances " + getBaseDao().mBalances.size());
    } else if (result.taskType == TASK_FETCH_OK_STAKING_INFO) {
        if (result.isSuccess && result.resultData != null) {
            getBaseDao().mOkStaking = (ResOkStaking) result.resultData;
        }
    } else if (result.taskType == TASK_FETCH_OK_UNBONDING_INFO) {
        if (result.isSuccess && result.resultData != null) {
            getBaseDao().mOkUnbonding = ((ResOkUnbonding) result.resultData);
        }
    } else if (result.taskType == TASK_FETCH_OK_TOKEN_LIST) {
        if (result.isSuccess && result.resultData != null) {
            getBaseDao().mOkTokenList = ((ResOkTokenList) result.resultData);
        }
    } else if (result.taskType == TASK_FETCH_OK_DEX_TICKERS) {
        if (result.isSuccess && result.resultData != null) {
            getBaseDao().mOkTickersList = ((ResOkTickersList) result.resultData);
        }
    } else // gRPC callback
    if (result.taskType == TASK_GRPC_FETCH_NODE_INFO) {
        tendermint.p2p.Types.NodeInfo tempNodeInfo = (tendermint.p2p.Types.NodeInfo) result.resultData;
        if (tempNodeInfo != null) {
            getBaseDao().mGRpcNodeInfo = tempNodeInfo;
            mTaskCount = mTaskCount + 5;
            new StationParamInfoTask(getBaseApplication(), this, mBaseChain, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
            new StationIbcPathsTask(getBaseApplication(), this, mBaseChain, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
            new StationIbcTokensTask(getBaseApplication(), this, mBaseChain, getBaseDao().getChainIdGrpc()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
            new MintScanAssetsTask(getBaseApplication(), this, mBaseChain).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
            new MintScanCw20AssetsTask(getBaseApplication(), this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        }
    } else if (result.taskType == TASK_GRPC_FETCH_AUTH) {
        Any tempAccount = (Any) result.resultData;
        if (tempAccount != null) {
            getBaseDao().mGRpcAccount = tempAccount;
        }
    } else if (result.taskType == TASK_GRPC_FETCH_BONDED_VALIDATORS) {
        ArrayList<Staking.Validator> bonded = (ArrayList<Staking.Validator>) result.resultData;
        if (bonded != null) {
            getBaseDao().mGRpcTopValidators.addAll(bonded);
        }
    } else if (result.taskType == TASK_GRPC_FETCH_UNBONDED_VALIDATORS) {
        ArrayList<Staking.Validator> unbonded = (ArrayList<Staking.Validator>) result.resultData;
        if (unbonded != null) {
            getBaseDao().mGRpcOtherValidators.addAll(unbonded);
        }
    } else if (result.taskType == TASK_GRPC_FETCH_UNBONDING_VALIDATORS) {
        ArrayList<Staking.Validator> unbonding = (ArrayList<Staking.Validator>) result.resultData;
        if (unbonding != null) {
            getBaseDao().mGRpcOtherValidators.addAll(unbonding);
        }
    } else if (result.taskType == TASK_GRPC_FETCH_BALANCE) {
        ArrayList<CoinOuterClass.Coin> balance = (ArrayList<CoinOuterClass.Coin>) result.resultData;
        if (balance != null && balance.size() > 0) {
            for (CoinOuterClass.Coin coin : balance) {
                if (!coin.getAmount().equals("0")) {
                    getBaseDao().mGrpcBalance.add(new Coin(coin.getDenom(), coin.getAmount()));
                } else {
                    if (coin.getDenom().equalsIgnoreCase(WDp.mainDenom(mBaseChain))) {
                        getBaseDao().mGrpcBalance.add(new Coin(coin.getDenom(), coin.getAmount()));
                    }
                }
            }
        }
        if (getBaseDao().mGrpcBalance.size() <= 0 || getBaseDao().getAvailable(WDp.mainDenom(mBaseChain)).compareTo(BigDecimal.ZERO) <= 0) {
            getBaseDao().mGrpcBalance.add(new Coin(WDp.mainDenom(mBaseChain), "0"));
        }
    } else if (result.taskType == TASK_GRPC_FETCH_DELEGATIONS) {
        ArrayList<Staking.DelegationResponse> delegations = (ArrayList<Staking.DelegationResponse>) result.resultData;
        if (delegations != null) {
            getBaseDao().mGrpcDelegations = delegations;
        }
    } else if (result.taskType == TASK_GRPC_FETCH_UNDELEGATIONS) {
        ArrayList<Staking.UnbondingDelegation> undelegations = (ArrayList<Staking.UnbondingDelegation>) result.resultData;
        if (undelegations != null) {
            getBaseDao().mGrpcUndelegations = undelegations;
        }
    } else if (result.taskType == TASK_GRPC_FETCH_ALL_REWARDS) {
        ArrayList<Distribution.DelegationDelegatorReward> rewards = (ArrayList<Distribution.DelegationDelegatorReward>) result.resultData;
        if (rewards != null) {
            getBaseDao().mGrpcRewards = rewards;
        }
    } else if (result.taskType == TASK_GRPC_FETCH_STARNAME_FEE) {
        if (result.isSuccess && result.resultData != null) {
            getBaseDao().mGrpcStarNameFee = ((starnamed.x.configuration.v1beta1.Types.Fees) result.resultData);
        }
    } else if (result.taskType == TASK_GRPC_FETCH_STARNAME_CONFIG) {
        if (result.isSuccess && result.resultData != null) {
            getBaseDao().mGrpcStarNameConfig = ((starnamed.x.configuration.v1beta1.Types.Config) result.resultData);
        }
    } else if (result.taskType == TASK_GRPC_FETCH_GRAVITY_POOL_LIST) {
        if (result.isSuccess && result.resultData != null) {
            List<Liquidity.Pool> pools = (List<Liquidity.Pool>) result.resultData;
            getBaseDao().mGrpcGravityPools = new ArrayList<Liquidity.Pool>(pools);
        }
    } else if (result.taskType == TASK_GRPC_FETCH_OSMOSIS_POOL_LIST) {
        if (result.isSuccess && result.resultData != null) {
            List<BalancerPool.Pool> pools = (List<BalancerPool.Pool>) result.resultData;
            getBaseDao().mGrpcOsmosisPool = new ArrayList<BalancerPool.Pool>(pools);
        }
    } else // kava
    if (result.taskType == TASK_FETCH_KAVA_INCENTIVE_PARAM) {
        if (result.isSuccess && result.resultData != null) {
            getBaseDao().mIncentiveParam5 = (IncentiveParam) result.resultData;
        }
    } else if (result.taskType == TASK_FETCH_KAVA_INCENTIVE_REWARD) {
        if (result.isSuccess && result.resultData != null) {
            getBaseDao().mIncentiveRewards = (IncentiveReward) result.resultData;
        }
    } else if (result.taskType == TASK_GRPC_FETCH_KAVA_PRICES) {
        if (result.isSuccess && result.resultData != null) {
            ArrayList<QueryOuterClass.CurrentPriceResponse> currentPrices = (ArrayList<QueryOuterClass.CurrentPriceResponse>) result.resultData;
            if (currentPrices != null) {
                for (QueryOuterClass.CurrentPriceResponse response : currentPrices) {
                    getBaseDao().mKavaTokenPrice.put(response.getMarketId(), response);
                }
            }
        }
    } else // mintscan
    if (result.taskType == TASK_FETCH_MINTSCAN_CW20_ASSETS) {
        if (result.isSuccess && result.resultData != null) {
            getBaseDao().mCw20Assets = (ArrayList<Cw20Assets>) result.resultData;
            if (getBaseDao().mCw20Assets != null && getBaseDao().mCw20Assets.size() > 0) {
                for (Cw20Assets assets : getBaseDao().mCw20Assets) {
                    if (assets.chain.equalsIgnoreCase(WDp.getChainNameByBaseChain(mBaseChain))) {
                        mTaskCount = mTaskCount + 1;
                        new Cw20BalanceGrpcTask(getBaseApplication(), this, mBaseChain, mAccount, assets.contract_address).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
                    }
                }
            }
        }
    }
    if (mTaskCount == 0) {
        if (isGRPC(mBaseChain)) {
            getBaseDao().mGRpcAllValidators.addAll(getBaseDao().mGRpcTopValidators);
            getBaseDao().mGRpcAllValidators.addAll(getBaseDao().mGRpcOtherValidators);
            for (Staking.Validator validator : getBaseDao().mGRpcAllValidators) {
                boolean already = false;
                for (Staking.DelegationResponse delegation : getBaseDao().mGrpcDelegations) {
                    if (delegation.getDelegation().getValidatorAddress().equals(validator.getOperatorAddress())) {
                        already = true;
                        break;
                    }
                }
                for (Staking.UnbondingDelegation undelegation : getBaseDao().mGrpcUndelegations) {
                    if (undelegation.getValidatorAddress().equals(validator.getOperatorAddress())) {
                        already = true;
                        break;
                    }
                }
                if (already)
                    getBaseDao().mGRpcMyValidators.add(validator);
            }
            // WLog.w("mIbcTokens " + getBaseDao().mIbcTokens.size());
            if (getBaseDao().mGRpcNodeInfo == null) {
                Toast.makeText(getBaseContext(), R.string.error_network_error, Toast.LENGTH_SHORT).show();
            } else {
                // WLog.w("mGRpcAccount " + getBaseDao().mGRpcAccount.getTypeUrl());
                if (getBaseDao().mGRpcAccount != null && !getBaseDao().mGRpcAccount.getTypeUrl().contains(Auth.BaseAccount.getDescriptor().getFullName())) {
                    WUtil.onParseVestingAccount(getBaseDao(), mBaseChain);
                }
                ArrayList<Balance> snapBalance = new ArrayList<>();
                for (Coin coin : getBaseDao().mGrpcBalance) {
                    snapBalance.add(new Balance(mAccount.id, coin.denom, coin.amount, Calendar.getInstance().getTime().getTime(), "0", "0"));
                }
                getBaseDao().onUpdateBalances(mAccount.id, snapBalance);
            // WLog.w("getBaseDao().mGRpcNodeInfo " + getBaseDao().mGRpcNodeInfo.getNetwork());
            }
        } else if (mBaseChain.equals(BNB_MAIN)) {
            if (getBaseDao().mNodeInfo == null) {
                Toast.makeText(getBaseContext(), R.string.error_network_error, Toast.LENGTH_SHORT).show();
            }
        // WLog.w("mBnbTokens " + getBaseDao().mBnbTokens.size());
        // WLog.w("mBnbTickers " + getBaseDao().mBnbTickers.size());
        } else if (mBaseChain.equals(OKEX_MAIN)) {
            for (Validator all : getBaseDao().mAllValidators) {
                if (all.status == Validator.BONDED) {
                    getBaseDao().mTopValidators.add(all);
                } else {
                    getBaseDao().mOtherValidators.add(all);
                }
            }
            if (getBaseDao().mOkStaking != null && getBaseDao().mOkStaking.validator_address != null) {
                for (String valAddr : getBaseDao().mOkStaking.validator_address) {
                    for (Validator val : getBaseDao().mAllValidators) {
                        if (val.operator_address.equals(valAddr)) {
                            getBaseDao().mMyValidators.add(val);
                        }
                    }
                }
            }
            if (getBaseDao().mNodeInfo == null) {
                Toast.makeText(getBaseContext(), R.string.error_network_error, Toast.LENGTH_SHORT).show();
            }
        } else {
            getBaseDao().mAllValidators.addAll(getBaseDao().mTopValidators);
            getBaseDao().mAllValidators.addAll(getBaseDao().mOtherValidators);
            for (Validator top : getBaseDao().mAllValidators) {
                boolean already = false;
                for (BondingInfo bond : getBaseDao().mMyDelegations) {
                    if (bond.validator_address.equals(top.operator_address)) {
                        already = true;
                        break;
                    }
                }
                for (UnbondingInfo unbond : getBaseDao().mMyUnbondings) {
                    if (unbond.validator_address.equals(top.operator_address) && !already) {
                        already = true;
                        break;
                    }
                }
                if (already)
                    getBaseDao().mMyValidators.add(top);
            }
            if (getBaseDao().mNodeInfo == null) {
                Toast.makeText(getBaseContext(), R.string.error_network_error, Toast.LENGTH_SHORT).show();
            }
        }
        new StationPriceInfoTask(getBaseApplication(), this, mBaseChain).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        // callback with delay fix gRPC  timming issue
        mHandler.postDelayed(new Runnable() {

            @Override
            public void run() {
                if (mFetchCallback != null) {
                    mFetchCallback.fetchFinished();
                }
            }
        }, 300);
    }
}
Also used : ArrayList(java.util.ArrayList) Coin(wannabit.io.cosmostaion.model.type.Coin) BalancerPool(osmosis.gamm.poolmodels.balancer.BalancerPool) ArrayList(java.util.ArrayList) ResOkTokenList(wannabit.io.cosmostaion.network.res.ResOkTokenList) List(java.util.List) ResOkTickersList(wannabit.io.cosmostaion.network.res.ResOkTickersList) BalancerPool(osmosis.gamm.poolmodels.balancer.BalancerPool) StationIbcPathsTask(wannabit.io.cosmostaion.task.FetchTask.StationIbcPathsTask) BnbToken(wannabit.io.cosmostaion.dao.BnbToken) Price(wannabit.io.cosmostaion.dao.Price) NodeInfo(wannabit.io.cosmostaion.model.NodeInfo) ResOkStaking(wannabit.io.cosmostaion.network.res.ResOkStaking) Staking(cosmos.staking.v1beta1.Staking) Distribution(cosmos.distribution.v1beta1.Distribution) Liquidity(tendermint.liquidity.v1beta1.Liquidity) MintScanAssetsTask(wannabit.io.cosmostaion.task.FetchTask.MintScanAssetsTask) Balance(wannabit.io.cosmostaion.dao.Balance) UnbondingInfo(wannabit.io.cosmostaion.model.UnbondingInfo) IncentiveReward(wannabit.io.cosmostaion.model.kava.IncentiveReward) Any(com.google.protobuf2.Any) Cw20Assets(wannabit.io.cosmostaion.dao.Cw20Assets) ResOkStaking(wannabit.io.cosmostaion.network.res.ResOkStaking) ResOkTickersList(wannabit.io.cosmostaion.network.res.ResOkTickersList) QueryOuterClass(kava.pricefeed.v1beta1.QueryOuterClass) MintScanCw20AssetsTask(wannabit.io.cosmostaion.task.FetchTask.MintScanCw20AssetsTask) StationPriceInfoTask(wannabit.io.cosmostaion.task.FetchTask.StationPriceInfoTask) BondingInfo(wannabit.io.cosmostaion.model.BondingInfo) Cw20BalanceGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.Cw20BalanceGrpcTask) BnbTicker(wannabit.io.cosmostaion.dao.BnbTicker) ResOkUnbonding(wannabit.io.cosmostaion.network.res.ResOkUnbonding) CoinOuterClass(cosmos.base.v1beta1.CoinOuterClass) StationParamInfoTask(wannabit.io.cosmostaion.task.FetchTask.StationParamInfoTask) StationIbcTokensTask(wannabit.io.cosmostaion.task.FetchTask.StationIbcTokensTask) Validator(wannabit.io.cosmostaion.model.type.Validator)

Example 4 with BnbToken

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

the class TokenDetailSupportHolder method onBindBNBTokens.

public void onBindBNBTokens(Context c, BaseData baseData, String denom) {
    BnbToken bnbToken = baseData.getBnbToken(denom);
    if (bnbToken != null) {
        mLockedLayout.setVisibility(View.VISIBLE);
        mFrozenLayout.setVisibility(View.VISIBLE);
    }
    mAvailableAmount = baseData.availableAmount(denom);
    final BigDecimal lockedAmount = baseData.lockedAmount(denom);
    final BigDecimal frozenAmount = baseData.frozenAmount(denom);
    mTvTotal.setText(WDp.getDpAmount2(c, mAvailableAmount, 0, 8));
    mTvAvailable.setText(WDp.getDpAmount2(c, mAvailableAmount, 0, 8));
    mTvLocked.setText(WDp.getDpAmount2(c, lockedAmount, 0, 8));
    mTvFrozen.setText(WDp.getDpAmount2(c, frozenAmount, 0, 8));
}
Also used : BnbToken(wannabit.io.cosmostaion.dao.BnbToken) BigDecimal(java.math.BigDecimal)

Example 5 with BnbToken

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

the class MainTokensFragment method onBindEtcToken.

// with Etc tokens (binance, okex)
private void onBindEtcToken(TokensAdapter.AssetHolder holder, int position) {
    final Balance balance = mEtc.get(position);
    if (getMainActivity().mBaseChain.equals(OKEX_MAIN)) {
        final OkToken okToken = getBaseDao().okToken(balance.symbol);
        if (okToken != null) {
            holder.itemSymbol.setText(okToken.original_symbol.toUpperCase());
            holder.itemInnerSymbol.setText("(" + okToken.symbol + ")");
            holder.itemFullName.setText(okToken.description);
            holder.itemSymbol.setTextColor(getResources().getColor(R.color.colorWhite));
            Picasso.get().load(OKEX_COIN_IMG_URL + okToken.original_symbol + ".png").placeholder(R.drawable.token_ic).error(R.drawable.token_ic).fit().into(holder.itemImg);
        }
        BigDecimal totalAmount = getBaseDao().getAllExToken(balance.symbol);
        BigDecimal convertAmount = WDp.convertTokenToOkt(getBaseDao(), balance.symbol);
        holder.itemBalance.setText(WDp.getDpAmount2(getContext(), totalAmount, 0, 6));
        holder.itemValue.setText(WDp.dpUserCurrencyValue(getBaseDao(), TOKEN_OK, convertAmount, 0));
        holder.itemRoot.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getMainActivity(), NativeTokenDetailActivity.class);
                intent.putExtra("denom", balance.symbol);
                startActivity(intent);
            }
        });
    } else if (getMainActivity().mBaseChain.equals(BNB_MAIN)) {
        final String denom = mEtc.get(position).symbol;
        final BigDecimal amount = getBaseDao().getAllBnbTokenAmount(denom);
        final BnbToken bnbToken = getBaseDao().getBnbToken(denom);
        holder.itemSymbol.setText(bnbToken.original_symbol.toUpperCase());
        holder.itemInnerSymbol.setText("(" + bnbToken.symbol + ")");
        holder.itemFullName.setText(bnbToken.name);
        Picasso.get().load(BINANCE_TOKEN_IMG_URL + bnbToken.original_symbol + ".png").fit().placeholder(R.drawable.token_ic).error(R.drawable.token_ic).into(holder.itemImg);
        holder.itemSymbol.setTextColor(getResources().getColor(R.color.colorWhite));
        holder.itemBalance.setText(WDp.getDpAmount2(getContext(), amount, 0, 6));
        final BigDecimal convertAmount = WUtil.getBnbConvertAmount(getBaseDao(), denom, amount);
        holder.itemValue.setText(WDp.dpUserCurrencyValue(getBaseDao(), TOKEN_BNB, convertAmount, 0));
        holder.itemRoot.setOnClickListener(new View.OnClickListener() {

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

Aggregations

BnbToken (wannabit.io.cosmostaion.dao.BnbToken)5 BigDecimal (java.math.BigDecimal)4 Balance (wannabit.io.cosmostaion.dao.Balance)3 OkToken (wannabit.io.cosmostaion.dao.OkToken)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 Any (com.google.protobuf2.Any)1 CoinOuterClass (cosmos.base.v1beta1.CoinOuterClass)1 Distribution (cosmos.distribution.v1beta1.Distribution)1 Staking (cosmos.staking.v1beta1.Staking)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 QueryOuterClass (kava.pricefeed.v1beta1.QueryOuterClass)1 BalancerPool (osmosis.gamm.poolmodels.balancer.BalancerPool)1 Liquidity (tendermint.liquidity.v1beta1.Liquidity)1 NativeTokenDetailActivity (wannabit.io.cosmostaion.activities.tokenDetail.NativeTokenDetailActivity)1