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