1 | package org.greenstone.android.tipple.base;
|
---|
2 |
|
---|
3 | import java.util.List;
|
---|
4 | import java.util.HashMap;
|
---|
5 |
|
---|
6 | import android.graphics.Color;
|
---|
7 | //import java.util.ArrayList;
|
---|
8 |
|
---|
9 | public class TipLocation
|
---|
10 | {
|
---|
11 |
|
---|
12 | // Text and/or Audio associated with (Latitude,Longitude) location with radius
|
---|
13 |
|
---|
14 | private double latitude_;
|
---|
15 | private double longitude_;
|
---|
16 |
|
---|
17 | private double radiusInKM_;
|
---|
18 | //private double avgRadLatLong_;
|
---|
19 |
|
---|
20 | private String title_;
|
---|
21 | private String text_;
|
---|
22 | private String tts_text_;
|
---|
23 |
|
---|
24 | private String title_tts_;
|
---|
25 |
|
---|
26 | private String colour_fill_;
|
---|
27 | private String colour_outline_;
|
---|
28 |
|
---|
29 |
|
---|
30 | private String audioFilename_;
|
---|
31 | private List<String> audioPaths_;
|
---|
32 |
|
---|
33 | protected String id_;
|
---|
34 |
|
---|
35 | public TipLocation(HashMap<String,String> hashmap)
|
---|
36 | {
|
---|
37 | latitude_ = Double.parseDouble(hashmap.get("latitude"));
|
---|
38 | longitude_ = Double.parseDouble(hashmap.get("longitude"));
|
---|
39 | radiusInKM_ = Double.parseDouble(hashmap.get("radius"));
|
---|
40 |
|
---|
41 | title_ = hashmap.get("title");
|
---|
42 |
|
---|
43 | text_ = hashmap.get("text");
|
---|
44 | tts_text_ = (hashmap.containsKey("tts")) ? hashmap.get("tts") : null;
|
---|
45 | title_tts_ = (hashmap.containsKey("tts_title")) ? hashmap.get("tts_title") : null;
|
---|
46 |
|
---|
47 | colour_fill_ = (hashmap.containsKey("colour_fill_")) ? hashmap.get("colour_fill") : "#0000FF";
|
---|
48 | colour_outline_ = (hashmap.containsKey("colour_outline")) ? hashmap.get("colour_outline") : "#0000FF";
|
---|
49 |
|
---|
50 | audioFilename_ = hashmap.get("audio");
|
---|
51 |
|
---|
52 |
|
---|
53 |
|
---|
54 | // Consolidate whitespace
|
---|
55 | title_ = title_.replaceAll("^\\s+", "");
|
---|
56 | title_ = title_.replaceAll("\\s+$", "");
|
---|
57 | title_ = title_.replaceAll("\\s+", " ");
|
---|
58 |
|
---|
59 | if (text_ != null) {
|
---|
60 | text_ = text_.replaceAll("^\\s+", "");
|
---|
61 | text_ = text_.replaceAll("\\s+$", "");
|
---|
62 | text_ = text_.replaceAll("\\s+", " ");
|
---|
63 | }
|
---|
64 |
|
---|
65 | id_ = title_.replaceAll("/\\s+/", "-");
|
---|
66 |
|
---|
67 | // ok, get rid of the <h2></h2> heading in the text (if it exists)
|
---|
68 | if(text_.lastIndexOf("</h2>") != -1)
|
---|
69 | text_ = text_.substring( text_.lastIndexOf("</h2>") );
|
---|
70 |
|
---|
71 | // get rid of html tags for the text
|
---|
72 | text_ = text_.replaceAll("\\<.*?\\>", "");
|
---|
73 | }
|
---|
74 |
|
---|
75 | public int getColourFill()
|
---|
76 | {
|
---|
77 | return Color.parseColor(colour_fill_);
|
---|
78 | }
|
---|
79 |
|
---|
80 | public int getColourOutline()
|
---|
81 | {
|
---|
82 | return Color.parseColor(colour_outline_);
|
---|
83 | }
|
---|
84 |
|
---|
85 |
|
---|
86 | public double getLatitude()
|
---|
87 | {
|
---|
88 | return latitude_;
|
---|
89 | }
|
---|
90 |
|
---|
91 | public double getLongitude()
|
---|
92 | {
|
---|
93 | return longitude_;
|
---|
94 | }
|
---|
95 |
|
---|
96 | public double getRadiusKM()
|
---|
97 | {
|
---|
98 | return radiusInKM_;
|
---|
99 | }
|
---|
100 |
|
---|
101 | public String getText()
|
---|
102 | {
|
---|
103 | return text_;
|
---|
104 | }
|
---|
105 |
|
---|
106 | public String getTTSText()
|
---|
107 | {
|
---|
108 | return (tts_text_ != null) ? tts_text_ : text_;
|
---|
109 | }
|
---|
110 | public String getTitle()
|
---|
111 | {
|
---|
112 | return title_;
|
---|
113 | }
|
---|
114 |
|
---|
115 | public String getTitleTTS()
|
---|
116 | {
|
---|
117 | return title_tts_;
|
---|
118 | }
|
---|
119 |
|
---|
120 | public String getID()
|
---|
121 | {
|
---|
122 | return id_;
|
---|
123 | }
|
---|
124 |
|
---|
125 | public List<String> getAudio()
|
---|
126 | {
|
---|
127 | return audioPaths_;
|
---|
128 | }
|
---|
129 |
|
---|
130 | public String getAudioFilename()
|
---|
131 | {
|
---|
132 | return audioFilename_;
|
---|
133 | }
|
---|
134 |
|
---|
135 | }
|
---|