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);
}
});
}
}
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;
}
Aggregations