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