use of com.samourai.wallet.whirlpool.newPool.fragments.SelectPoolFragment in project samourai-wallet-android by Samourai-Wallet.
the class NewPoolActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_new_whirlpool_cycle);
Toolbar toolbar = findViewById(R.id.toolbar_new_whirlpool);
setSupportActionBar(toolbar);
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
cycleTotalAmount = findViewById(R.id.cycle_total_amount);
cycleTotalAmount.setText(MonetaryUtil.getInstance().getBTCFormat().format(((double) getCycleTotalAmount(new ArrayList<UTXOCoin>())) / 1e8) + " BTC");
fees.add(FeeUtil.getInstance().getLowFee().getDefaultPerKB().longValue() / 1000L);
fees.add(FeeUtil.getInstance().getNormalFee().getDefaultPerKB().longValue() / 1000L);
fees.add(FeeUtil.getInstance().getHighFee().getDefaultPerKB().longValue() / 1000L);
String preselectId = null;
if (getIntent().getExtras() != null && getIntent().getExtras().containsKey("preselected")) {
preselectId = getIntent().getExtras().getString("preselected");
}
if (getIntent().getExtras() != null && getIntent().getExtras().containsKey("_account")) {
account = getIntent().getExtras().getInt("_account");
}
chooseUTXOsFragment = ChooseUTXOsFragment.newInstance(preselectId);
selectPoolFragment = new SelectPoolFragment();
reviewPoolFragment = new ReviewPoolFragment();
selectPoolFragment.setFees(this.fees);
tx0Progress = findViewById(R.id.new_pool_tx0_progress);
newPoolViewPager = findViewById(R.id.new_pool_viewpager);
setUpStepper();
newPoolViewPager.setAdapter(new NewPoolStepsPager(getSupportFragmentManager()));
newPoolViewPager.enableSwipe(false);
confirmButton = findViewById(R.id.utxo_selection_confirm_btn);
confirmButton.setVisibility(View.VISIBLE);
enableConfirmButton(false);
// Disable selection from fragment since post mix utxo's are populated by the activity
if (account != WhirlpoolMeta.getInstance(getApplicationContext()).getWhirlpoolPostmix())
chooseUTXOsFragment.setOnUTXOSelectionListener(this::onUTXOSelected);
selectPoolFragment.setOnPoolSelectionComplete((poolViewModel, priority) -> {
selectedPoolViewModel = poolViewModel;
selectedPoolPriority = priority;
if (tx0 != null && poolViewModel != null) {
tx0.setPool(poolViewModel.getDenomination());
}
enableConfirmButton(selectedPoolViewModel != null);
});
confirmButton.setOnClickListener(view -> {
switch(newPoolViewPager.getCurrentItem()) {
case 0:
{
newPoolViewPager.setCurrentItem(1);
initUTXOReviewButton(selectedCoins);
enableConfirmButton(selectedPoolViewModel != null);
break;
}
case 1:
{
try {
tx0.make();
} catch (Exception ex) {
Toast.makeText(this, ex.getMessage(), Toast.LENGTH_LONG).show();
return;
}
calculateTx0(selectedPoolViewModel.getDenomination(), selectedPoolViewModel.getMinerFee() / 1000L);
newPoolViewPager.setCurrentItem(2);
confirmButton.setText(getString(R.string.begin_cycle));
confirmButton.setBackgroundResource(R.drawable.button_green);
reviewPoolFragment.setTx0(tx0);
break;
}
case 2:
{
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(R.string.block_tx0_change).setCancelable(false);
AlertDialog alert = builder.create();
alert.setTitle(R.string.doxxic_change_warning);
alert.setButton(AlertDialog.BUTTON_POSITIVE, getString(R.string.yes), (dialog, id) -> {
dialog.dismiss();
blockChangeOutput = true;
processWhirlPool();
});
alert.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.no), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
blockChangeOutput = false;
processWhirlPool();
}
});
if (!isFinishing()) {
alert.show();
}
break;
}
}
});
setUpViewPager();
if (getIntent().getExtras() != null && getIntent().getExtras().containsKey("_account")) {
if (account == WhirlpoolMeta.getInstance(getApplication()).getWhirlpoolPostmix()) {
selectedCoins.clear();
List<UTXOCoin> coinList = PreSelectUtil.getInstance().getPreSelected(preselectId);
try {
onUTXOSelected(coinList);
newPoolViewPager.setCurrentItem(1);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
Aggregations