source: other-projects/tipple-android/src/org/mapsforge/android/maps/ArrayItemizedOverlayTweaked.java@ 26523

Last change on this file since 26523 was 26523, checked in by davidb, 11 years ago

A version of Tipple with the mods Casey made for her Masters work

File size: 2.9 KB
Line 
1package org.mapsforge.android.maps;
2
3import java.util.ArrayList;
4import java.util.Collection;
5
6import android.app.AlertDialog;
7import android.content.Context;
8import android.graphics.drawable.Drawable;
9
10/**
11 * Thread-safe implementation of the {@link ItemizedOverlay} class using an
12 * {@link ArrayList} as internal data structure.
13 */
14public class ArrayItemizedOverlayTweaked extends ItemizedOverlay<OverlayItem> {
15 private static final int ARRAY_LIST_INITIAL_CAPACITY = 8;
16 private static final String THREAD_NAME = "ArrayItemizedOverlayTweaked";
17
18 protected final Context context;
19 protected AlertDialog.Builder dialog;
20 protected OverlayItem item;
21 protected final ArrayList<OverlayItem> overlayItems;
22
23 /**
24 * Constructs a new ArrayItemizedOverlay.
25 *
26 * @param defaultMarker
27 * the default marker.
28 * @param context
29 * the reference to the application context.
30 */
31 public ArrayItemizedOverlayTweaked(Drawable defaultMarker, Context context) {
32 super(boundCenterBottom(defaultMarker));
33 this.context = context;
34 this.overlayItems = new ArrayList<OverlayItem>(
35 ARRAY_LIST_INITIAL_CAPACITY);
36 }
37
38 /**
39 * Adds the given item to the Overlay.
40 *
41 * @param overlayItem
42 * the item that should be added to the Overlay.
43 */
44 public synchronized void addOverlay(OverlayItem overlayItem) {
45 this.overlayItems.add(overlayItem);
46 populate();
47 }
48
49 /**
50 * Adds all items of the given collection to the Overlay.
51 *
52 * @param c
53 * collection whose items should be added to the Overlay.
54 */
55 public synchronized void addOverlays(Collection<? extends OverlayItem> c) {
56 this.overlayItems.addAll(c);
57 populate();
58 }
59
60 /**
61 * Removes all items from the Overlay.
62 */
63 public synchronized void clear() {
64 this.overlayItems.clear();
65 populate();
66 }
67
68 @Override
69 public String getThreadName() {
70 return THREAD_NAME;
71 }
72
73 /**
74 * Removes the given item from the Overlay.
75 *
76 * @param overlayItem
77 * the item that should be removed from the Overlay.
78 */
79 public synchronized void removeOverlay(OverlayItem overlayItem) {
80 this.overlayItems.remove(overlayItem);
81 populate();
82 super.requestRedraw();
83 }
84
85 @Override
86 public synchronized int size() {
87 return this.overlayItems.size();
88 }
89
90 @Override
91 public synchronized OverlayItem createItem(int i) {
92 return this.overlayItems.get(i);
93 }
94
95 @Override
96 // you always need this even it doesn't do anything visibly
97 protected synchronized boolean onTap(int index) {
98
99 OverlayItem item = createItem(index);
100
101 if (item != null)
102 System.out.println("ArrayItemizedOverlayTweaked ontap");
103 return true;
104 // this.dialog = new AlertDialog.Builder(this.context);
105 // this.dialog.setTitle(this.item.getTitle());
106 // this.dialog.setMessage(this.item.getSnippet());
107 // this.dialog.show();
108 //
109 // return false;
110 }
111
112}
Note: See TracBrowser for help on using the repository browser.