private void handleAppendItems(Object data) { if (data instanceof Object[]) { Object[] views = (Object[]) data; if (itemProperties == null) { itemProperties = new ArrayList<Object>(Arrays.asList(views)); } else { for (Object view : views) { itemProperties.add(view); } } // only process items when listview's properties is processed. if (getListView() == null) { preload = true; return; } // we must update the itemCount before notify data change. If we don't, it will crash int count = itemCount; itemCount += views.length; processData(views, count); } else { Log.e(TAG, "Invalid argument type to setData", Log.DEBUG_MODE); } }
private void handleInsertItemsAt(int index, Object data) { if (data instanceof Object[]) { Object[] views = (Object[]) data; if (itemProperties == null) { itemProperties = new ArrayList<Object>(Arrays.asList(views)); } else { if (index < 0 || index > itemProperties.size()) { Log.e(TAG, "Invalid index to handleInsertItem", Log.DEBUG_MODE); return; } int counter = index; for (Object view : views) { itemProperties.add(counter, view); counter++; } } // only process items when listview's properties is processed. if (getListView() == null) { preload = true; return; } itemCount += views.length; processData(views, index); } else { Log.e(TAG, "Invalid argument type to insertItemsAt", Log.DEBUG_MODE); } }
private void handleSetItems(Object data) { if (data instanceof Object[]) { Object[] items = (Object[]) data; itemProperties = new ArrayList<Object>(Arrays.asList(items)); listItemData.clear(); // only process items when listview's properties is processed. if (getListView() == null) { preload = true; return; } itemCount = items.length; processData(items, 0); } else { Log.e(TAG, "Invalid argument type to setData", Log.DEBUG_MODE); } }