Clover Coverage Report - Main Coverage Report
Coverage timestamp: ven dic 19 2014 16:47:52 EST
../../../../img/srcFileCovDistChart9.png 17% of files have more coverage
38   114   16   3,45
10   94   0,42   11
11     1,45  
1    
This report was generated with an evaluation server license. Purchase Clover or configure your license.
 
  ChangeCityActivity       Line # 22 38 16 86,4% 0.86440676
 
No Tests
 
1    package com.dreamcatcher.bicycle.activity;
2   
3    import android.app.Activity;
4    import android.app.ProgressDialog;
5    import android.os.Bundle;
6    import android.view.View;
7    import android.view.View.OnClickListener;
8    import android.widget.Button;
9    import android.widget.ListView;
10    import android.widget.Toast;
11   
12    import com.dreamcatcher.bicycle.R;
13    import com.dreamcatcher.bicycle.adapter.CityListAdapter;
14    import com.dreamcatcher.bicycle.adapter.CityListAdapter.ICityListEvent;
15    import com.dreamcatcher.bicycle.core.BicycleService;
16    import com.dreamcatcher.bicycle.interfaces.ISettingEvent;
17    import com.dreamcatcher.bicycle.interfaces.ISettingService;
18    import com.dreamcatcher.bicycle.util.Constants;
19    import com.dreamcatcher.bicycle.util.Utils;
20    import com.dreamcatcher.bicycle.view.ActivityTitle;
21   
 
22    public class ChangeCityActivity extends Activity implements ISettingEvent{
23    private int mSelectedCityIndex = -1;
24    private ISettingService mSettingService = null;
25    private ProgressDialog mProgressDialog = null;
26   
 
27  3 toggle @Override
28    protected void onCreate(Bundle savedInstanceState) {
29  3 super.onCreate(savedInstanceState);
30  3 setContentView(R.layout.change_city);
31  3 this.init();
32    }
33   
 
34  3 toggle private void init(){
35  3 mSettingService = BicycleService.getInstance().getSettingService();
36  3 this.addEvent();
37   
38  3 ActivityTitle activityTitle = (ActivityTitle) findViewById(R.id.bicycle_title);
39  3 activityTitle.setActivityTitle(R.string.title_change_city);
40   
41  3 ListView listView = (ListView) findViewById(R.id.change_city_list);
42   
43  3 ICityListEvent citySelectEvent = new ICityListEvent() {
 
44  2 toggle public void onCityItemClicked(int index) {
45  2 mSelectedCityIndex = index;
46    }
47    };
48   
49  3 CityListAdapter adapter = new CityListAdapter(citySelectEvent, getCurrentCityIndex());
50   
51  3 listView.setAdapter(adapter);
52   
53  3 Button reloadBtn = (Button) findViewById(R.id.change_city_reload_btn);
54  3 reloadBtn.setOnClickListener(new OnClickListener() {
 
55  2 toggle public void onClick(View v) {
56  2 onReloadtBtnClicked();
57    }
58    });
59    }
60   
 
61  3 toggle @Override
62    protected void onDestroy() {
63  3 this.removeEvent();
64  3 super.onDestroy();
65    }
66   
 
67  3 toggle private void addEvent(){
68  3 BicycleService.getInstance().getSettingEventListener().addEvent(this);
69    }
70   
 
71  3 toggle private void removeEvent(){
72  3 BicycleService.getInstance().getSettingEventListener().removeEvent(this);
73    }
74   
 
75  3 toggle private int getCurrentCityIndex(){
76  3 String currentCity = Utils.getStringDataFromLocal(Constants.LocalStoreTag.CITY_NAME);
77  13 for(int i = 0, n = Constants.CitySetting.CITY_TAG.length; i < n; i++){
78  13 if(currentCity.equalsIgnoreCase(Constants.CitySetting.CITY_TAG[i])){
79  3 return i;
80    }
81    }
82  0 return -1;
83    }
84   
 
85  2 toggle private void onReloadtBtnClicked(){
86  2 String currentCity = Utils.getStringDataFromLocal(Constants.LocalStoreTag.CITY_NAME);
87  2 String selectedCity = Constants.CitySetting.CITY_TAG[mSelectedCityIndex];
88  2 if(currentCity.equalsIgnoreCase(selectedCity)){
89  0 Toast.makeText(this, R.string.change_city_same_city_toast_msg, Toast.LENGTH_SHORT).show();
90    }else {
91  2 mProgressDialog = new ProgressDialog(this);
92  2 mProgressDialog.setMessage(getText(R.string.change_city_progress_dialog_msg));
93  2 mProgressDialog.show();
94  2 mSettingService.changeCitySetting(selectedCity);
95    }
96    }
97   
 
98  2 toggle public void onCitySettingChanged(int resultCode) {
99  2 if(mProgressDialog != null){
100  2 mProgressDialog.dismiss();
101    }
102  2 if(resultCode == Constants.ResultCode.CHANGE_CITY_FAILED){
103  0 Toast.makeText(ChangeCityActivity.this, getText(R.string.change_city_reload_failed_msg), Toast.LENGTH_SHORT).show();
104    }else {
105  2 Toast.makeText(ChangeCityActivity.this, getText(R.string.change_city_reload_success_msg), Toast.LENGTH_SHORT).show();
106  2 super.onBackPressed();
107    }
108    }
109   
 
110  0 toggle public void onFavoriteIdsChanged() {
111   
112    }
113   
114    }