/* clean the adapter from the items modified or erased */ private void removePoi(Integer indexAdapter) { PoiAdapter poisAdapter = getPoiAdapter(); POIObject objectToRemove = poisAdapter.getItem(indexAdapter); int i = 0; while (i < poisAdapter.getCount()) { if (poisAdapter.getItem(i).getEntityId() == objectToRemove.getEntityId()) { poisAdapter.remove(poisAdapter.getItem(i)); } else { i++; } } }
/* * insert in the same adapter the new item */ private void insertPOI(POIObject poi) { PoiAdapter poiAdapter = getPoiAdapter(); // add in the right place int i = 0; boolean insert = false; while (i < poiAdapter.getCount()) { if (poiAdapter.getItem(i).getTitle() != null) { if (poiAdapter.getItem(i).getTitle().toLowerCase().compareTo(poi.getTitle().toLowerCase()) <= 0) { i++; } else { poiAdapter.insert(poi, i); insert = true; break; } } } if (!insert) { poiAdapter.insert(poi, poiAdapter.getCount()); } }