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