Clover Coverage Report - Main Coverage Report
Coverage timestamp: ven dic 19 2014 16:47:52 EST
../../../../img/srcFileCovDistChart9.png 17% of files have more coverage
29   76   13   4,83
2   68   0,45   6
6     2,17  
1    
This report was generated with an evaluation server license. Purchase Clover or configure your license.
 
  AssetsService       Line # 13 29 13 81,1% 0.8108108
 
No Tests
 
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.IAssetsService;
10    import com.dreamcatcher.bicycle.util.Constants;
11    import com.dreamcatcher.bicycle.util.Utils;
12   
 
13    public class AssetsService implements IAssetsService {
14    private ExecutorService mExecutorService = null;
15    private Handler mHandler = null;
16    private final static int CITY_SETTING_LOAD_SUCCESS = 0;
17    private final static int CITY_SETTING_LOAD_FAILED = 1;
18    private final static int BICYCLE_INFO_LOAD_SUCCESS = 2;
19    private final static int BICYCLE_INFO_LOAD_FAILED = 3;
20   
 
21  1 toggle public AssetsService(){
22  1 mExecutorService = Executors.newCachedThreadPool();
23  1 mHandler = new Handler(){
 
24  3 toggle @Override
25    public void handleMessage(Message msg) {
26  3 switch (msg.what) {
27  1 case CITY_SETTING_LOAD_SUCCESS:
28  1 BicycleService.getInstance().getAssetsEventListener().onCitySettingLoaded(Constants.ResultCode.SUCCESS);
29  1 break;
30  1 case CITY_SETTING_LOAD_FAILED:
31  1 BicycleService.getInstance().getAssetsEventListener().onCitySettingLoaded(Constants.ResultCode.LOAD_ASSETS_FAILED);
32  1 break;
33  1 case BICYCLE_INFO_LOAD_SUCCESS:
34  1 BicycleService.getInstance().getAssetsEventListener().onBicyclesInfoLoaded(Constants.ResultCode.SUCCESS);
35  1 break;
36  0 case BICYCLE_INFO_LOAD_FAILED:
37  0 BicycleService.getInstance().getAssetsEventListener().onBicyclesInfoLoaded(Constants.ResultCode.LOAD_ASSETS_FAILED);
38  0 break;
39  0 default:
40  0 break;
41    }
42    }
43    };
44    }
45   
 
46  2 toggle public void loadCitySetting() {
47  2 mExecutorService.execute(new Runnable() {
 
48  2 toggle public void run() {
49  2 try {
50  2 boolean success = Utils.loadCitySetting();
51  2 if(success){
52  1 mHandler.sendEmptyMessage(CITY_SETTING_LOAD_SUCCESS);
53    }else {
54  1 mHandler.sendEmptyMessage(CITY_SETTING_LOAD_FAILED);
55    }
56    } catch (Exception e) {
57  0 mHandler.sendEmptyMessage(CITY_SETTING_LOAD_FAILED);
58    }
59    }
60    });
61    }
62   
 
63  1 toggle public void loadBicyclesInfo() {
64  1 mExecutorService.execute(new Runnable() {
 
65  1 toggle public void run() {
66  1 try {
67  1 Utils.loadBicyclesInfoFromAssets();
68  1 mHandler.sendEmptyMessage(BICYCLE_INFO_LOAD_SUCCESS);
69    } catch (Exception e) {
70  0 mHandler.sendEmptyMessage(BICYCLE_INFO_LOAD_FAILED);
71    }
72    }
73    });
74    }
75   
76    }