Clover Coverage Report - Main Coverage Report
Coverage timestamp: ven dic 19 2014 16:47:52 EST
../../../../img/srcFileCovDistChart6.png 51% of files have more coverage
77   213   36   4,05
32   175   0,47   19
19     1,89  
1    
This report was generated with an evaluation server license. Purchase Clover or configure your license.
 
  Main       Line # 27 77 36 60,9% 0.609375
 
No Tests
 
1    package com.dreamcatcher.bicycle.activity;
2   
3    import android.app.AlertDialog;
4    import android.app.TabActivity;
5    import android.content.DialogInterface;
6    import android.content.Intent;
7    import android.os.Bundle;
8    import android.view.LayoutInflater;
9    import android.view.View;
10    import android.widget.ImageView;
11    import android.widget.TabHost;
12    import android.widget.TabHost.TabSpec;
13    import android.widget.TextView;
14    import android.widget.Toast;
15   
16    import com.dreamcatcher.bicycle.R;
17    import com.dreamcatcher.bicycle.core.BicycleService;
18    import com.dreamcatcher.bicycle.interfaces.IAdEvent;
19    import com.dreamcatcher.bicycle.interfaces.ISettingEvent;
20    import com.dreamcatcher.bicycle.util.Constants;
21    import com.dreamcatcher.bicycle.util.GlobalSetting;
22    import com.dreamcatcher.bicycle.util.Utils;
23    import com.dreamcatcher.bicycle.vo.CitySetting;
24    import com.kuguo.ad.PushAdsManager;
25    import com.uucun.adsdk.UUAppConnect;
26   
 
27    public class Main extends TabActivity implements ISettingEvent, IAdEvent{
28    private TabHost mTabHost;
29    private LayoutInflater mLayoutInflater;
30    private long mCurrentTime = 0;
31    private static final int SPLASH_SCREEN_CODE = 1;
32    private static final int SELECT_CITY_CODE = 1;
33   
34    /** Called when the activity is first created. */
 
35  1 toggle @Override
36    public void onCreate(Bundle savedInstanceState) {
37  1 super.onCreate(savedInstanceState);
38  1 startActivityForResult(new Intent(this, SplashScreen.class), SPLASH_SCREEN_CODE);
39    }
40   
 
41  2 toggle @Override
42    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
43  2 if(requestCode == SPLASH_SCREEN_CODE){
44  2 if(resultCode == RESULT_OK){
45  2 boolean loadCompleted = data.getBooleanExtra("load_completed", false);
46  2 if(loadCompleted){
47  1 setContentView(R.layout.main);
48  1 this.init();
49    }else {
50  1 startActivityForResult(new Intent(this, SelectCityActivity.class), SELECT_CITY_CODE);
51    }
52    }
53  0 }else if(requestCode == SELECT_CITY_CODE) {
54  0 if(requestCode == RESULT_OK){
55  0 setContentView(R.layout.main);
56  0 this.init();
57    }
58    }
59    }
60   
 
61  0 toggle @Override
62    protected void onDestroy() {
63  0 this.removeEvent();
64  0 UUAppConnect.getInstance(this).exitSdk();
65  0 super.onDestroy();
66    }
67   
 
68  0 toggle @Override
69    public void onBackPressed() {
70  0 if(System.currentTimeMillis() - mCurrentTime < 2000){
71  0 Utils.exitApplication();
72    }else {
73  0 try {
74  0 Toast.makeText(this, getText(R.string.exit_app_inform_msg), Toast.LENGTH_SHORT).show();
75  0 mCurrentTime = System.currentTimeMillis();
76    } catch (Exception e) {
77  0 e.printStackTrace();
78    }
79    }
80    }
81   
 
82  1 toggle private void init(){
83  1 this.addEvent();
84   
85  1 mTabHost = getTabHost();
86  1 mLayoutInflater = LayoutInflater.from(this);
87   
88  1 CitySetting citySetting = GlobalSetting.getInstance().getCitySetting();
89  1 if(citySetting == null){
90  0 return;
91    }
92  1 int[] tabs = citySetting.getTabs();
93  1 int childrenCount = Constants.TabSetting.IMAGE_ARRAY.length;
94   
95  5 for(int i = 0; i < childrenCount; i++){
96  4 TabSpec tabSpec = mTabHost.newTabSpec(getString(Constants.TabSetting.TEXT_ARRAY[i])).setIndicator(getTabItemView(i)).setContent(getTabItemIntent(i));
97   
98  4 mTabHost.addTab(tabSpec);
99  4 mTabHost.getTabWidget().getChildAt(i).setBackgroundResource(R.drawable.selector_tab_background);
100  4 if(!inArray(i, tabs)){
101  0 mTabHost.getTabWidget().getChildAt(i).setVisibility(View.GONE);
102    }
103    }
104   
105  1 UUAppConnect.getInstance(this).initSdk();
106   
107    //get ad config from server
108  1 BicycleService.getInstance().getAdService().getPoints();
109   
110    //get push ad
111  1 PushAdsManager paManager = PushAdsManager.getInstance();
112  1 paManager.receivePushMessage(this, true);
113    }
114   
 
115  1 toggle private void addEvent(){
116  1 BicycleService.getInstance().getSettingEventListener().addEvent(this);
117  1 BicycleService.getInstance().getAdEventListener().addEvent(this);
118    }
119   
 
120  0 toggle private void removeEvent(){
121  0 BicycleService.getInstance().getSettingEventListener().removeEvent(this);
122  0 BicycleService.getInstance().getAdEventListener().removeEvent(this);
123    }
124   
 
125  6 toggle private boolean inArray(int data, int[] array){
126  6 boolean result = false;
127  12 for(int i = 0; i < array.length; i++){
128  12 if(data == array[i]){
129  6 result = true;
130  6 break;
131    }
132    }
133  6 return result;
134    }
135   
 
136  0 toggle @Override
137    protected void onNewIntent(Intent intent) {
138  0 processIntent(intent);
139  0 super.onNewIntent(intent);
140    }
141   
142   
 
143  0 toggle private void processIntent(Intent intent){
144  0 boolean isFromReminderNotificaiton = intent.getBooleanExtra(Constants.IntentExtraTag.MAIN_REMINDER_FROM_NOTIFICATION, false);
145  0 if(isFromReminderNotificaiton){
146  0 new AlertDialog.Builder(this)
147    .setTitle(R.string.return_bicycle_reminder_cancel_dialog_title)
148    .setMessage(R.string.return_bicycle_reminder_cancel_dialog_msg)
149    .setPositiveButton(R.string.return_bicycle_reminder_cancel_dialog_btn, new DialogInterface.OnClickListener() {
 
150  0 toggle public void onClick(DialogInterface dialog, int which) {
151  0 closeReturnBicycleReminder();
152    }
153    }).show();
154    }
155    }
156   
 
157  0 toggle private void closeReturnBicycleReminder(){
158  0 Utils.stopReminder();
159    }
160   
 
161  2 toggle private void reloadUI(){
162  2 CitySetting citySetting = GlobalSetting.getInstance().getCitySetting();
163  2 if(citySetting == null){
164  0 return;
165    }
166  2 int[] tabs = citySetting.getTabs();
167  2 int tabCount = mTabHost.getChildCount();
168  4 for(int i = 0; i < tabCount; i++){
169  2 if(inArray(i, tabs)){
170  2 mTabHost.getTabWidget().getChildAt(i).setVisibility(View.VISIBLE);
171    }else {
172  0 mTabHost.getTabWidget().getChildAt(i).setVisibility(View.VISIBLE);
173    }
174    }
175    }
176   
 
177  4 toggle private View getTabItemView(int index){
178  4 View view = mLayoutInflater.inflate(R.layout.tab_item_view, null);
179  4 ImageView tabImage = (ImageView) view.findViewById(R.id.tab_item_image);
180  4 if(tabImage != null){
181  4 tabImage.setImageResource(Constants.TabSetting.IMAGE_ARRAY[index]);
182    }
183   
184  4 TextView textView = (TextView) view.findViewById(R.id.tab_item_text);
185  4 textView.setText(Constants.TabSetting.TEXT_ARRAY[index]);
186   
187  4 return view;
188    }
189   
 
190  4 toggle private Intent getTabItemIntent(int index){
191  4 Intent intent = new Intent(this, Constants.TabSetting.CONTENT_ARRAY[index]);
192  4 return intent;
193    }
194   
 
195  2 toggle public void onCitySettingChanged(int resultCode) {
196  2 reloadUI();
197    }
198   
 
199  8 toggle public void onFavoriteIdsChanged() {
200   
201    }
202   
 
203  1 toggle @Override
204    public void onPointsUpdated(String currencyName, int totalPoint) {
205  1 GlobalSetting.getInstance().getAdsetting().setPointTotal(totalPoint);
206    }
207   
 
208  0 toggle @Override
209    public void onPointsUpdateFailed(String error) {
210   
211    }
212   
213    }