Search in sources :

Example 6 with AddressBookEntry

use of de.schildbach.wallet.addressbook.AddressBookEntry in project bitcoin-wallet by bitcoin-wallet.

the class BlockListFragment method maybeSubmitList.

private void maybeSubmitList() {
    final List<StoredBlock> blocks = viewModel.blocks.getValue();
    final Wallet wallet = walletActivityViewModel.wallet.getValue();
    if (blocks != null) {
        final Map<String, AddressBookEntry> addressBook = AddressBookEntry.asMap(viewModel.addressBook.getValue());
        adapter.submitList(BlockListAdapter.buildListItems(activity, blocks, viewModel.getTime().getValue(), config.getFormat(), viewModel.getTransactions().getValue(), wallet, addressBook));
    }
}
Also used : StoredBlock(org.bitcoinj.core.StoredBlock) Wallet(org.bitcoinj.wallet.Wallet) AddressBookEntry(de.schildbach.wallet.addressbook.AddressBookEntry)

Example 7 with AddressBookEntry

use of de.schildbach.wallet.addressbook.AddressBookEntry in project bitcoin-wallet by bitcoin-wallet.

the class WalletTransactionsViewModel method maybePostList.

private void maybePostList() {
    AsyncTask.execute(() -> {
        org.bitcoinj.core.Context.propagate(Constants.CONTEXT);
        final Set<Transaction> transactions = WalletTransactionsViewModel.this.transactions.getValue();
        final MonetaryFormat format = configFormat.getValue();
        final Map<String, AddressBookEntry> addressBook = AddressBookEntry.asMap(WalletTransactionsViewModel.this.addressBook.getValue());
        if (transactions != null && format != null && addressBook != null) {
            final List<Transaction> filteredTransactions = new ArrayList<>(transactions.size());
            final Wallet wallet = application.getWallet();
            final Direction direction = WalletTransactionsViewModel.this.direction.getValue();
            for (final Transaction tx : transactions) {
                final boolean sent = tx.getValue(wallet).signum() < 0;
                final boolean isInternal = tx.getPurpose() == Purpose.KEY_ROTATION;
                if ((direction == Direction.RECEIVED && !sent && !isInternal) || direction == null || (direction == Direction.SENT && sent && !isInternal))
                    filteredTransactions.add(tx);
            }
            Collections.sort(filteredTransactions, TRANSACTION_COMPARATOR);
            list.postValue(TransactionsAdapter.buildListItems(application, filteredTransactions, warning.getValue(), wallet, addressBook, format, application.maxConnectedPeers()));
        }
    });
}
Also used : MonetaryFormat(org.bitcoinj.utils.MonetaryFormat) Transaction(org.bitcoinj.core.Transaction) Wallet(org.bitcoinj.wallet.Wallet) ArrayList(java.util.ArrayList) AddressBookEntry(de.schildbach.wallet.addressbook.AddressBookEntry)

Aggregations

AddressBookEntry (de.schildbach.wallet.addressbook.AddressBookEntry)7 Address (org.bitcoinj.core.Address)4 Wallet (org.bitcoinj.wallet.Wallet)4 Transaction (org.bitcoinj.core.Transaction)3 ArrayList (java.util.ArrayList)2 Coin (org.bitcoinj.core.Coin)2 MonetaryFormat (org.bitcoinj.utils.MonetaryFormat)2 Dialog (android.app.Dialog)1 Context (android.content.Context)1 DialogInterface (android.content.DialogInterface)1 Typeface (android.graphics.Typeface)1 Bundle (android.os.Bundle)1 Handler (android.os.Handler)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 TextView (android.widget.TextView)1 Nullable (androidx.annotation.Nullable)1 DialogFragment (androidx.fragment.app.DialogFragment)1 FragmentManager (androidx.fragment.app.FragmentManager)1 ViewModelProvider (androidx.lifecycle.ViewModelProvider)1