private void newList(IObservableCollection<?> list) { observableItemsLayoutID.clear(); videoListViews = new WeakList<View>(); if (list == null) { currentList = null; } else { currentList = new WeakList<Object>(); for (int pos = 0; pos < list.size(); pos++) { Object item = list.getItem(pos); // Log.e(VideoStripLayout.class.getName(), // "item " + item.toString()); insertItem(pos, item); currentList.add(item); } } }
private void listChanged(CollectionChangedEventArg e, IObservableCollection<?> collection) { if (e == null) return; int pos = -1; switch (e.getAction()) { case Add: pos = e.getNewStartingIndex(); for (Object item : e.getNewItems()) { insertItem(pos, item); pos++; } break; case Remove: removeItems(e.getOldItems()); break; case Replace: removeItems(e.getOldItems()); pos = e.getNewStartingIndex(); if (pos < 0) pos = 0; for (Object item : e.getNewItems()) { insertItem(pos, item); pos++; } break; case Reset: newList(collection); break; case Move: // currently the observable array list doesn't create this // action throw new IllegalArgumentException("move not implemented"); default: throw new IllegalArgumentException("unknown action " + e.getAction().toString()); } if (collection == null) return; currentList = new WeakList<Object>(); for (pos = 0; pos < collection.size(); pos++) { Object item = collection.getItem(pos); currentList.add(item); } prepareChildViews(); }