Clover Coverage Report - SaveApp Coverage Report
Coverage timestamp: mar dic 23 2014 15:53:11 EST
../../../../img/srcFileCovDistChart6.png 54% of files have more coverage
78   215   20   6,5
10   154   0,26   6
12     1,67  
2    
This report was generated with an evaluation server license. Purchase Clover or configure your license.
 
  MapAccountActivity       Line # 33 62 13 64,9% 0.64935064
  MapAccountActivity.MapOverlay       Line # 162 16 7 43,5% 0.4347826
 
No Tests
 
1    package com.loopback.androidapps.saveapp;
2   
3    /**
4    * @author Hugo A. Matilla G�mez
5    *Activity que muestra el mapa en pantalla
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   
 
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    *-------------------------------------ON CREATE & ON ROTATION--------------------------------------------------
47    *------------------------------------------------------------------------------------------------ */
 
48  0 toggle 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   
 
61  1 toggle 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   
 
77  0 toggle 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    *-------------------------------------- LOAD ACTIVITY --------------------------------------------------
95    *------------------------------------------------------------------------------------------------ */
 
96  1 toggle public void loadActivity() {
97  1 saveApp = ((SaveApp) getApplicationContext());
98    // Map
99    // Init------------------------------------------------------------------
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    // Get Intennt
106    // Values------------------------------------------------------------------
107   
108    // Reading Outlays from the DB
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    // Get
135    // Preferences------------------------------------------------------------------
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    // Map
142    // Edit------------------------------------------------------------------
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    // Re-Draw
152    // ------------------------------------------------------------------
153  1 mapView.invalidate();
154  1 Log.i("MAP", "Draw");
155    }
156   
157    /*--******************************************************************************************-------------
158    *-------------------------------------- MapOverlay CLASS --------------------------------------------------
159    *--******************************************************************************************-------------*/
160   
161    @SuppressWarnings("rawtypes")
 
162    public class MapOverlay extends ItemizedOverlay {
163   
164    private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
165    private Context mContext;
166   
 
167  1 toggle public MapOverlay(Drawable defaultMarker, Context context) {
168  1 super(boundCenterBottom(defaultMarker));
169  1 mContext = context;
170    }
171   
 
172  2 toggle public void addOverlay(OverlayItem overlay) {
173  2 mOverlays.add(overlay);
174  2 populate();
175    }
176   
 
177  0 toggle public void clearOverlay() {
178  0 mOverlays.clear();
179    }
180   
 
181  3 toggle protected OverlayItem createItem(int i) {
182  3 return mOverlays.get(i);
183    }
184   
 
185  18 toggle public int size() {
186  18 return mOverlays.size();
187    }
188   
 
189  0 toggle 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   
 
198  0 toggle 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   
 
210  4 toggle protected boolean isRouteDisplayed() {
211    // TODO Auto-generated method stub
212  4 return false;
213    }
214   
215    }