1 |
|
package com.dreamcatcher.bicycle.activity; |
2 |
|
|
3 |
|
import android.app.Activity; |
4 |
|
import android.content.Intent; |
5 |
|
import android.os.Bundle; |
6 |
|
|
7 |
|
import com.dreamcatcher.bicycle.R; |
8 |
|
import com.dreamcatcher.bicycle.core.BicycleService; |
9 |
|
import com.dreamcatcher.bicycle.interfaces.IAssetsEvent; |
10 |
|
import com.dreamcatcher.bicycle.interfaces.IAssetsService; |
11 |
|
import com.dreamcatcher.bicycle.util.Constants; |
12 |
|
import com.dreamcatcher.bicycle.util.GlobalSetting; |
13 |
|
import com.dreamcatcher.bicycle.util.Utils; |
14 |
|
|
|
|
| 48,1% |
Uncovered Elements: 28 (54) |
Complexity: 15 |
Complexity Density: 0,42 |
|
15 |
|
public class SplashScreen extends Activity implements IAssetsEvent{ |
16 |
|
private IAssetsService mAssetsService = null; |
17 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
18 |
1
|
@Override... |
19 |
|
protected void onCreate(Bundle savedInstanceState) { |
20 |
1
|
super.onCreate(savedInstanceState); |
21 |
1
|
setContentView(R.layout.splash_screen); |
22 |
|
} |
23 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
24 |
1
|
@Override... |
25 |
|
protected void onDestroy() { |
26 |
1
|
this.removeEvent(); |
27 |
1
|
super.onDestroy(); |
28 |
|
} |
29 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
30 |
1
|
private void addEvent(){... |
31 |
1
|
BicycleService.getInstance().getAssetsEventListener().addEvent(this); |
32 |
|
} |
33 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
34 |
1
|
private void removeEvent(){... |
35 |
1
|
BicycleService.getInstance().getAssetsEventListener().removeEvent(this); |
36 |
|
} |
37 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
38 |
1
|
@Override... |
39 |
|
protected void onResume() { |
40 |
1
|
super.onResume(); |
41 |
1
|
this.init(); |
42 |
|
} |
43 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
|
44 |
1
|
private void init(){... |
45 |
1
|
this.addEvent(); |
46 |
|
|
47 |
1
|
mAssetsService = BicycleService.getInstance().getAssertsService(); |
48 |
1
|
mAssetsService.loadCitySetting(); |
49 |
|
|
50 |
|
|
51 |
1
|
long nextShowAdTime = Utils.getLongDataFromLocal(Constants.LocalStoreTag.NEXT_AD_SHOWN_TIME, 0); |
52 |
|
|
53 |
1
|
GlobalSetting.getInstance().getAdsetting().setNextShowAdTime(nextShowAdTime); |
54 |
|
} |
55 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 2 |
Complexity Density: 0,29 |
|
56 |
0
|
private void getBicycleInfo(){... |
57 |
0
|
boolean success = loadAllBicyclesInfoFromLocal(); |
58 |
0
|
if(!success){ |
59 |
0
|
mAssetsService.loadBicyclesInfo(); |
60 |
|
}else { |
61 |
0
|
Intent data = new Intent(); |
62 |
0
|
data.putExtra("load_completed", true); |
63 |
0
|
setResult(RESULT_OK, data); |
64 |
0
|
finish(); |
65 |
|
} |
66 |
|
} |
67 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 3 |
Complexity Density: 0,6 |
|
68 |
0
|
private boolean loadAllBicyclesInfoFromLocal(){... |
69 |
0
|
String jsonStr = Utils.getStringDataFromLocal(Constants.LocalStoreTag.ALL_BICYCLE); |
70 |
0
|
if(jsonStr == null || jsonStr.equals("")){ |
71 |
0
|
return false; |
72 |
|
} |
73 |
0
|
Utils.setToDataset(jsonStr); |
74 |
0
|
return true; |
75 |
|
} |
76 |
|
|
77 |
|
|
78 |
|
|
79 |
|
|
|
|
| 75% |
Uncovered Elements: 2 (8) |
Complexity: 2 |
Complexity Density: 0,33 |
|
80 |
1
|
public void onCitySettingLoaded(int resultCode) {... |
81 |
1
|
if(resultCode == Constants.ResultCode.SUCCESS){ |
82 |
0
|
getBicycleInfo(); |
83 |
|
}else { |
84 |
1
|
Intent data = new Intent(); |
85 |
1
|
data.putExtra("load_completed", false); |
86 |
1
|
setResult(RESULT_OK, data); |
87 |
1
|
finish(); |
88 |
|
} |
89 |
|
} |
90 |
|
|
91 |
|
|
92 |
|
|
93 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0,4 |
|
94 |
0
|
public void onBicyclesInfoLoaded(int resultCode) {... |
95 |
0
|
if (resultCode == Constants.ResultCode.SUCCESS) { |
96 |
0
|
Intent data = new Intent(); |
97 |
0
|
data.putExtra("load_completed", true); |
98 |
0
|
setResult(RESULT_OK, data); |
99 |
0
|
finish(); |
100 |
|
} |
101 |
|
} |
102 |
|
} |