Search in sources :

Example 26 with Coin

use of wannabit.io.cosmostaion.model.type.Coin in project cosmostation-android by cosmostation.

the class OKStakingFragmentStep0 method isValidateDepositAmount.

private boolean isValidateDepositAmount() {
    try {
        if (getSActivity().mBaseChain.equals(OKEX_MAIN) || getSActivity().mBaseChain.equals(OK_TEST)) {
            BigDecimal depositTemp = new BigDecimal(mAmountInput.getText().toString().trim());
            if (depositTemp.compareTo(BigDecimal.ZERO) <= 0)
                return false;
            if (depositTemp.compareTo(mMaxAvailable) > 0)
                return false;
            Coin token = new Coin(TOKEN_OK, depositTemp.setScale(mDpDecimal).toPlainString());
            getSActivity().mToDepositCoin = token;
            return true;
        }
        return false;
    } catch (Exception e) {
        getSActivity().mToDepositCoin = null;
        return false;
    }
}
Also used : Coin(wannabit.io.cosmostaion.model.type.Coin) BigDecimal(java.math.BigDecimal)

Example 27 with Coin

use of wannabit.io.cosmostaion.model.type.Coin in project cosmostation-android by cosmostation.

the class HtlcSendStep2Fragment method isValidateAmount.

private boolean isValidateAmount() {
    mToSendCoins.clear();
    try {
        if (getSActivity().mBaseChain.equals(BaseChain.BNB_MAIN)) {
            BigDecimal sendTemp = new BigDecimal(mAmountInput.getText().toString().trim());
            if (sendTemp.compareTo(BigDecimal.ZERO) <= 0)
                return false;
            if (sendTemp.compareTo(mMinAvailable) <= 0)
                return false;
            if (sendTemp.compareTo(mMaxAvailable) > 0)
                return false;
            Coin token = new Coin(getSActivity().mToSwapDenom, sendTemp.toPlainString());
            mToSendCoins.add(token);
            return true;
        } else if (getSActivity().mBaseChain.equals(BaseChain.KAVA_MAIN)) {
            BigDecimal sendTemp = new BigDecimal(mAmountInput.getText().toString().trim()).movePointRight(mDecimal);
            if (sendTemp.compareTo(BigDecimal.ZERO) <= 0)
                return false;
            if (sendTemp.compareTo(mMinAvailable) <= 0)
                return false;
            if (sendTemp.compareTo(mMaxAvailable) > 0)
                return false;
            Coin token = new Coin(getSActivity().mToSwapDenom.toLowerCase(), sendTemp.toPlainString());
            mToSendCoins.add(token);
        }
        if (mToSendCoins.size() <= 0) {
            return false;
        }
    } catch (Exception e) {
        mToSendCoins.clear();
        return false;
    }
    return true;
}
Also used : Coin(wannabit.io.cosmostaion.model.type.Coin) BigDecimal(java.math.BigDecimal)

Example 28 with Coin

use of wannabit.io.cosmostaion.model.type.Coin in project cosmostation-android by cosmostation.

the class DepositPoolStep0Fragment method isValidateJoinPool.

private boolean isValidateJoinPool() {
    try {
        BigDecimal InputAmountTemp = new BigDecimal(mJoinPoolInput0.getText().toString().trim());
        if (InputAmountTemp.compareTo(BigDecimal.ZERO) <= 0)
            return false;
        if (InputAmountTemp.compareTo(mAvailable0MaxAmount.movePointLeft(mCoin0Decimal).setScale(mCoin0Decimal, RoundingMode.CEILING)) > 0)
            return false;
        BigDecimal OutputAmountTemp = new BigDecimal(mJoinPoolInput1.getText().toString().trim());
        if (OutputAmountTemp.compareTo(BigDecimal.ZERO) <= 0)
            return false;
        if (OutputAmountTemp.compareTo(mAvailable1MaxAmount.movePointLeft(mCoin1Decimal).setScale(mCoin1Decimal, RoundingMode.CEILING)) > 0)
            return false;
        getSActivity().mKavaPoolTokenA = new Coin(mCoin0Denom, InputAmountTemp.movePointRight(mCoin0Decimal).toPlainString());
        getSActivity().mKavaPoolTokenB = new Coin(mCoin1Denom, OutputAmountTemp.movePointRight(mCoin1Decimal).toPlainString());
        return true;
    } catch (Exception e) {
        return false;
    }
}
Also used : Coin(wannabit.io.cosmostaion.model.type.Coin) BigDecimal(java.math.BigDecimal)

Example 29 with Coin

use of wannabit.io.cosmostaion.model.type.Coin in project cosmostation-android by cosmostation.

the class KavaSwapStep0Fragment method isValidateSwapInputAmount.

private boolean isValidateSwapInputAmount() {
    try {
        BigDecimal InputAmountTemp = new BigDecimal(mSwapInputAmount.getText().toString().trim());
        BigDecimal OutAmountTemp = new BigDecimal(mSwapOutputAmount.getText().toString().trim());
        if (InputAmountTemp.compareTo(BigDecimal.ZERO) <= 0)
            return false;
        if (InputAmountTemp.compareTo(mAvailableMaxAmount.movePointLeft(mInputCoinDecimal).setScale(mInputCoinDecimal, RoundingMode.CEILING)) > 0)
            return false;
        getSActivity().mKavaSwapIn = new Coin(getSActivity().mInputDenom, InputAmountTemp.movePointRight(mInputCoinDecimal).setScale(0).toPlainString());
        getSActivity().mKavaSwapOut = new Coin(getSActivity().mOutputDenom, OutAmountTemp.movePointRight(mOutputCoinDecimal).setScale(0).toPlainString());
        return true;
    } catch (Exception e) {
        getSActivity().mKavaSwapIn = null;
        getSActivity().mKavaSwapOut = null;
        return false;
    }
}
Also used : Coin(wannabit.io.cosmostaion.model.type.Coin) BigDecimal(java.math.BigDecimal)

Example 30 with Coin

use of wannabit.io.cosmostaion.model.type.Coin in project cosmostation-android by cosmostation.

the class MainTokensFragment method onBindGravityDexToken.

// with Cosmos Gravity Dex gRPC
private void onBindGravityDexToken(TokensAdapter.AssetHolder holder, int position) {
    final Coin coin = mGravityDexGrpc.get(position);
    Picasso.get().load(COSMOS_COIN_IMG_URL + "gravitydex.png").fit().placeholder(R.drawable.token_ic).error(R.drawable.token_ic).into(holder.itemImg);
    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.itemInnerSymbol.setText("");
    Liquidity.Pool poolInfo = getBaseDao().getGravityPoolByDenom(coin.denom);
    if (poolInfo != null) {
        holder.itemSymbol.setText("GDEX-" + poolInfo.getId());
        holder.itemSymbol.setTextColor(getResources().getColor(R.color.colorWhite));
        holder.itemFullName.setText("pool/" + poolInfo.getId());
    }
    holder.itemRoot.setOnClickListener(new View.OnClickListener() {

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

Aggregations

Coin (wannabit.io.cosmostaion.model.type.Coin)126 BigDecimal (java.math.BigDecimal)85 ArrayList (java.util.ArrayList)28 TextView (android.widget.TextView)27 CardView (androidx.cardview.widget.CardView)27 View (android.view.View)25 RecyclerView (androidx.recyclerview.widget.RecyclerView)17 Intent (android.content.Intent)15 Abci (cosmos.base.abci.v1beta1.Abci)13 ImageView (android.widget.ImageView)12 Matcher (java.util.regex.Matcher)12 Pattern (java.util.regex.Pattern)12 CoinOuterClass (cosmos.base.v1beta1.CoinOuterClass)9 SpannableString (android.text.SpannableString)6 Balance (wannabit.io.cosmostaion.dao.Balance)6 Date (java.util.Date)5 IbcToken (wannabit.io.cosmostaion.dao.IbcToken)5 Fee (wannabit.io.cosmostaion.model.type.Fee)5 Bundle (android.os.Bundle)4 Lock (osmosis.lockup.Lock)4