Search in sources :

Example 1 with OsmosisPeriodLockWrapper

use of wannabit.io.cosmostaion.utils.OsmosisPeriodLockWrapper in project cosmostation-android by cosmostation.

the class EarningOtherHolder method onBindView.

public void onBindView(Context c, BaseActivity activity, BaseData baseData, BalancerPoolOuterClass.BalancerPool pool, ArrayList<Lock.PeriodLock> lockups, ArrayList<GaugeOuterClass.Gauge> gauges) {
    Coin coin0 = new Coin(pool.getPoolAssets(0).getToken().getDenom(), pool.getPoolAssets(0).getToken().getAmount());
    Coin coin1 = new Coin(pool.getPoolAssets(1).getToken().getDenom(), pool.getPoolAssets(1).getToken().getAmount());
    BigDecimal lpCoinPrice = WUtil.getOsmoLpTokenPerUsdPrice(baseData, pool);
    BigDecimal apr = WUtil.getPoolArp(baseData, pool, gauges, 2);
    itemPoolId.setText("#" + pool.getId() + " EARNING");
    itemPoolCoinPair.setText(WUtil.dpOsmosisTokenName(baseData, coin0.denom) + " / " + WUtil.dpOsmosisTokenName(baseData, coin1.denom));
    itemPoolApr.setText(WDp.getPercentDp(apr));
    // display available
    BigDecimal availableAmount = baseData.getAvailable("gamm/pool/" + pool.getId());
    BigDecimal availableValue = availableAmount.multiply(lpCoinPrice).movePointLeft(18).setScale(2, RoundingMode.DOWN);
    itemAvailableAmount.setText(WDp.getDpAmount2(c, availableAmount, 18, 6));
    itemAvailableDenom.setText("GAMM-" + pool.getId());
    itemAvailableValue.setText(WDp.getDpRawDollor(c, availableValue, 2));
    itemRoot.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent intent = new Intent(activity, EarningDetailActivity.class);
            intent.putExtra("osmosisPool", pool.toByteArray());
            OsmosisGaugeWrapper gaugesWrapper = new OsmosisGaugeWrapper(gauges);
            intent.putExtra("osmosisGauges", gaugesWrapper);
            OsmosisPeriodLockWrapper lockupsWrapper = new OsmosisPeriodLockWrapper(lockups);
            intent.putExtra("osmosislockups", lockupsWrapper);
            activity.startActivity(intent);
        }
    });
}
Also used : Coin(wannabit.io.cosmostaion.model.type.Coin) OsmosisGaugeWrapper(wannabit.io.cosmostaion.utils.OsmosisGaugeWrapper) EarningDetailActivity(wannabit.io.cosmostaion.activities.chains.osmosis.EarningDetailActivity) Intent(android.content.Intent) OsmosisPeriodLockWrapper(wannabit.io.cosmostaion.utils.OsmosisPeriodLockWrapper) TextView(android.widget.TextView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) CardView(androidx.cardview.widget.CardView) BigDecimal(java.math.BigDecimal)

Example 2 with OsmosisPeriodLockWrapper

use of wannabit.io.cosmostaion.utils.OsmosisPeriodLockWrapper in project cosmostation-android by cosmostation.

the class Dialog_Osmo_Unlock_All method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.dialog_osmo_unlock_all, container, false);
    Button btnAll = view.findViewById(R.id.btn_all);
    Button btnOne = view.findViewById(R.id.btn_one);
    TextView msgTv = view.findViewById(R.id.lock_ids);
    OsmosisPeriodLockWrapper lockupWrapper = (OsmosisPeriodLockWrapper) getArguments().getSerializable("all");
    ArrayList<Lock.PeriodLock> lockups = lockupWrapper.array;
    String msg = "";
    for (Lock.PeriodLock lock : lockups) {
        msg = msg + "# " + lock.getID() + "  ";
    }
    // String amount = new BigDecimal(getArguments().getString("amount")).movePointLeft(18).toPlainString();
    // msg = msg + "\n" + amount;
    msgTv.setText(msg);
    btnAll.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            OsmosisPeriodLockWrapper lockupWrapper = (OsmosisPeriodLockWrapper) getArguments().getSerializable("all");
            ArrayList<Lock.PeriodLock> lockups = lockupWrapper.array;
            ((EarningDetailActivity) getActivity()).onStartUnlock(lockups);
            dismiss();
        }
    });
    btnOne.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            try {
                Lock.PeriodLock lockup = Lock.PeriodLock.parseFrom(getArguments().getByteArray("single"));
                ArrayList<Lock.PeriodLock> lockups = new ArrayList<>();
                lockups.add(lockup);
                ((EarningDetailActivity) getActivity()).onStartUnlock(lockups);
            } catch (Exception e) {
                WLog.w("e " + e.getMessage());
            }
            dismiss();
        }
    });
    return view;
}
Also used : ArrayList(java.util.ArrayList) TextView(android.widget.TextView) View(android.view.View) Lock(osmosis.lockup.Lock) Button(android.widget.Button) TextView(android.widget.TextView) OsmosisPeriodLockWrapper(wannabit.io.cosmostaion.utils.OsmosisPeriodLockWrapper)

Example 3 with OsmosisPeriodLockWrapper

use of wannabit.io.cosmostaion.utils.OsmosisPeriodLockWrapper in project cosmostation-android by cosmostation.

the class EarningDetailActivity method onCheckUnbonding.

public void onCheckUnbonding(Lock.PeriodLock lockup) {
    WLog.w("onCheckUnbonding " + lockup.getID());
    if (!mAccount.hasPrivateKey) {
        AlertDialogUtils.showDoubleButtonDialog(this, getString(R.string.str_only_observe_title), getString(R.string.str_only_observe_msg), Html.fromHtml("<font color=\"#9C6CFF\">" + getString(R.string.str_add_mnemonics) + "</font>"), view -> onAddMnemonicForAccount(), getString(R.string.str_close), null);
        return;
    }
    ArrayList<Lock.PeriodLock> tempLockups = new ArrayList<>();
    BigDecimal totalToUnbonding = BigDecimal.ZERO;
    for (Lock.PeriodLock lock : mBondedList) {
        if (lock.getDuration().getSeconds() == lockup.getDuration().getSeconds()) {
            tempLockups.add(lock);
            totalToUnbonding = totalToUnbonding.add(new BigDecimal(lock.getCoins(0).getAmount()));
        }
    }
    if (tempLockups.size() > 1) {
        // display dialog for start unbonding all for same class
        OsmosisPeriodLockWrapper lockupsWrapper = new OsmosisPeriodLockWrapper(tempLockups);
        ArrayList<Lock.PeriodLock> lockups = lockupsWrapper.array;
        String msg = "";
        for (Lock.PeriodLock lock : lockups) {
            msg = msg + "# " + lock.getID() + "  ";
        }
        // String amount = new BigDecimal(totalToUnbonding.toPlainString()).movePointLeft(18).toPlainString();
        // msg = msg + "\n" + amount;
        PaddedVerticalButtonAlertDialog.showDoubleButton(this, "Unbonding all for same durations?", msg, "Unbonding All", view -> onStartUnbonding(lockups), "Unbonding This One", view -> {
            try {
                Lock.PeriodLock lock = Lock.PeriodLock.parseFrom(lockup.toByteArray());
                ArrayList<Lock.PeriodLock> Lock = new ArrayList<>();
                Lock.add(lock);
                onStartUnbonding(Lock);
            } catch (InvalidProtocolBufferException e) {
                e.printStackTrace();
            }
        });
    } else {
        onStartUnbonding(tempLockups);
    }
}
Also used : ArrayList(java.util.ArrayList) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) OsmosisPeriodLockWrapper(wannabit.io.cosmostaion.utils.OsmosisPeriodLockWrapper) BigDecimal(java.math.BigDecimal) Lock(osmosis.lockup.Lock)

Example 4 with OsmosisPeriodLockWrapper

use of wannabit.io.cosmostaion.utils.OsmosisPeriodLockWrapper in project cosmostation-android by cosmostation.

the class EarningDetailActivity method onStartUnbonding.

public void onStartUnbonding(ArrayList<Lock.PeriodLock> lockups) {
    WLog.w("onStartUnbonding " + lockups.size());
    Intent intent = new Intent(this, StartUnbondingActivity.class);
    OsmosisPeriodLockWrapper lockupsWrapper = new OsmosisPeriodLockWrapper(lockups);
    intent.putExtra("osmosislockups", lockupsWrapper);
    startActivity(intent);
}
Also used : Intent(android.content.Intent) OsmosisPeriodLockWrapper(wannabit.io.cosmostaion.utils.OsmosisPeriodLockWrapper)

Example 5 with OsmosisPeriodLockWrapper

use of wannabit.io.cosmostaion.utils.OsmosisPeriodLockWrapper in project cosmostation-android by cosmostation.

the class StartUnbondingActivity method onCreate.

// BaseBroadCastActivity의 mOsmosisLockups 사용
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_step);
    mRootView = findViewById(R.id.root_view);
    mToolbar = findViewById(R.id.tool_bar);
    mTitle = findViewById(R.id.toolbar_title);
    mIvStep = findViewById(R.id.send_step);
    mTvStep = findViewById(R.id.send_step_msg);
    mViewPager = findViewById(R.id.view_pager);
    mTitle.setText(getString(R.string.str_title_start_unbonding_osmosis));
    mTxType = CONST_PW_TX_OSMOSIS_BEGIN_UNBONDING;
    setSupportActionBar(mToolbar);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    mIvStep.setImageDrawable(getDrawable(R.drawable.step_4_img_1));
    mTvStep.setText(getString(R.string.str_osmosis_start_unbonding_step_0));
    mAccount = getBaseDao().onSelectAccount(getBaseDao().getLastUser());
    mBaseChain = BaseChain.getChain(mAccount.baseChain);
    OsmosisPeriodLockWrapper lockupsWrapper = (OsmosisPeriodLockWrapper) getIntent().getSerializableExtra("osmosislockups");
    mOsmosisLockups = lockupsWrapper.array;
    mPageAdapter = new UnBondingPageAdapter(getSupportFragmentManager());
    mViewPager.setOffscreenPageLimit(3);
    mViewPager.setAdapter(mPageAdapter);
    mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageScrolled(int i, float v, int i1) {
        }

        @Override
        public void onPageSelected(int i) {
            if (i == 0) {
                mIvStep.setImageDrawable(getDrawable(R.drawable.step_4_img_1));
                mTvStep.setText(getString(R.string.str_osmosis_start_unbonding_step_0));
                mPageAdapter.mCurrentFragment.onRefreshTab();
            } else if (i == 1) {
                mIvStep.setImageDrawable(getDrawable(R.drawable.step_4_img_2));
                mTvStep.setText(getString(R.string.str_osmosis_start_unbonding_step_1));
            } else if (i == 2) {
                mIvStep.setImageDrawable(getDrawable(R.drawable.step_4_img_3));
                mTvStep.setText(getString(R.string.str_osmosis_start_unbonding_step_2));
                mPageAdapter.mCurrentFragment.onRefreshTab();
            } else if (i == 3) {
                mIvStep.setImageDrawable(getDrawable(R.drawable.step_4_img_4));
                mTvStep.setText(getString(R.string.str_osmosis_start_unbonding_step_3));
                mPageAdapter.mCurrentFragment.onRefreshTab();
            }
        }

        @Override
        public void onPageScrollStateChanged(int i) {
        }
    });
    mViewPager.setCurrentItem(0);
    mRootView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            onHideKeyboard();
        }
    });
}
Also used : OsmosisPeriodLockWrapper(wannabit.io.cosmostaion.utils.OsmosisPeriodLockWrapper) ViewPager(androidx.viewpager.widget.ViewPager) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView)

Aggregations

OsmosisPeriodLockWrapper (wannabit.io.cosmostaion.utils.OsmosisPeriodLockWrapper)16 Intent (android.content.Intent)8 View (android.view.View)8 TextView (android.widget.TextView)8 BigDecimal (java.math.BigDecimal)7 Lock (osmosis.lockup.Lock)7 Coin (wannabit.io.cosmostaion.model.type.Coin)5 OsmosisGaugeWrapper (wannabit.io.cosmostaion.utils.OsmosisGaugeWrapper)5 CardView (androidx.cardview.widget.CardView)4 RecyclerView (androidx.recyclerview.widget.RecyclerView)4 ArrayList (java.util.ArrayList)4 EarningDetailActivity (wannabit.io.cosmostaion.activities.chains.osmosis.EarningDetailActivity)4 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)3 Date (java.util.Date)3 Button (android.widget.Button)2 ImageView (android.widget.ImageView)2 ViewPager (androidx.viewpager.widget.ViewPager)2 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)1 QueryOuterClass (irismod.nft.QueryOuterClass)1 Querier (sifnode.clp.v1.Querier)1