Listener(final ObservableArrayMap<K, V> observableArrayMap, final Observer<? super ObservableArrayMapOnMapChangeEvent<K, V>> observer) { this.observableArrayMap = observableArrayMap; this.onMapChangedCallback = new ObservableMap.OnMapChangedCallback<ObservableArrayMap<K, V>, K, V>() { @Override public void onMapChanged(ObservableArrayMap<K, V> observableArrayMap, K key) { observer.onNext(ObservableArrayMapOnMapChangeEvent.create(observableArrayMap, key)); } }; }
@BindingAdapter("entries_orders") public static void entriesBasket(RecyclerView recyclerView, ObservableMap<Food, Integer> orders) { if (recyclerView.getAdapter() == null) recyclerView.setAdapter(new PayListAdapter(orders)); else { Logs.d("entries_orders调用"); PayListAdapter adapter = (PayListAdapter) recyclerView.getAdapter(); adapter.setBasket(orders); } }
public void setBasket(ObservableMap<Food, Integer> orders) { foods = new Food[orders.size()]; numbs = new Integer[orders.size()]; orders.keySet().toArray(foods); orders.values().toArray(numbs); notifyDataSetChanged(); }
private static <K, V> void handleMapChange(ObservableMap<K, V> map, K key, Class c, String field, ArrayMap<K, CinderPair> cinderPairs, CinderObservable observation) { if (cinderPairs.get(key) == null) { observeMapFieldForClass(c, field, key, map.get(key), cinderPairs, observation); } else { CinderPair cinderPair = cinderPairs.get(key); cinderPair.getObservable().removeOnPropertyChangedCallback(cinderPair.getCallback()); cinderPairs.remove(key); if (map.get(key) != null){ observeMapFieldForClass(c, field, key, map.get(key), cinderPairs, observation); } } }
public PayListAdapter(ObservableMap<Food, Integer> orders) { foods = new Food[orders.size()]; numbs = new Integer[orders.size()]; orders.keySet().toArray(foods); orders.values().toArray(numbs); }
public static CinderComputable observable(ObservableMap map){ CinderComputable computable = new CinderComputable(); computable.setBehaviour(Cinder.observe(computable::notifyChange, map)); return computable; }
public static CinderComputable observable(ObservableMap map, Class c, String... fields){ CinderComputable computable = new CinderComputable(); computable.setBehaviour(Cinder.observe(computable::notifyChange, map, c, fields)); return computable; }
public static <K, V> CinderObservable observe(OnChangeCallback onChangeCallback, ObservableMap<K, V> map) { return Cinder.observe(onChangeCallback, map, null); }
CinderMapPair(ObservableMap<K,V> observableMap){ this.observableMap = observableMap; }
public void setCallback(ObservableMap.OnMapChangedCallback callback){ this.callback = callback; }