- Code: Select all
02-04 23:28:56.188: INFO/NotificationService(52): enqueueToast pkg=android.mapit callback=android.app.ITransientNotification$Stub$Proxy@4394c100 duration=0
If I add a second item and click ANY of the other items, the onTap method gets called twice and I get the following in LogCat:
- Code: Select all
02-04 23:29:29.408: INFO/NotificationService(52): enqueueToast pkg=android.mapit callback=android.app.ITransientNotification$Stub$Proxy@438b4048 duration=0
02-04 23:29:29.418: INFO/NotificationService(52): enqueueToast pkg=android.mapit callback=android.app.ITransientNotification$Stub$Proxy@43950d20 duration=0
If I add a third item and click ANY of the other items, the onTap method gets called three times and I get the following in LogCat:
- Code: Select all
02-04 23:30:32.007: INFO/NotificationService(52): enqueueToast pkg=android.mapit callback=android.app.ITransientNotification$Stub$Proxy@4394fcf8 duration=0
02-04 23:30:32.017: INFO/NotificationService(52): enqueueToast pkg=android.mapit callback=android.app.ITransientNotification$Stub$Proxy@43950408 duration=0
02-04 23:30:32.028: INFO/NotificationService(52): enqueueToast pkg=android.mapit callback=android.app.ITransientNotification$Stub$Proxy@438babe0 duration=0
Any idea why this would occur? I'm running into issues with it affecting other things like removal of items.
Using java Syntax Highlighting
- public class POIItemizedOverlay extends ItemizedOverlay {
- SparseArray<OverlayItem> mOverlays = new SparseArray<OverlayItem>();
- int key = 0;
- Context mContext;
- Projection proj;
- List<Overlay> mapOverlays;
- OverlayItem overlayItem;
- MapView view;
- boolean remove;
- public POIDatabase db;
- boolean done;
- public POIItemizedOverlay(Context context, Drawable defaultMarker, MapView mapView) {
- super(boundCenterBottom(defaultMarker));
- mContext = context;
- proj = mapView.getProjection();
- view = mapView;
- mapOverlays = mapView.getOverlays();
- db = new POIDatabase(mContext);
- }
- public void populatePOIs() {
- db.open();
- Cursor c = db.getAllGeoPoints();
- clearAll();
- if (c.moveToFirst()) {
- do {
- GeoPoint d = new GeoPoint(Integer.parseInt(c.getString(2)), Integer.parseInt(c.getString(1)));
- overlayItem = new OverlayItem(d, c.getString(3), c.getString(4));
- this.addOverlay(overlayItem, (Integer.parseInt(c.getString(0))-1));
- mapOverlays.add(this);
- } while (c.moveToNext());
- done = true;
- }
- setLastFocusedIndex(-1);
- db.close();
- }
- public void addLocation(GeoPoint p, String title, String desc) {
- db.open();
- if (done == true) {
- Cursor c = db.getAllGeoPoints();
- c.moveToLast();
- key = Integer.parseInt(c.getString(0));
- } else {
- key = 0;
- done = true;
- }
- db.insertGeoPoint(p.getLongitudeE6(), p.getLatitudeE6(), title, desc, 1, 1);
- OverlayItem overlayItem = new OverlayItem(p, title, desc);
- this.addOverlay(overlayItem, key);
- mapOverlays.add(this);
- db.close();
- }
- public void remove() {
- this.remove = true;
- }
- public void addOverlay(OverlayItem overlay, int key) {
- Log.w("DONE", String.valueOf(done));
- mOverlays.put(key, overlay);
- populate();
- view.invalidate();
- }
- public void removeOverlay(int pIndex) {
- //db.open();
- //db.deleteGeoPoint(mOverlays.get(pIndex).getPoint().getLongitudeE6());
- //db.close();
- //mOverlays.delete(pIndex);
- System.out.println(pIndex);
- mOverlays.delete(pIndex);
- setLastFocusedIndex(-1);
- //view.invalidate();
- }
- public void clearAll() {
- db.open();
- db.deleteAllGeoPoints();
- db.close();
- mOverlays.clear();
- view.invalidate();
- }
- @Override
- public boolean onTap(int pIndex) {
- if (this.remove == true) {
- removeOverlay(pIndex);
- Log.w("PINDEX", String.valueOf(pIndex));
- this.remove = false;
- Toast.makeText(mContext, "POI Removed", Toast.LENGTH_SHORT).show();
- } else {
- Toast.makeText(mContext, mOverlays.get(pIndex).getSnippet(), Toast.LENGTH_SHORT).show();
- }
- return false;
- }
- @Override
- protected OverlayItem createItem(int i) {
- return mOverlays.get(i);
- }
- @Override
- public int size() {
- // TODO Auto-generated method stub
- return mOverlays.size();
- }
- }
Parsed in 0.042 seconds, using GeSHi 1.0.8.4


