// Path: app/src/main/java/com/kuahusg/weather/service/AutoUpdateService.java
// public class AutoUpdateService extends Service {
//     private double time = 2;
// 
//     //    private IDataSource dataSource = new WeatherDataSource(new RemoteForecastDataSource(), new LocalForecastDataSource());
//     private WeakReference<IDataSource> dataSourceWeakReference = new WeakReference<IDataSource>(new WeatherDataSource(new RemoteForecastDataSource(), new LocalForecastDataSource()));
// 
// 
//     @Override
//     public void onCreate() {
//         super.onCreate();
//         LogUtil.v(this.toString(), "Service onCreate()");
// 
//     }
// 
//     @Nullable
//     @Override
//     public IBinder onBind(Intent intent) {
//         return null;
//     }
// 
//     @Override
//     public int onStartCommand(Intent intent, int flags, int startId) {
// 
// 
//         time = Double.valueOf(PreferenceUtil.getInstance().getSharedPreferences().getString(SettingFragment.UPDATE_TIME, "0"));
//         if (time <= 0)
//             time = 2;
//         // TODO: 16-10-8 ??
//         dataSourceWeakReference.get().queryWeather(null, new RequestWeatherCallback() {
//             @Override
//             public void success(List<Forecast> forecasts, ForecastInfo forecastInfo) {
//             }
// 
//             @Override
//             public void error(String message) {
// 
//             }
//         });
// 
//         AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
//         long hours = (long) (time * 60 * 60 * 1000 + SystemClock.elapsedRealtime());
//         Intent i = new Intent(this, AutoUpdateReceiver.class);
//         PendingIntent pi = PendingIntent.getBroadcast(this, 0, i, 0);
//         alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, hours, pi);
//         return super.onStartCommand(intent, flags, startId);
//     }
// 
//     @Override
//     public void onDestroy() {
//         super.onDestroy();
//         LogUtil.v(this.toString(), "Service onDestroy()");
//     }
// 
// 
// }
// 
// Path: app/src/main/java/com/kuahusg/weather/util/PreferenceUtil.java
// public class PreferenceUtil {
//     SharedPreferences sharedPreferences;
//     SharedPreferences.Editor editor;
//     public static final String PREF_HAS_LOAD_ALL_CITY = "hasLoadAllCity";
//     public static final String PREF_SELECTED_CITY = "selectCity";
//     public static final String PREF_WOEID = "woeid";
//     public static final String PREF_CITY_SIMPLE_NAME = "selectCitySimpleName";
//     public static final String PREF_AUTO_UPDATE = "auto_update";
// 
//     private PreferenceUtil() {
// 
//     }
// 
//     public static PreferenceUtil getInstance() {
//         return InstanceHolder.INSTANCE;
//     }
// 
// 
//     public SharedPreferences getSharedPreferences() {
//         if (sharedPreferences == null)
//             sharedPreferences = PreferenceManager.getDefaultSharedPreferences(App.getContext());
//         return sharedPreferences;
//     }
// 
//     public SharedPreferences.Editor getSharedPreferencesEditor() {
//         if (editor == null) {
//             editor = getSharedPreferences().edit();
//         }
// 
//         return editor;
//     }
// 
//     public static String getWoeid() {
//         return InstanceHolder.INSTANCE.getSharedPreferences().getString(PREF_WOEID, null);
//     }
// 
//     public static String getCitySimpleName() {
//         return InstanceHolder.INSTANCE.getSharedPreferences().getString(PREF_CITY_SIMPLE_NAME, null);
//     }
// 
//     public static boolean getCanAutoUpdate() {
//         return InstanceHolder.INSTANCE.getSharedPreferences().getBoolean(PREF_AUTO_UPDATE, false);
//     }
// 
// 
//     private static final class InstanceHolder {
//         static final PreferenceUtil INSTANCE = new PreferenceUtil();
//     }
// }


import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import com.kuahusg.weather.service.AutoUpdateService;
import com.kuahusg.weather.util.PreferenceUtil;
package com.kuahusg.weather.receiver;



/**
 * Created by kuahusg on 16-6-21.
 * com.kuahusg.weather.receiver
 */
public class BootCompleteReciver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
//        LogUtil.v(this.toString(), "boot complete,start service");
// Path: app/src/main/java/com/kuahusg/weather/service/AutoUpdateService.java
// public class AutoUpdateService extends Service {
//     private double time = 2;
// 
//     //    private IDataSource dataSource = new WeatherDataSource(new RemoteForecastDataSource(), new LocalForecastDataSource());
//     private WeakReference<IDataSource> dataSourceWeakReference = new WeakReference<IDataSource>(new WeatherDataSource(new RemoteForecastDataSource(), new LocalForecastDataSource()));
// 
// 
//     @Override
//     public void onCreate() {
//         super.onCreate();
//         LogUtil.v(this.toString(), "Service onCreate()");
// 
//     }
// 
//     @Nullable
//     @Override
//     public IBinder onBind(Intent intent) {
//         return null;
//     }
// 
//     @Override
//     public int onStartCommand(Intent intent, int flags, int startId) {
// 
// 
//         time = Double.valueOf(PreferenceUtil.getInstance().getSharedPreferences().getString(SettingFragment.UPDATE_TIME, "0"));
//         if (time <= 0)
//             time = 2;
//         // TODO: 16-10-8 ??
//         dataSourceWeakReference.get().queryWeather(null, new RequestWeatherCallback() {
//             @Override
//             public void success(List<Forecast> forecasts, ForecastInfo forecastInfo) {
//             }
// 
//             @Override
//             public void error(String message) {
// 
//             }
//         });
// 
//         AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
//         long hours = (long) (time * 60 * 60 * 1000 + SystemClock.elapsedRealtime());
//         Intent i = new Intent(this, AutoUpdateReceiver.class);
//         PendingIntent pi = PendingIntent.getBroadcast(this, 0, i, 0);
//         alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, hours, pi);
//         return super.onStartCommand(intent, flags, startId);
//     }
// 
//     @Override
//     public void onDestroy() {
//         super.onDestroy();
//         LogUtil.v(this.toString(), "Service onDestroy()");
//     }
// 
// 
// }
// 
// Path: app/src/main/java/com/kuahusg/weather/util/PreferenceUtil.java
// public class PreferenceUtil {
//     SharedPreferences sharedPreferences;
//     SharedPreferences.Editor editor;
//     public static final String PREF_HAS_LOAD_ALL_CITY = "hasLoadAllCity";
//     public static final String PREF_SELECTED_CITY = "selectCity";
//     public static final String PREF_WOEID = "woeid";
//     public static final String PREF_CITY_SIMPLE_NAME = "selectCitySimpleName";
//     public static final String PREF_AUTO_UPDATE = "auto_update";
// 
//     private PreferenceUtil() {
// 
//     }
// 
//     public static PreferenceUtil getInstance() {
//         return InstanceHolder.INSTANCE;
//     }
// 
// 
//     public SharedPreferences getSharedPreferences() {
//         if (sharedPreferences == null)
//             sharedPreferences = PreferenceManager.getDefaultSharedPreferences(App.getContext());
//         return sharedPreferences;
//     }
// 
//     public SharedPreferences.Editor getSharedPreferencesEditor() {
//         if (editor == null) {
//             editor = getSharedPreferences().edit();
//         }
// 
//         return editor;
//     }
// 
//     public static String getWoeid() {
//         return InstanceHolder.INSTANCE.getSharedPreferences().getString(PREF_WOEID, null);
//     }
// 
//     public static String getCitySimpleName() {
//         return InstanceHolder.INSTANCE.getSharedPreferences().getString(PREF_CITY_SIMPLE_NAME, null);
//     }
// 
//     public static boolean getCanAutoUpdate() {
//         return InstanceHolder.INSTANCE.getSharedPreferences().getBoolean(PREF_AUTO_UPDATE, false);
//     }
// 
// 
//     private static final class InstanceHolder {
//         static final PreferenceUtil INSTANCE = new PreferenceUtil();
//     }
// }


// Path: app/src/main/java/com/kuahusg/weather/receiver/BootCompleteReciver.java
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import com.kuahusg.weather.service.AutoUpdateService;
import com.kuahusg.weather.util.PreferenceUtil;

package com.kuahusg.weather.receiver;



/**
 * Created by kuahusg on 16-6-21.
 * com.kuahusg.weather.receiver
 */
public class BootCompleteReciver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
//        LogUtil.v(this.toString(), "boot complete,start service");
        if (PreferenceUtil.getCanAutoUpdate()) {