Clover Coverage Report - Main Coverage Report
Coverage timestamp: ven dic 19 2014 16:47:52 EST
../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
18   63   7   3,6
2   50   0,39   5
5     1,4  
1    
This report was generated with an evaluation server license. Purchase Clover or configure your license.
 
  SettingService       Line # 14 18 7 92% 0.92
 
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.ISettingService;
10    import com.dreamcatcher.bicycle.util.Constants;
11    import com.dreamcatcher.bicycle.util.HttpUtils;
12    import com.dreamcatcher.bicycle.util.Utils;
13   
 
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   
 
20  1 toggle public SettingService(){
21  1 mExecutorService = Executors.newCachedThreadPool();
22  1 mHandler = new Handler(){
 
23  2 toggle @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   
 
34  2 toggle public void changeCitySetting(final String cityTag) {
35  2 mExecutorService.execute(new Runnable() {
 
36  2 toggle public void run() {
37  2 try {
38    //clear all data
39  2 Utils.clearLocalData();
40  2 Utils.clearDataset();
41    //update city to local
42  2 Utils.storeStringDataToLocal(Constants.LocalStoreTag.CITY_NAME, cityTag);//set city tag
43    //reload city setting
44  2 Utils.loadCitySetting();
45    //reload bicycles info from assets
46  2 Utils.loadBicyclesInfoFromAssets();
47    //reload bicycles from server
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   
 
58  8 toggle public void changeFavoriteIds(String favoriteIds) {
59  8 Utils.storeStringDataToLocal(Constants.LocalStoreTag.FAVORITE_IDS, favoriteIds);
60  8 BicycleService.getInstance().getSettingEventListener().onFavoriteIdsChanged();
61    }
62   
63    }