Search in sources :

Example 1 with LinearLayoutManagerWrapper

use of com.samourai.wallet.util.LinearLayoutManagerWrapper in project samourai-wallet-android by Samourai-Wallet.

the class WhirlpoolMain method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_whirlpool_main);
    Toolbar toolbar = findViewById(R.id.toolbar_whirlpool);
    setSupportActionBar(toolbar);
    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }
    whirlpoolBalance = findViewById(R.id.whirlpool_balance_textview);
    collapsingToolbarLayout = findViewById(R.id.collapsing_toolbar_whirlpool_main);
    amountSubText = findViewById(R.id.toolbar_subtext);
    progressBar = findViewById(R.id.whirlpool_main_progressBar);
    premixList = findViewById(R.id.rv_whirlpool_dashboard);
    swipeRefreshLayout = findViewById(R.id.tx_swipe_container_whirlpool);
    findViewById(R.id.whirlpool_fab).setOnClickListener(view -> showBottomSheetDialog());
    premixList.setLayoutManager(new LinearLayoutManagerWrapper(this));
    adapter = new MixAdapter(new ArrayList<>());
    Drawable drawable = this.getResources().getDrawable(R.drawable.divider_grey);
    premixList.addItemDecoration(new ItemDividerDecorator(drawable));
    premixList.setAdapter(adapter);
    long postMixBalance = APIFactory.getInstance(WhirlpoolMain.this).getXpubPostMixBalance();
    long preMixBalance = APIFactory.getInstance(WhirlpoolMain.this).getXpubPreMixBalance();
    whirlpoolBalance.setText(getBTCDecimalFormat(postMixBalance + preMixBalance).concat(" BTC"));
    startWhirlpool();
    Disposable disposable = AndroidWhirlpoolWalletService.getInstance().listenConnectionStatus().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(connectionStates -> {
        if (connectionStates == AndroidWhirlpoolWalletService.ConnectionStates.CONNECTED) {
            listenPoolState();
            loadMixes(false);
        }
    });
    compositeDisposable.add(disposable);
    IntentFilter broadcastIntent = new IntentFilter(DISPLAY_INTENT);
    LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver(receiver, broadcastIntent);
    collapsingToolbarLayout.setOnClickListener(view -> switchBalance());
    swipeRefreshLayout.setOnRefreshListener(() -> {
        Intent intent = new Intent(this, JobRefreshService.class);
        intent.putExtra("notifTx", false);
        intent.putExtra("dragged", true);
        intent.putExtra("launch", false);
        JobRefreshService.enqueueWork(getApplicationContext(), intent);
        swipeRefreshLayout.setRefreshing(false);
        progressBar.setVisibility(View.VISIBLE);
        loadMixes(true);
    });
}
Also used : CompositeDisposable(io.reactivex.disposables.CompositeDisposable) Disposable(io.reactivex.disposables.Disposable) IntentFilter(android.content.IntentFilter) ItemDividerDecorator(com.samourai.wallet.widgets.ItemDividerDecorator) LinearLayoutManagerWrapper(com.samourai.wallet.util.LinearLayoutManagerWrapper) ArrayList(java.util.ArrayList) Drawable(android.graphics.drawable.Drawable) Intent(android.content.Intent) Toolbar(android.support.v7.widget.Toolbar)

Example 2 with LinearLayoutManagerWrapper

use of com.samourai.wallet.util.LinearLayoutManagerWrapper in project samourai-wallet-android by Samourai-Wallet.

the class UTXOSActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_utxos);
    toolbar = findViewById(R.id.toolbar_utxos);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    if (account == WhirlpoolMeta.getInstance(getApplicationContext()).getWhirlpoolPostmix()) {
        getSupportActionBar().setTitle(getText(R.string.unspent_outputs_post_mix));
    }
    noteAmounts = new TreeMap<String, Long>();
    tagAmounts = new TreeMap<String, Long>();
    df.setMinimumIntegerDigits(1);
    df.setMinimumFractionDigits(8);
    df.setMaximumFractionDigits(8);
    utxoList = findViewById(R.id.utxo_rv_list);
    utxoList.setItemViewCacheSize(24);
    utxoProgressBar = findViewById(R.id.utxo_progressBar);
    utxoSwipeRefresh = findViewById(R.id.utxo_swipe_container);
    adapter = new UTXOListAdapter();
    adapter.setHasStableIds(true);
    utxoList.setLayoutManager(new LinearLayoutManagerWrapper(this));
    utxoList.addItemDecoration(new ItemDividerDecorator(getDrawable(R.color.disabled_white)));
    utxoList.setAdapter(adapter);
    loadUTXOs(false);
    utxoSwipeRefresh.setOnRefreshListener(() -> {
        loadUTXOs(false);
    });
    if (!APIFactory.getInstance(getApplicationContext()).walletInit) {
        if (!shownWalletLoadingMessage) {
            Snackbar.make(utxoList.getRootView(), "Please wait... your wallet is still loading ", Snackbar.LENGTH_LONG).show();
            shownWalletLoadingMessage = true;
        }
    }
}
Also used : ItemDividerDecorator(com.samourai.wallet.widgets.ItemDividerDecorator) LinearLayoutManagerWrapper(com.samourai.wallet.util.LinearLayoutManagerWrapper)

Aggregations

LinearLayoutManagerWrapper (com.samourai.wallet.util.LinearLayoutManagerWrapper)2 ItemDividerDecorator (com.samourai.wallet.widgets.ItemDividerDecorator)2 Intent (android.content.Intent)1 IntentFilter (android.content.IntentFilter)1 Drawable (android.graphics.drawable.Drawable)1 Toolbar (android.support.v7.widget.Toolbar)1 CompositeDisposable (io.reactivex.disposables.CompositeDisposable)1 Disposable (io.reactivex.disposables.Disposable)1 ArrayList (java.util.ArrayList)1