use of wannabit.io.cosmostaion.dao.OkToken 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);
}
});
}
}
use of wannabit.io.cosmostaion.dao.OkToken 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);
}
use of wannabit.io.cosmostaion.dao.OkToken in project cosmostation-android by cosmostation.
the class TokenDetailSupportHolder method onBindOKTokens.
public void onBindOKTokens(Context c, BaseData baseData, String denom) {
final OkToken okToken = baseData.okToken(denom);
if (okToken != null) {
mLockedLayout.setVisibility(View.VISIBLE);
}
mAvailableAmount = baseData.availableAmount(denom);
final BigDecimal lockedAmount = baseData.lockedAmount(denom);
final BigDecimal totalAmount = mAvailableAmount.add(lockedAmount);
mTvTotal.setText(WDp.getDpAmount2(c, totalAmount, 0, 18));
mTvAvailable.setText(WDp.getDpAmount2(c, mAvailableAmount, 0, 18));
mTvLocked.setText(WDp.getDpAmount2(c, lockedAmount, 0, 18));
}
use of wannabit.io.cosmostaion.dao.OkToken in project cosmostation-android by cosmostation.
the class WDp method convertTokenToOkt.
public static BigDecimal convertTokenToOkt(BaseData baseData, String denom) {
OkToken okToken = baseData.okToken(denom);
if (okToken != null) {
BigDecimal tokenAmount = baseData.availableAmount(denom).add(baseData.lockedAmount(denom));
BigDecimal totalTokenValue = okExTokenDollorValue(baseData, okToken, tokenAmount);
return totalTokenValue.divide(perUsdValue(baseData, TOKEN_OK), 18, RoundingMode.DOWN);
}
return BigDecimal.ZERO;
}
use of wannabit.io.cosmostaion.dao.OkToken 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);
}
});
}
}
Aggregations