1 |
|
package com.dreamcatcher.bicycle.core; |
2 |
|
|
3 |
|
import java.util.concurrent.ExecutorService; |
4 |
|
import java.util.concurrent.Executors; |
5 |
|
|
6 |
|
import android.os.Handler; |
7 |
|
import android.os.Message; |
8 |
|
|
9 |
|
import com.dreamcatcher.bicycle.interfaces.ISettingService; |
10 |
|
import com.dreamcatcher.bicycle.util.Constants; |
11 |
|
import com.dreamcatcher.bicycle.util.HttpUtils; |
12 |
|
import com.dreamcatcher.bicycle.util.Utils; |
13 |
|
|
|
|
| 92% |
Uncovered Elements: 2 (25) |
Complexity: 7 |
Complexity Density: 0,39 |
|
14 |
|
public class SettingService implements ISettingService { |
15 |
|
private ExecutorService mExecutorService = null; |
16 |
|
private Handler mHandler = null; |
17 |
|
private final static int SETTING_SUCCESS = 0; |
18 |
|
private final static int SETTING_FIALED = 0; |
19 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
20 |
1
|
public SettingService(){... |
21 |
1
|
mExecutorService = Executors.newCachedThreadPool(); |
22 |
1
|
mHandler = new Handler(){ |
|
|
| 60% |
Uncovered Elements: 2 (5) |
Complexity: 2 |
Complexity Density: 0,67 |
|
23 |
2
|
@Override... |
24 |
|
public void handleMessage(Message msg) { |
25 |
2
|
if(msg.what == SETTING_SUCCESS){ |
26 |
2
|
BicycleService.getInstance().getSettingEventListener().onCitySettingChanged(Constants.ResultCode.SUCCESS); |
27 |
|
}else { |
28 |
0
|
BicycleService.getInstance().getSettingEventListener().onCitySettingChanged(Constants.ResultCode.CHANGE_CITY_FAILED); |
29 |
|
} |
30 |
|
} |
31 |
|
}; |
32 |
|
} |
33 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
34 |
2
|
public void changeCitySetting(final String cityTag) {... |
35 |
2
|
mExecutorService.execute(new Runnable() { |
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 2 |
Complexity Density: 0,2 |
|
36 |
2
|
public void run() {... |
37 |
2
|
try { |
38 |
|
|
39 |
2
|
Utils.clearLocalData(); |
40 |
2
|
Utils.clearDataset(); |
41 |
|
|
42 |
2
|
Utils.storeStringDataToLocal(Constants.LocalStoreTag.CITY_NAME, cityTag); |
43 |
|
|
44 |
2
|
Utils.loadCitySetting(); |
45 |
|
|
46 |
2
|
Utils.loadBicyclesInfoFromAssets(); |
47 |
|
|
48 |
2
|
HttpUtils.getAllBicyclesInfoFromServer(); |
49 |
1
|
mHandler.sendEmptyMessage(SETTING_SUCCESS); |
50 |
|
} catch (Exception e) { |
51 |
1
|
e.printStackTrace(); |
52 |
1
|
mHandler.sendEmptyMessage(SETTING_FIALED); |
53 |
|
} |
54 |
|
} |
55 |
|
}); |
56 |
|
} |
57 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
58 |
8
|
public void changeFavoriteIds(String favoriteIds) {... |
59 |
8
|
Utils.storeStringDataToLocal(Constants.LocalStoreTag.FAVORITE_IDS, favoriteIds); |
60 |
8
|
BicycleService.getInstance().getSettingEventListener().onFavoriteIdsChanged(); |
61 |
|
} |
62 |
|
|
63 |
|
} |