Clover Coverage Report - Main Coverage Report
Coverage timestamp: ven dic 19 2014 16:47:52 EST
../../../../img/srcFileCovDistChart8.png 33% of files have more coverage
69   171   28   3,83
8   146   0,41   18
18     1,56  
1    
This report was generated with an evaluation server license. Purchase Clover or configure your license.
 
  BicycleMore       Line # 25 69 28 80% 0.8
 
No Tests
 
1    package com.dreamcatcher.bicycle.activity;
2   
3    import android.app.Activity;
4    import android.content.Intent;
5    import android.content.pm.PackageInfo;
6    import android.net.Uri;
7    import android.os.Bundle;
8    import android.view.LayoutInflater;
9    import android.view.View;
10    import android.view.View.OnClickListener;
11    import android.widget.ImageView;
12    import android.widget.LinearLayout;
13    import android.widget.LinearLayout.LayoutParams;
14    import android.widget.TextView;
15    import android.widget.Toast;
16   
17    import com.dreamcatcher.bicycle.R;
18    import com.dreamcatcher.bicycle.core.BicycleService;
19    import com.dreamcatcher.bicycle.interfaces.IHttpEvent;
20    import com.dreamcatcher.bicycle.util.Constants;
21    import com.dreamcatcher.bicycle.util.Utils;
22    import com.dreamcatcher.bicycle.view.ActivityTitle;
23    import com.dreamcatcher.bicycle.vo.BicycleNumberInfo;
24   
 
25    public class BicycleMore extends Activity implements IHttpEvent{
26    private LayoutInflater mInflater = null;
27    private LinearLayout mListContainer = null;
28   
 
29  1 toggle @Override
30    protected void onCreate(Bundle savedInstanceState) {
31  1 super.onCreate(savedInstanceState);
32  1 setContentView(R.layout.bicycle_more);
33  1 init();
34    }
35   
 
36  0 toggle @Override
37    public void onBackPressed() {
38  0 this.getParent().onBackPressed();
39    }
40   
 
41  1 toggle private void init(){
42  1 mInflater = getLayoutInflater();
43   
44  1 ActivityTitle activityTitle = (ActivityTitle) findViewById(R.id.bicycle_title);
45  1 activityTitle.setActivityTitle(getText(R.string.title_more));
46   
47  1 mListContainer = (LinearLayout) findViewById(R.id.bicycle_more_list_container);
48  1 this.addSettingItem();
49  1 this.addEvent();
50    }
51   
 
52  1 toggle private void addSettingItem(){
53  6 for(int i = 0, n = Constants.MoreListviewItem.SETTING_ITEM_IMAGE.length; i < n; i++){
54  5 View view = mInflater.inflate(R.layout.setting_listview_item, mListContainer, false);
55   
56  5 ImageView imageView = (ImageView) view.findViewById(R.id.setting_listview_item_image);
57  5 TextView textView = (TextView) view.findViewById(R.id.setting_listview_item_text);
58  5 ImageView indicator = (ImageView) view.findViewById(R.id.setting_listview_item_next_indicator);
59   
60  5 imageView.setImageResource(Constants.MoreListviewItem.SETTING_ITEM_IMAGE[i]);
61  5 textView.setText(Constants.MoreListviewItem.SETTING_ITEM_TEXT[i]);
62  5 indicator.setImageResource(Constants.MoreListviewItem.SETTING_ITEM_NEXT_INDICATOR);
63   
64  5 view.setOnClickListener(getOnFunctionSettingItemClickListener(i));
65   
66  5 view.setBackgroundResource(Constants.MoreListviewItem.BACKGROUND_IMAGE[i]);
67  5 LayoutParams params = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
68  5 params.setMargins(0, Utils.dip2px(Constants.MoreListviewItem.MARGIN_TOP_IN_DIP[i]), 0, 0);
69  5 view.setLayoutParams(params);
70   
71  5 mListContainer.addView(view);
72    }
73    }
 
74  5 toggle private OnClickListener getOnFunctionSettingItemClickListener(int index){
75  5 OnClickListener listener = null;
76  5 switch (index) {
77  1 case 0:
78  1 case 4:
79  2 final Intent intent = new Intent(this, Constants.MoreListviewItem.NEXT_ACTIVITY_ARRAY[index]);
80  2 listener = new OnClickListener() {
 
81  2 toggle public void onClick(View v) {
82  2 startActivity(intent);
83    }
84    };
85  2 break;
86  1 case 1:
87  1 listener = new OnClickListener() {
 
88  1 toggle public void onClick(View v) {
89  1 shareToFriend();
90    }
91    };
92  1 break;
93  1 case 2:
94  1 listener = new OnClickListener() {
 
95  1 toggle public void onClick(View v) {
96  1 checkVersion();
97    }
98    };
99  1 break;
100  1 case 3:
101  1 listener = new OnClickListener() {
 
102  1 toggle public void onClick(View v) {
103  1 goToMarket();
104    }
105    };
106  1 break;
107  0 default:
108  0 break;
109    }
110  5 return listener;
111    }
112   
 
113  1 toggle private void shareToFriend(){
114  1 Intent intent = new Intent(Intent.ACTION_SEND);
115  1 intent.putExtra(Intent.EXTRA_TEXT, getText(R.string.share_message));
116  1 intent.putExtra(Intent.EXTRA_SUBJECT, getText(R.string.share_title));
117  1 intent.setType("text/plain");
118  1 startActivity(Intent.createChooser(intent, getText(R.string.share_chooser_title)));
119    }
120   
 
121  1 toggle private void goToMarket(){
122  1 try {
123  1 startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(Constants.HttpUrl.APP_URI)));
124    } catch (Exception e) {
125  0 Toast.makeText(this, R.string.toast_msg_version_no_market, Toast.LENGTH_SHORT).show();
126    }
127    }
128   
 
129  1 toggle private void checkVersion(){
130  1 Toast.makeText(this, R.string.toast_msg_version_is_checking, Toast.LENGTH_SHORT).show();
131  1 PackageInfo packageInfo = Utils.getPackageInfo();
132  1 BicycleService.getInstance().getHttpService().checkNewVersion(packageInfo.versionName, packageInfo.versionCode);
133    }
134   
 
135  0 toggle @Override
136    protected void onDestroy() {
137  0 this.removeEvent();
138  0 super.onDestroy();
139    }
140   
 
141  1 toggle private void addEvent(){
142  1 BicycleService.getInstance().getHttpEventListener().addEvent(this);
143    }
144   
 
145  0 toggle private void removeEvent(){
146  0 BicycleService.getInstance().getHttpEventListener().removeEvent(this);
147    }
148   
 
149  1 toggle public void onAllBicyclesInfoReceived(int resultCode) {
150   
151    }
152   
 
153  0 toggle public void onSingleBicycleNumberInfoReceived(
154    BicycleNumberInfo bicycleNumberInfo, int resultCode) {
155   
156    }
157   
 
158  1 toggle public void onNewVersionCheckCompleted(boolean needUpdate, int resultCode) {
159  1 if(resultCode == Constants.ResultCode.NETWORK_DISCONNECT){
160  0 Toast.makeText(this, R.string.toast_msg_network_error, Toast.LENGTH_SHORT).show();
161  1 }else if(resultCode == Constants.ResultCode.SUCCESS){
162  0 if(needUpdate){
163  0 goToMarket();
164    }else {
165  0 Toast.makeText(this, R.string.toast_msg_version_is_up_to_date, Toast.LENGTH_SHORT).show();
166    }
167    }else {
168  1 Toast.makeText(this, R.string.toast_msg_server_unavailable, Toast.LENGTH_SHORT).show();
169    }
170    }
171    }