import android.widget.Button;
import com.ic.work.hardware.BeforeDawnRunnable;
+import com.ic.work.utils.IcLog;
import com.ic.work.utils.ServiceUtil;
import com.ic.work.weather.LocationState;
import com.ic.work.weather.WeatherHelper;
+import org.threeten.bp.Duration;
import org.threeten.bp.OffsetDateTime;
import org.threeten.bp.ZoneId;
import org.threeten.bp.format.DateTimeFormatter;
context = this;
app =(WorkServiceApp) getApplication();
- /**OffsetDateTime time = OffsetDateTime.now(ZoneId.systemDefault()).plusDays(1);
-
- ThreadPoolManager.getInstance().execute(new BeforeDawnRunnable(
- app.getApplicationContext(),
- app.getRepository(),
- app.getWeatherRepository(),
- 11000));
-
- new Handler().postDelayed(new Runnable() {
- @Override
- public void run() {
- WeatherHelper weather = new WeatherHelper();
- LocationState state = new LocationState(null,true,"深圳市");
- weather.queryWeatherServerInfo(app.getWeatherRepository(),state);
- }
- },10000);**/
+ OffsetDateTime now = OffsetDateTime.now(ZoneId.systemDefault());
+ OffsetDateTime old = OffsetDateTime.parse("2020-04-11T10:19:16.341+08:00");
+
+ Duration interval = Duration.between(old,now);
+ IcLog.i(TAG,"interval: "+interval.toDays());
}
ThreadPoolManager.getInstance().execute(new BeforeDawnRunnable(
mApp.getApplicationContext(),
mApp.getRepository(),
- mApp.getWeatherRepository(),
intent.getIntExtra(PED_TOTAL_KEY, 0)));
}
}
private static final String TAG = "BeforeDawnRunnable";
private int mTotalPed;
- private WeatherInjection weatherInjection;
- public BeforeDawnRunnable(Context context, PedInjection pedInjection, WeatherInjection weatherInjection, int totalPed) {
+ public BeforeDawnRunnable(Context context, PedInjection pedInjection, int totalPed) {
super(context, pedInjection);
this.mTotalPed = totalPed;
- this.weatherInjection = weatherInjection;
}
@Override
public void run() {
- if(weatherInjection != null){
- weatherInjection.deleteDBWeatherDate();
- }
-
IcLog.i(TAG, "Before Ped Count" + mTotalPed);
updateCountDB(mTotalPed, getFrontOffsetDateTime());
import com.ic.work.event.WeatherResultEvent;
import org.greenrobot.eventbus.EventBus;
-import org.threeten.bp.LocalDate;
+import org.threeten.bp.Duration;
import org.threeten.bp.OffsetDateTime;
+import org.threeten.bp.ZoneId;
import org.threeten.bp.format.DateTimeFormatter;
import java.util.ArrayList;
EventBus.getDefault().post(new WeatherAgainEvent());
}else {
List<WeatherParcelable> wpList = new ArrayList<>(weatherList.size());
- for (int i=0; i<weatherList.size(); i++){
- WeatherEntity entity = weatherList.get(i);
-
- WeatherParcelable parcelable = new WeatherParcelable();
- parcelable.setCity(entity.getCity());
- parcelable.setFigureDay(entity.getFigureDay());
- parcelable.setFigureNight(entity.getFigureNight());
- parcelable.setStatusDay(entity.getStatusDay());
- parcelable.setStatusNight(entity.getStatusNight());
- parcelable.setTemperatureDay(entity.getTemperatureDay());
- parcelable.setTemperatureNight(entity.getTemperatureNight());
- parcelable.setUpdateTime(entity.getUpdateTime());
- wpList.add(parcelable);
- }
- //通知主线程 更新UI
- EventBus.getDefault().post(new WeatherResultEvent(wpList));
+ //判断当天是否有昨天的数据,如果有则不是最新数据,要请求数据库
+ OffsetDateTime now = OffsetDateTime.now(ZoneId.systemDefault());
+ Duration interval = Duration.between(weatherList.get(0).getQueryTime(),now);
+ if(interval.toDays() != 0){
+ EventBus.getDefault().post(new WeatherAgainEvent());
+ }else{
+ for (int i=0; i<weatherList.size(); i++){
+ WeatherEntity entity = weatherList.get(i);
+
+ WeatherParcelable parcelable = new WeatherParcelable();
+ parcelable.setCity(entity.getCity());
+ parcelable.setFigureDay(entity.getFigureDay());
+ parcelable.setFigureNight(entity.getFigureNight());
+ parcelable.setStatusDay(entity.getStatusDay());
+ parcelable.setStatusNight(entity.getStatusNight());
+ parcelable.setTemperatureDay(entity.getTemperatureDay());
+ parcelable.setTemperatureNight(entity.getTemperatureNight());
+ parcelable.setUpdateTime(entity.getUpdateTime());
+ wpList.add(parcelable);
+ }
+
+ //通知主线程 更新UI
+ EventBus.getDefault().post(new WeatherResultEvent(wpList));
+ }
}
}
}
-#Fri Apr 10 13:53:45 CST 2020
-VERSION_CODE=29
+#Sat Apr 11 17:08:31 CST 2020
+VERSION_CODE=32