1 |
|
package com.loopback.androidapps.saveapp; |
2 |
|
|
3 |
|
|
4 |
|
@author |
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
import java.util.ArrayList; |
9 |
|
import java.util.List; |
10 |
|
|
11 |
|
import android.app.AlertDialog; |
12 |
|
import android.content.Context; |
13 |
|
import android.content.DialogInterface; |
14 |
|
import android.content.SharedPreferences; |
15 |
|
import android.content.res.Configuration; |
16 |
|
import android.database.Cursor; |
17 |
|
import android.graphics.PixelFormat; |
18 |
|
import android.graphics.drawable.Drawable; |
19 |
|
import android.os.Bundle; |
20 |
|
import android.preference.PreferenceManager; |
21 |
|
import android.util.Log; |
22 |
|
import android.view.Display; |
23 |
|
import android.view.WindowManager; |
24 |
|
|
25 |
|
import com.google.android.maps.GeoPoint; |
26 |
|
import com.google.android.maps.ItemizedOverlay; |
27 |
|
import com.google.android.maps.MapActivity; |
28 |
|
import com.google.android.maps.MapController; |
29 |
|
import com.google.android.maps.MapView; |
30 |
|
import com.google.android.maps.Overlay; |
31 |
|
import com.google.android.maps.OverlayItem; |
32 |
|
|
|
|
| 64,9% |
Uncovered Elements: 27 (77) |
Complexity: 13 |
Complexity Density: 0,21 |
|
33 |
|
public class MapAccountActivity extends MapActivity { |
34 |
|
|
35 |
|
private MapView mapView; |
36 |
|
private MapController mapController; |
37 |
|
private MapOverlay itemizedoverlay; |
38 |
|
private GeoPoint localization; |
39 |
|
private DBManager dbManager; |
40 |
|
private List<Overlay> mapOverlays; |
41 |
|
private ArrayList<Outlay> outlays = new ArrayList<Outlay>(); |
42 |
|
|
43 |
|
public SaveApp saveApp; |
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0,43 |
|
48 |
0
|
public void onConfigurationChanged(Configuration newConfig) {... |
49 |
0
|
super.onConfigurationChanged(newConfig); |
50 |
0
|
Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)) |
51 |
|
.getDefaultDisplay(); |
52 |
0
|
int orientation = display.getOrientation(); |
53 |
0
|
if (orientation == 1 || orientation == 3) |
54 |
0
|
setContentView(R.layout.mapaccount); |
55 |
|
else |
56 |
0
|
setContentView(R.layout.mapaccount); |
57 |
|
|
58 |
0
|
loadActivity(); |
59 |
|
} |
60 |
|
|
|
|
| 83,3% |
Uncovered Elements: 2 (12) |
Complexity: 3 |
Complexity Density: 0,3 |
|
61 |
1
|
public void onCreate(Bundle savedInstanceState) {... |
62 |
1
|
Log.i("MAP", "Create..."); |
63 |
1
|
super.onCreate(savedInstanceState); |
64 |
1
|
getWindow().setFormat(PixelFormat.RGBA_8888); |
65 |
1
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DITHER); |
66 |
1
|
Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)) |
67 |
|
.getDefaultDisplay(); |
68 |
1
|
int orientation = display.getOrientation(); |
69 |
1
|
if (orientation == 1 || orientation == 3) |
70 |
0
|
setContentView(R.layout.mapaccount); |
71 |
|
else |
72 |
1
|
setContentView(R.layout.mapaccount); |
73 |
|
|
74 |
1
|
loadActivity(); |
75 |
|
} |
76 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 3 |
Complexity Density: 0,3 |
|
77 |
0
|
public void onResume(Bundle savedInstanceState) {... |
78 |
0
|
Log.i("MAP", "Create..."); |
79 |
0
|
super.onCreate(savedInstanceState); |
80 |
0
|
getWindow().setFormat(PixelFormat.RGBA_8888); |
81 |
0
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DITHER); |
82 |
0
|
Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)) |
83 |
|
.getDefaultDisplay(); |
84 |
0
|
int orientation = display.getOrientation(); |
85 |
0
|
if (orientation == 1 || orientation == 3) |
86 |
0
|
setContentView(R.layout.mapaccount); |
87 |
|
else |
88 |
0
|
setContentView(R.layout.mapaccount); |
89 |
|
|
90 |
0
|
loadActivity(); |
91 |
|
} |
92 |
|
|
93 |
|
|
94 |
|
|
95 |
|
|
|
|
| 94,7% |
Uncovered Elements: 2 (38) |
Complexity: 3 |
Complexity Density: 0,09 |
|
96 |
1
|
public void loadActivity() {... |
97 |
1
|
saveApp = ((SaveApp) getApplicationContext()); |
98 |
|
|
99 |
|
|
100 |
1
|
Log.i("MAP", "Drawing Map..."); |
101 |
1
|
mapView = (MapView) findViewById(R.id.mapView); |
102 |
1
|
mapView.setBuiltInZoomControls(true); |
103 |
1
|
dbManager = saveApp.getDbManager(); |
104 |
|
|
105 |
|
|
106 |
|
|
107 |
|
|
108 |
|
|
109 |
1
|
Log.i("OLA", "Reading..."); |
110 |
1
|
Cursor cursor = dbManager.select(-1, DBManager.OUTLAY_TABLE_ID); |
111 |
1
|
DBReader dbReader = new DBReader(); |
112 |
1
|
dbReader.readOutlay(cursor); |
113 |
1
|
outlays = dbReader.outlayList; |
114 |
|
|
115 |
1
|
mapOverlays = mapView.getOverlays(); |
116 |
1
|
Drawable drawable = this.getResources().getDrawable( |
117 |
|
R.drawable.changeaccount); |
118 |
1
|
itemizedoverlay = new MapOverlay(drawable, this); |
119 |
1
|
Outlay outlay = new Outlay(); |
120 |
1
|
AddressX address = new AddressX(); |
121 |
3
|
for (int i = 0; i < outlays.size(); i++) { |
122 |
2
|
outlay = outlays.get(i); |
123 |
2
|
address.inflate(outlay.getAddressId()); |
124 |
2
|
localization = new GeoPoint((int) (address.getLatitude() * 1E6), |
125 |
|
(int) (address.getLongitude() * 1E6)); |
126 |
2
|
OverlayItem overlayitem = new OverlayItem(localization, |
127 |
|
i +". "+ outlay.getItemDesc() + ": " + String.valueOf(outlay.getCharge()) + saveApp.getCurrencySymbol(), |
128 |
|
getString(R.string.strDateAndTimeList) + ": " + outlay.getDate() + "\n" |
129 |
|
+ getString(R.string.strWhere) + ": " + outlay.getPlaceDesc()); |
130 |
2
|
itemizedoverlay.addOverlay(overlayitem); |
131 |
2
|
mapOverlays.add(itemizedoverlay); |
132 |
|
} |
133 |
|
|
134 |
|
|
135 |
|
|
136 |
1
|
Log.i("MAP", "Preferences..."); |
137 |
1
|
SharedPreferences sp = PreferenceManager |
138 |
|
.getDefaultSharedPreferences(this); |
139 |
1
|
Integer mapStyle = Integer.valueOf(sp.getString("mapStyle", "-1")); |
140 |
|
|
141 |
|
|
142 |
|
|
143 |
1
|
Log.i("MAP", "Editionn..."); |
144 |
1
|
mapView.setSatellite(false); |
145 |
1
|
if (mapStyle == 2) |
146 |
0
|
mapView.setSatellite(true); |
147 |
1
|
mapController = mapView.getController(); |
148 |
1
|
mapController.setZoom(12); |
149 |
1
|
mapController.animateTo(localization); |
150 |
|
|
151 |
|
|
152 |
|
|
153 |
1
|
mapView.invalidate(); |
154 |
1
|
Log.i("MAP", "Draw"); |
155 |
|
} |
156 |
|
|
157 |
|
|
158 |
|
|
159 |
|
|
160 |
|
|
161 |
|
@SuppressWarnings("rawtypes") |
|
|
| 43,5% |
Uncovered Elements: 13 (23) |
Complexity: 7 |
Complexity Density: 0,44 |
|
162 |
|
public class MapOverlay extends ItemizedOverlay { |
163 |
|
|
164 |
|
private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>(); |
165 |
|
private Context mContext; |
166 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
167 |
1
|
public MapOverlay(Drawable defaultMarker, Context context) {... |
168 |
1
|
super(boundCenterBottom(defaultMarker)); |
169 |
1
|
mContext = context; |
170 |
|
} |
171 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
172 |
2
|
public void addOverlay(OverlayItem overlay) {... |
173 |
2
|
mOverlays.add(overlay); |
174 |
2
|
populate(); |
175 |
|
} |
176 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
177 |
0
|
public void clearOverlay() {... |
178 |
0
|
mOverlays.clear(); |
179 |
|
} |
180 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
181 |
3
|
protected OverlayItem createItem(int i) {... |
182 |
3
|
return mOverlays.get(i); |
183 |
|
} |
184 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
185 |
18
|
public int size() {... |
186 |
18
|
return mOverlays.size(); |
187 |
|
} |
188 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 1 |
Complexity Density: 0,12 |
|
189 |
0
|
protected boolean onTap(int index) {... |
190 |
0
|
Log.i("MAP", "Tap..."); |
191 |
0
|
OverlayItem item = mOverlays.get(index); |
192 |
0
|
AlertDialog.Builder dialog = new AlertDialog.Builder(mContext); |
193 |
0
|
dialog.setTitle(item.getTitle()); |
194 |
0
|
dialog.setMessage(item.getSnippet()); |
195 |
0
|
dialog.setPositiveButton("OK", |
196 |
|
new DialogInterface.OnClickListener() { |
197 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
198 |
0
|
public void onClick(DialogInterface dialog, int which) {... |
199 |
|
|
200 |
0
|
return; |
201 |
|
|
202 |
|
} |
203 |
|
}); |
204 |
0
|
dialog.show(); |
205 |
0
|
return true; |
206 |
|
} |
207 |
|
|
208 |
|
} |
209 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
210 |
4
|
protected boolean isRouteDisplayed() {... |
211 |
|
|
212 |
4
|
return false; |
213 |
|
} |
214 |
|
|
215 |
|
} |