Search in sources :

Example 61 with SimpleCursorAdapter

use of android.widget.SimpleCursorAdapter in project bitcoin-wallet by bitcoin-wallet.

the class SendingAddressesFragment method onCreate.

@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setHasOptionsMenu(true);
    adapter = new SimpleCursorAdapter(activity, R.layout.address_book_row, null, new String[] { AddressBookProvider.KEY_LABEL, AddressBookProvider.KEY_ADDRESS }, new int[] { R.id.address_book_row_label, R.id.address_book_row_address }, 0);
    adapter.setViewBinder(new ViewBinder() {

        @Override
        public boolean setViewValue(final View view, final Cursor cursor, final int columnIndex) {
            if (!AddressBookProvider.KEY_ADDRESS.equals(cursor.getColumnName(columnIndex)))
                return false;
            ((TextView) view).setText(WalletUtils.formatHash(cursor.getString(columnIndex), Constants.ADDRESS_FORMAT_GROUP_SIZE, Constants.ADDRESS_FORMAT_LINE_SIZE));
            return true;
        }
    });
    setListAdapter(adapter);
    final List<ECKey> derivedKeys = wallet.getIssuedReceiveKeys();
    Collections.sort(derivedKeys, DeterministicKey.CHILDNUM_ORDER);
    final List<ECKey> randomKeys = wallet.getImportedKeys();
    final StringBuilder builder = new StringBuilder();
    for (final ECKey key : Iterables.concat(derivedKeys, randomKeys)) {
        final Address address = key.toAddress(Constants.NETWORK_PARAMETERS);
        builder.append(address.toBase58()).append(",");
    }
    if (builder.length() > 0)
        builder.setLength(builder.length() - 1);
    walletAddressesSelection = builder.toString();
    loaderManager.initLoader(0, null, this);
}
Also used : WholeStringBuilder(de.schildbach.wallet.util.WholeStringBuilder) Address(org.bitcoinj.core.Address) SimpleCursorAdapter(android.widget.SimpleCursorAdapter) ECKey(org.bitcoinj.core.ECKey) ViewBinder(android.widget.SimpleCursorAdapter.ViewBinder) Cursor(android.database.Cursor) View(android.view.View) TextView(android.widget.TextView) ListView(android.widget.ListView)

Aggregations

SimpleCursorAdapter (android.widget.SimpleCursorAdapter)61 Cursor (android.database.Cursor)38 ListAdapter (android.widget.ListAdapter)16 ListView (android.widget.ListView)14 AlphaAnimation (android.view.animation.AlphaAnimation)6 Animation (android.view.animation.Animation)6 AnimationSet (android.view.animation.AnimationSet)6 LayoutAnimationController (android.view.animation.LayoutAnimationController)6 TranslateAnimation (android.view.animation.TranslateAnimation)6 View (android.view.View)5 TextView (android.widget.TextView)3 Test (org.junit.Test)3 Intent (android.content.Intent)2 Uri (android.net.Uri)2 ContentResolver (android.content.ContentResolver)1 ContentValues (android.content.ContentValues)1 MatrixCursor (android.database.MatrixCursor)1 Drawable (android.graphics.drawable.Drawable)1 OnClickListener (android.view.View.OnClickListener)1 LayoutParams (android.view.ViewGroup.LayoutParams)1