Search in sources :

Example 1 with ViewBinder

use of android.widget.SimpleCursorAdapter.ViewBinder in project robolectric by robolectric.

the class ShadowSimpleCursorAdapter method bindView.

@Implementation
public void bindView(View view, Context context, Cursor cursor) {
    final ViewBinder binder = mViewBinder;
    final int count = mTo.length;
    final int[] from = mFrom;
    final int[] to = mTo;
    for (int i = 0; i < count; i++) {
        final View v = view.findViewById(to[i]);
        if (v != null) {
            boolean bound = false;
            if (binder != null) {
                bound = binder.setViewValue(v, cursor, from[i]);
            }
            if (!bound) {
                String text = cursor.getString(from[i]);
                if (text == null) {
                    text = "";
                }
                if (v instanceof TextView) {
                    setViewText((TextView) v, text);
                } else if (v instanceof ImageView) {
                    setViewImage((ImageView) v, text);
                } else {
                    throw new IllegalStateException(v.getClass().getName() + " is not a " + " view that can be bounds by this SimpleCursorAdapter");
                }
            }
        }
    }
}
Also used : TextView(android.widget.TextView) ViewBinder(android.widget.SimpleCursorAdapter.ViewBinder) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) Implementation(org.robolectric.annotation.Implementation)

Example 2 with ViewBinder

use of android.widget.SimpleCursorAdapter.ViewBinder in project assertj-android by square.

the class SimpleCursorAdapterAssert method hasViewBinder.

public SimpleCursorAdapterAssert hasViewBinder(ViewBinder binder) {
    isNotNull();
    ViewBinder actualBinder = actual.getViewBinder();
    // 
    assertThat(actualBinder).overridingErrorMessage("Expected view binder <%s> but was <%s>.", binder, // 
    actualBinder).isSameAs(binder);
    return this;
}
Also used : ViewBinder(android.widget.SimpleCursorAdapter.ViewBinder)

Example 3 with ViewBinder

use of android.widget.SimpleCursorAdapter.ViewBinder 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

ViewBinder (android.widget.SimpleCursorAdapter.ViewBinder)3 View (android.view.View)2 TextView (android.widget.TextView)2 Cursor (android.database.Cursor)1 ImageView (android.widget.ImageView)1 ListView (android.widget.ListView)1 SimpleCursorAdapter (android.widget.SimpleCursorAdapter)1 WholeStringBuilder (de.schildbach.wallet.util.WholeStringBuilder)1 Address (org.bitcoinj.core.Address)1 ECKey (org.bitcoinj.core.ECKey)1 Implementation (org.robolectric.annotation.Implementation)1