Skip to content

Commit

Permalink
Fixed startup job, show only future values in forecast screen
Browse files Browse the repository at this point in the history
  • Loading branch information
thuryn committed May 6, 2024
1 parent 43e9e1b commit a9e0a12
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,17 @@ public WeatherForecastAdapter(Context context,

mWeatherList = new HashMap<>();
keys = new ArrayList<>();
long now = System.currentTimeMillis();
Calendar forecastCalendar = Calendar.getInstance();
for (DetailedWeatherForecast forecast: weatherForecastList) {
if (forecast == null) {
continue;
}
forecastCalendar.setTimeInMillis(forecast.getDateTime() * 1000);
long forecastDateTimeInMs = forecast.getDateTime() * 1000;
if (forecastDateTimeInMs < now) {
continue;
}
forecastCalendar.setTimeInMillis(forecastDateTimeInMs);
int forecastDay = forecastCalendar.get(Calendar.DAY_OF_YEAR);
if (!mWeatherList.keySet().contains(forecastDay)) {
List<DetailedWeatherForecast> dayForecastList = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ public void handleMessage(Message inputMessage) {
};

private void processScreenOn(Context context) {
WidgetUtils.updateWidgets(context);
Message completeMessage =
handler.obtainMessage();
completeMessage.obj = context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ private enum Updated {
@Override
public boolean onStartJob(JobParameters params) {
this.params = params;
appendLog(this, TAG, "onStartJob");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
setNotification(params, NotificationUtils.NOTIFICATION_ID, NotificationUtils.getNotificationForActivity(this),
setNotification(params, NotificationUtils.NOTIFICATION_ID, NotificationUtils.getNoWeatherNotification(this),
JobService.JOB_END_NOTIFICATION_POLICY_DETACH);
}
YourLocalWeather.executor.submit(() -> {
appendLog(this, TAG, "onStartJob");
try {
performUpdateOfLocation();
startSensorBasedUpdates();
Expand Down

0 comments on commit a9e0a12

Please sign in to comment.