Search in sources :

Example 11 with Balance

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

Example 12 with Balance

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

the class BaseData method onSelectBalance.

public ArrayList<Balance> onSelectBalance(long accountId) {
    ArrayList<Balance> result = new ArrayList<>();
    Cursor cursor = getBaseDB().query(BaseConstant.DB_TABLE_BALANCE, new String[] { "accountId", "symbol", "balance", "fetchTime", "frozen", "locked" }, "accountId == ?", new String[] { "" + accountId }, null, null, null);
    if (cursor != null && cursor.moveToFirst()) {
        do {
            Balance balance = new Balance(cursor.getLong(0), cursor.getString(1), cursor.getString(2), cursor.getLong(3), cursor.getString(4), cursor.getString(5));
            result.add(balance);
        } while (cursor.moveToNext());
    }
    cursor.close();
    return result;
}
Also used : ArrayList(java.util.ArrayList) Cursor(net.sqlcipher.Cursor) Balance(wannabit.io.cosmostaion.dao.Balance)

Aggregations

Balance (wannabit.io.cosmostaion.dao.Balance)12 BigDecimal (java.math.BigDecimal)8 ArrayList (java.util.ArrayList)6 Coin (wannabit.io.cosmostaion.model.type.Coin)6 BnbToken (wannabit.io.cosmostaion.dao.BnbToken)3 IbcToken (wannabit.io.cosmostaion.dao.IbcToken)3 Intent (android.content.Intent)2 SpannableString (android.text.SpannableString)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 Cw20Assets (wannabit.io.cosmostaion.dao.Cw20Assets)2 OkToken (wannabit.io.cosmostaion.dao.OkToken)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 List (java.util.List)1