Search in sources :

Example 11 with IbcToken

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

the class MainTokensFragment method onBindIbcUnknownToken.

// with Unknown IBC gRPC
private void onBindIbcUnknownToken(TokensAdapter.AssetHolder holder, int position) {
    final Coin coin = mIbcUnknownGrpc.get(position);
    final IbcToken ibcToken = getBaseDao().getIbcToken(coin.denom);
    if (ibcToken == null) {
        holder.itemSymbol.setText("Unknown");
        holder.itemInnerSymbol.setText("");
        holder.itemFullName.setText("");
        holder.itemImg.setImageDrawable(getResources().getDrawable(R.drawable.token_default_ibc));
        holder.itemBalance.setText(WDp.getDpAmount2(getContext(), new BigDecimal(coin.amount), 6, 6));
        holder.itemValue.setText(WDp.dpUserCurrencyValue(getBaseDao(), coin.denom, BigDecimal.ZERO, 6));
    } else {
        holder.itemSymbol.setText("Unknown");
        holder.itemInnerSymbol.setText("");
        holder.itemFullName.setText(ibcToken.channel_id);
        holder.itemImg.setImageDrawable(getResources().getDrawable(R.drawable.token_default_ibc));
        holder.itemBalance.setText(WDp.getDpAmount2(getContext(), new BigDecimal(coin.amount), 6, 6));
        holder.itemValue.setText(WDp.dpUserCurrencyValue(getBaseDao(), coin.denom, new BigDecimal(coin.amount), 6));
    }
    holder.itemRoot.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(getMainActivity(), IBCTokenDetailActivity.class);
            intent.putExtra("denom", coin.denom);
            startActivity(intent);
        }
    });
}
Also used : Coin(wannabit.io.cosmostaion.model.type.Coin) IbcToken(wannabit.io.cosmostaion.dao.IbcToken) Intent(android.content.Intent) 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) IBCTokenDetailActivity(wannabit.io.cosmostaion.activities.tokenDetail.IBCTokenDetailActivity)

Example 12 with IbcToken

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

the class MainTokensFragment method onBindIbcAuthToken.

// with Authed IBC gRPC
private void onBindIbcAuthToken(TokensAdapter.AssetHolder holder, int position) {
    final Coin coin = mIbcAuthedGrpc.get(position);
    final IbcToken ibcToken = getBaseDao().getIbcToken(coin.denom);
    holder.itemSymbol.setTextColor(getResources().getColor(R.color.colorWhite));
    holder.itemFullName.setEllipsize(TextUtils.TruncateAt.MIDDLE);
    if (ibcToken == null) {
        holder.itemSymbol.setText("Unknown");
        holder.itemInnerSymbol.setText("");
        holder.itemFullName.setText("");
        holder.itemImg.setImageDrawable(getResources().getDrawable(R.drawable.token_default_ibc));
        holder.itemBalance.setText(WDp.getDpAmount2(getContext(), new BigDecimal(coin.amount), 6, 6));
        holder.itemValue.setText(WDp.dpUserCurrencyValue(getBaseDao(), coin.denom, BigDecimal.ZERO, 6));
    } else {
        holder.itemSymbol.setText(ibcToken.display_denom.toUpperCase());
        holder.itemInnerSymbol.setText("");
        holder.itemFullName.setText(ibcToken.channel_id);
        holder.itemBalance.setText(WDp.getDpAmount2(getContext(), new BigDecimal(coin.amount), ibcToken.decimal, 6));
        holder.itemValue.setText(WDp.dpUserCurrencyValue(getBaseDao(), getBaseDao().getBaseDenom(coin.denom), new BigDecimal(coin.amount), ibcToken.decimal));
        try {
            Picasso.get().load(ibcToken.moniker).fit().placeholder(R.drawable.token_default_ibc).error(R.drawable.token_default_ibc).into(holder.itemImg);
        } catch (Exception e) {
        }
    }
    holder.itemRoot.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(getMainActivity(), IBCTokenDetailActivity.class);
            intent.putExtra("denom", coin.denom);
            startActivity(intent);
        }
    });
}
Also used : Coin(wannabit.io.cosmostaion.model.type.Coin) IbcToken(wannabit.io.cosmostaion.dao.IbcToken) Intent(android.content.Intent) 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) IBCTokenDetailActivity(wannabit.io.cosmostaion.activities.tokenDetail.IBCTokenDetailActivity)

Example 13 with IbcToken

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

the class BaseData method getIbcRollbackChannel.

public ArrayList<IbcPath.Path> getIbcRollbackChannel(String denom, ArrayList<IbcPath.Path> paths) {
    ArrayList<IbcPath.Path> result = new ArrayList<>();
    IbcToken ibcToken = getIbcToken(denom);
    if (paths != null && paths.size() > 0) {
        for (IbcPath.Path path : paths) {
            if (path.auth != null && path.auth && path.channel_id.equalsIgnoreCase(ibcToken.channel_id)) {
                result.add(path);
            }
        }
    }
    return result;
}
Also used : IbcPath(wannabit.io.cosmostaion.dao.IbcPath) IbcToken(wannabit.io.cosmostaion.dao.IbcToken) IbcPath(wannabit.io.cosmostaion.dao.IbcPath) ArrayList(java.util.ArrayList)

Example 14 with IbcToken

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

the class BaseData method getIbcRollbackRelayer.

public ArrayList<IbcPath> getIbcRollbackRelayer(String denom) {
    ArrayList<IbcPath> result = new ArrayList<>();
    IbcToken ibcToken = getIbcToken(denom.replaceAll("ibc/", ""));
    if (mIbcPaths != null && mIbcPaths.size() > 0) {
        for (IbcPath ibcPath : mIbcPaths) {
            for (IbcPath.Path path : ibcPath.paths) {
                if (path.channel_id != null && path.channel_id.equalsIgnoreCase(ibcToken.channel_id)) {
                    result.add(ibcPath);
                }
            }
        }
    }
    return result;
}
Also used : IbcToken(wannabit.io.cosmostaion.dao.IbcToken) IbcPath(wannabit.io.cosmostaion.dao.IbcPath) ArrayList(java.util.ArrayList)

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