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.widget.ListView; |
7 |
|
import android.widget.Toast; |
8 |
|
|
9 |
|
import com.dreamcatcher.bicycle.R; |
10 |
|
import com.dreamcatcher.bicycle.adapter.BicycleListAdapter; |
11 |
|
import com.dreamcatcher.bicycle.core.BicycleService; |
12 |
|
import com.dreamcatcher.bicycle.interfaces.IHttpEvent; |
13 |
|
import com.dreamcatcher.bicycle.interfaces.ISettingEvent; |
14 |
|
import com.dreamcatcher.bicycle.util.Constants; |
15 |
|
import com.dreamcatcher.bicycle.util.Utils; |
16 |
|
import com.dreamcatcher.bicycle.view.ActivityTitle; |
17 |
|
import com.dreamcatcher.bicycle.view.ActivityTitle.IActivityTitleRightImageClickEvent; |
18 |
|
import com.dreamcatcher.bicycle.vo.BicycleNumberInfo; |
19 |
|
|
|
|
| 70,3% |
Uncovered Elements: 19 (64) |
Complexity: 21 |
Complexity Density: 0,55 |
|
20 |
|
public class BicycleList extends Activity implements IHttpEvent, ISettingEvent{ |
21 |
|
private ActivityTitle mActivityTitle = null; |
22 |
|
private BicycleListAdapter mAdapter = null; |
23 |
|
private ListView mListView = null; |
24 |
|
private ProgressDialog mProgressDialog = null; |
25 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0,33 |
|
26 |
1
|
@Override... |
27 |
|
protected void onCreate(Bundle savedInstanceState) { |
28 |
|
|
29 |
1
|
super.onCreate(savedInstanceState); |
30 |
1
|
setContentView(R.layout.bicycle_list); |
31 |
1
|
init(); |
32 |
|
} |
33 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0,12 |
|
34 |
1
|
private void init(){... |
35 |
1
|
this.addEvent(); |
36 |
|
|
37 |
1
|
mActivityTitle = (ActivityTitle) findViewById(R.id.bicycle_title); |
38 |
1
|
mActivityTitle.setActivityTitle(getText(R.string.title_list)); |
39 |
|
|
40 |
1
|
IActivityTitleRightImageClickEvent rightImageClickEvent = new IActivityTitleRightImageClickEvent() { |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
41 |
2
|
public void onRightImageClicked() {... |
42 |
2
|
loadAllBicyclesInfoFromServer(); |
43 |
|
} |
44 |
|
}; |
45 |
|
|
46 |
1
|
mActivityTitle.setRightImage(R.drawable.ic_titlebar_refresh, rightImageClickEvent, false); |
47 |
|
|
48 |
1
|
mListView = (ListView) findViewById(R.id.bicycle_listview); |
49 |
1
|
mAdapter = new BicycleListAdapter(); |
50 |
1
|
mListView.setAdapter(mAdapter); |
51 |
|
|
52 |
|
} |
53 |
|
|
54 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
55 |
0
|
@Override... |
56 |
|
protected void onDestroy() { |
57 |
0
|
this.removeEvent(); |
58 |
0
|
super.onDestroy(); |
59 |
|
} |
60 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
61 |
0
|
@Override... |
62 |
|
public boolean onSearchRequested() { |
63 |
|
|
64 |
|
|
65 |
0
|
return super.onSearchRequested(); |
66 |
|
} |
67 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
68 |
1
|
private void addEvent(){... |
69 |
1
|
BicycleService.getInstance().getHttpEventListener().addEvent(this); |
70 |
1
|
BicycleService.getInstance().getSettingEventListener().addEvent(this); |
71 |
|
} |
72 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
73 |
0
|
private void removeEvent(){... |
74 |
0
|
BicycleService.getInstance().getHttpEventListener().removeEvent(this); |
75 |
0
|
BicycleService.getInstance().getSettingEventListener().removeEvent(this); |
76 |
|
} |
77 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
78 |
0
|
@Override... |
79 |
|
public void onBackPressed() { |
80 |
0
|
this.getParent().onBackPressed(); |
81 |
|
} |
82 |
|
|
|
|
| 75% |
Uncovered Elements: 3 (12) |
Complexity: 3 |
Complexity Density: 0,38 |
|
83 |
2
|
private void loadAllBicyclesInfoFromServer(){... |
84 |
2
|
if(Utils.getNetworkInfo() == Constants.NetworkInfo.DISCONNECT){ |
85 |
0
|
Toast.makeText(this, R.string.toast_msg_network_error, Toast.LENGTH_SHORT).show(); |
86 |
0
|
return; |
87 |
|
} |
88 |
2
|
if(mProgressDialog == null){ |
89 |
1
|
mProgressDialog = new ProgressDialog(this); |
90 |
1
|
mProgressDialog.setMessage(getText(R.string.list_progress_dialog_msg)); |
91 |
|
} |
92 |
2
|
mProgressDialog.show(); |
93 |
2
|
BicycleService.getInstance().getHttpService().getAllBicyclesInfo(); |
94 |
|
} |
95 |
|
|
|
|
| 60% |
Uncovered Elements: 4 (10) |
Complexity: 3 |
Complexity Density: 0,5 |
|
96 |
2
|
public void onAllBicyclesInfoReceived(int resultCode) {... |
97 |
2
|
if(mProgressDialog != null){ |
98 |
2
|
mProgressDialog.dismiss(); |
99 |
|
|
100 |
|
} |
101 |
2
|
if(resultCode == Constants.ResultCode.SUCCESS){ |
102 |
0
|
mAdapter.updateDataset(); |
103 |
0
|
Toast.makeText(this, R.string.toast_msg_bicycles_info_refresh_success, Toast.LENGTH_SHORT).show(); |
104 |
|
}else { |
105 |
2
|
Toast.makeText(this, R.string.toast_msg_server_unavailable, Toast.LENGTH_SHORT).show(); |
106 |
|
} |
107 |
|
} |
108 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
109 |
0
|
public void onSingleBicycleNumberInfoReceived(... |
110 |
|
BicycleNumberInfo bicycleNumberInfo, int resultCode) { |
111 |
|
} |
112 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
113 |
1
|
public void onNewVersionCheckCompleted(boolean needUpdate, int resultCode) {... |
114 |
|
} |
115 |
|
|
116 |
|
|
117 |
|
|
118 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
119 |
2
|
public void onCitySettingChanged(int resultCode) {... |
120 |
2
|
if(resultCode == Constants.ResultCode.SUCCESS){ |
121 |
2
|
mAdapter.updateDataset(); |
122 |
|
} |
123 |
|
} |
124 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
125 |
8
|
public void onFavoriteIdsChanged() {... |
126 |
|
|
127 |
|
|
128 |
|
} |
129 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
130 |
5
|
@Override... |
131 |
|
protected void onResume() { |
132 |
5
|
super.onResume(); |
133 |
|
} |
134 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
135 |
5
|
@Override... |
136 |
|
protected void onPause() { |
137 |
5
|
super.onPause(); |
138 |
|
} |
139 |
|
|
140 |
|
} |