ObservableArrayMapAdapter: Remove

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Samuel Holland
2017-08-17 02:44:18 -05:00
parent 25412e0537
commit 44561a9cb6
2 changed files with 0 additions and 120 deletions
@@ -14,34 +14,6 @@ import android.widget.TextView;
@SuppressWarnings("unused")
public final class BindingAdapters {
@BindingAdapter({"items", "layout"})
public static <K, V> void arrayMapBinding(final ListView view,
final ObservableArrayMap<K, V> oldMap,
final int oldLayoutId,
final ObservableArrayMap<K, V> newMap,
final int newLayoutId) {
// Remove any existing binding when there is no new map.
if (newMap == null) {
view.setAdapter(null);
return;
}
// The ListAdapter interface is not generic, so this cannot be checked.
@SuppressWarnings("unchecked")
ObservableArrayMapAdapter<K, V> adapter =
(ObservableArrayMapAdapter<K, V>) view.getAdapter();
// If the layout changes, any existing adapter must be replaced.
if (newLayoutId != oldLayoutId)
adapter = null;
// Add a new binding if there was none, or if it must be replaced due to a layout change.
if (adapter == null) {
adapter = new ObservableArrayMapAdapter<>(view.getContext(), newLayoutId, newMap);
view.setAdapter(adapter);
} else if (newMap != oldMap) {
// Changing the list only requires modifying the existing adapter.
adapter.setMap(newMap);
}
}
@BindingAdapter({"items", "layout"})
public static <T> void listBinding(final ListView view,
final ObservableList<T> oldList, final int oldLayoutId,