source: other-projects/tipple-android/trunk/src/org/mapsforge/android/maps/ArrayItemizedMarkerOverlay.java@ 23977

Last change on this file since 23977 was 23977, checked in by davidb, 13 years ago

Initial set of files for the Tipple project, to be run on an Android device

File size: 2.5 KB
Line 
1package org.mapsforge.android.maps;
2
3
4import java.util.ArrayList;
5import java.util.Collection;
6
7import android.app.AlertDialog;
8import android.content.Context;
9import android.graphics.drawable.Drawable;
10
11/**
12 * Thread-safe implementation of the {@link ItemizedMarkerOverlay} class using an {@link ArrayList} as
13 * internal data structure.
14 */
15public class ArrayItemizedMarkerOverlay extends ItemizedMarkerOverlay<OverlayMarkerItem> {
16 private static final int ARRAY_LIST_INITIAL_CAPACITY = 8;
17 private static final String THREAD_NAME = "ArrayItemizedMarkerOverlay";
18
19 protected final Context context;
20 protected AlertDialog.Builder dialog;
21 protected OverlayItem item;
22 protected final ArrayList<OverlayMarkerItem> overlayMarkerItems;
23
24 /**
25 * Constructs a new ArrayItemizedOverlay.
26 *
27 * @param defaultMarker
28 * the default marker.
29 * @param context
30 * the reference to the application context.
31 */
32 public ArrayItemizedMarkerOverlay(Drawable defaultMarker, Context context) {
33 super(boundCenterBottom(defaultMarker));
34 this.context = context;
35 this.overlayMarkerItems = new ArrayList<OverlayMarkerItem>(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(OverlayMarkerItem overlayItem) {
45 this.overlayMarkerItems.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 OverlayMarkerItem> c) {
56 this.overlayMarkerItems.addAll(c);
57 populate();
58 }
59
60 /**
61 * Removes all items from the Overlay.
62 */
63 public synchronized void clear() {
64 this.overlayMarkerItems.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 overlayMarkerItem
77 * the item that should be removed from the Overlay.
78 */
79 public synchronized void removeOverlay(OverlayMarkerItem overlayMarkerItem) {
80 this.overlayMarkerItems.remove(overlayMarkerItem);
81 populate();
82 }
83
84 @Override
85 public synchronized int size() {
86 return this.overlayMarkerItems.size();
87 }
88
89 @Override
90 public synchronized OverlayMarkerItem createItem(int i) {
91 return this.overlayMarkerItems.get(i);
92 }
93}
Note: See TracBrowser for help on using the repository browser.