Clover Coverage Report - RaspberryBusMalaysiaActivity Coverage Report
Coverage timestamp: mar dic 23 2014 15:39:35 EST
../../../img/srcFileCovDistChart10.png 0% of files have more coverage
29   108   10   3,62
4   75   0,34   8
8     1,25  
1    
This report was generated with an evaluation server license. Purchase Clover or configure your license.
 
  RbmItemizedOverlay       Line # 37 29 10 100% 1.0
 
No Tests
 
1    /*
2    Copyright (C) 2012 Sweetie Piggy Apps <sweetiepiggyapps@gmail.com>
3   
4    This file is part of Raspberry Bus Malaysia.
5   
6    Raspberry Bus Malaysia is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 3 of the License, or
9    (at your option) any later version.
10   
11    Raspberry Bus Malaysia is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14    GNU General Public License for more details.
15   
16    You should have received a copy of the GNU General Public License
17    along with Raspberry Bus Malaysia; if not, see <http://www.gnu.org/licenses/>.
18    */
19   
20    package com.sweetiepiggy.raspberrybusmalaysia;
21   
22    import java.util.ArrayList;
23   
24    import android.app.Activity;
25    import android.app.AlertDialog;
26    import android.content.Context;
27    import android.content.DialogInterface;
28    import android.content.DialogInterface.OnClickListener;
29    import android.content.Intent;
30    import android.graphics.drawable.Drawable;
31    import android.os.Bundle;
32   
33    import com.google.android.maps.ItemizedOverlay;
34    import com.google.android.maps.MapActivity;
35    import com.google.android.maps.OverlayItem;
36   
 
37    public class RbmItemizedOverlay extends ItemizedOverlay<OverlayItem>
38    {
39    private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
40    private Context mContext;
41    private boolean mSetResult;
42   
 
43  9 toggle public RbmItemizedOverlay(Drawable defaultMarker, Context context, boolean set_result) {
44  9 super(boundCenterBottom(defaultMarker));
45  9 mContext = context;
46  9 mSetResult = set_result;
47    }
48   
 
49  495 toggle public void addOverlay(OverlayItem overlay) {
50  495 mOverlays.add(overlay);
51  495 populate();
52    }
53   
 
54  22043 toggle @Override
55    protected OverlayItem createItem(int i) {
56  22043 return mOverlays.get(i);
57    }
58   
 
59  583 toggle @Override
60    public int size() {
61  583 return mOverlays.size();
62    }
63   
 
64  15 toggle @Override
65    protected boolean onTap(int index) {
66  15 OverlayItem item = mOverlays.get(index);
67  15 String station = item.getTitle();
68  15 String city = item.getSnippet();
69   
70  15 prompt_confirm(station, city, mSetResult);
71  15 return true;
72    }
73   
 
74  15 toggle private void prompt_confirm(final String station, final String city, final boolean set_result)
75    {
76  15 AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
77  15 if (station.equals(city)) {
78  8 builder.setTitle(station);
79    } else {
80  7 builder.setTitle(station + ", " + city);
81    }
82  15 builder.setPositiveButton(android.R.string.ok, new OnClickListener() {
 
83  10 toggle @Override
84    public void onClick(DialogInterface dialog, int which) {
85  10 if (set_result) {
86  8 Bundle b = new Bundle();
87  8 b.putString("station", station);
88  8 b.putString("city", city);
89   
90  8 Intent i = new Intent();
91  8 i.putExtras(b);
92   
93  8 MapActivity ma = (MapActivity) mContext;
94  8 ma.setResult(Activity.RESULT_OK, i);
95  8 ma.finish();
96    }
97    }
98    });
99  15 builder.setNegativeButton(android.R.string.cancel, new OnClickListener() {
 
100  5 toggle @Override
101    public void onClick(DialogInterface dialog, int which) {
102    }
103    });
104  15 AlertDialog alert = builder.create();
105  15 alert.show();
106    }
107    }
108