ObservableAdapters: notify on map/list being set

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Samuel Holland 2017-08-18 23:25:40 -05:00
parent 5b4e957122
commit a49fe9adf5
3 changed files with 2 additions and 3 deletions

View File

@ -23,7 +23,6 @@ class ObservableListAdapter<T> extends BaseAdapter implements ListAdapter {
private final OnListChangedCallback<T> callback = new OnListChangedCallback<>(this); private final OnListChangedCallback<T> callback = new OnListChangedCallback<>(this);
ObservableListAdapter(final Context context, final int layoutId, final ObservableList<T> list) { ObservableListAdapter(final Context context, final int layoutId, final ObservableList<T> list) {
super();
layoutInflater = LayoutInflater.from(context); layoutInflater = LayoutInflater.from(context);
this.layoutId = layoutId; this.layoutId = layoutId;
setList(list); setList(list);
@ -61,6 +60,7 @@ class ObservableListAdapter<T> extends BaseAdapter implements ListAdapter {
if (list != null) { if (list != null) {
list.addOnListChangedCallback(callback); list.addOnListChangedCallback(callback);
} }
notifyDataSetChanged();
} }
private static class OnListChangedCallback<U> private static class OnListChangedCallback<U>
@ -69,7 +69,6 @@ class ObservableListAdapter<T> extends BaseAdapter implements ListAdapter {
private final WeakReference<ObservableListAdapter<U>> weakAdapter; private final WeakReference<ObservableListAdapter<U>> weakAdapter;
private OnListChangedCallback(final ObservableListAdapter<U> adapter) { private OnListChangedCallback(final ObservableListAdapter<U> adapter) {
super();
weakAdapter = new WeakReference<>(adapter); weakAdapter = new WeakReference<>(adapter);
} }

View File

@ -86,6 +86,7 @@ class ObservableMapAdapter<K extends Comparable<K>, V> extends BaseAdapter imple
if (map != null) { if (map != null) {
map.addOnMapChangedCallback(callback); map.addOnMapChangedCallback(callback);
} }
notifyDataSetChanged();
} }
private static class OnMapChangedCallback<K extends Comparable<K>, V> private static class OnMapChangedCallback<K extends Comparable<K>, V>

View File

@ -4,7 +4,6 @@ import android.databinding.MapChangeRegistry;
import android.databinding.ObservableMap; import android.databinding.ObservableMap;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.TreeMap; import java.util.TreeMap;