Unverified Commit 65ed32b8 authored by Florian Klien's avatar Florian Klien Committed by GitHub

Merge pull request #21 from Rufus125/master

Merge changes from FOSDEM app
parents b7aafadf ef109b09
......@@ -27,11 +27,15 @@ public class LiveDataFactory {
@Override
protected void onActive() {
final long now = SystemClock.elapsedRealtime();
if (now >= updateTime) {
update(now);
if (version == 0L) {
run();
} else {
handler.postDelayed(this, updateTime - now);
final long now = SystemClock.elapsedRealtime();
if (now >= updateTime) {
handler.post(this);
} else {
handler.postDelayed(this, updateTime - now);
}
}
}
......@@ -40,15 +44,11 @@ public class LiveDataFactory {
handler.removeCallbacks(this);
}
private void update(long now) {
setValue(version++);
updateTime = now + periodInMillis;
handler.postDelayed(this, periodInMillis);
}
@Override
public void run() {
update(SystemClock.elapsedRealtime());
setValue(version++);
updateTime = SystemClock.elapsedRealtime() + periodInMillis;
handler.postDelayed(this, periodInMillis);
}
}
......
......@@ -27,7 +27,7 @@ public class EventsParser extends IterableAbstractPullParser<DetailedEvent> {
private final DateFormat DATE_FORMAT = DateUtils.withAustrianTimeZone(new SimpleDateFormat("yyyy-MM-dd", Locale.US));
// Calendar used to compute the events time, according to Belgium timezone
// Calendar used to compute the events time, according to Austrian timezone
private final Calendar calendar = Calendar.getInstance(DateUtils.getAustriaTimeZone(), Locale.US);
private Day currentDay;
......
......@@ -25,7 +25,7 @@ public class LiveViewModel extends AndroidViewModel {
new Function<Long, LiveData<PagedList<StatusEvent>>>() {
@Override
public LiveData<PagedList<StatusEvent>> apply(Long version) {
final long now = System.currentTimeMillis();
final long now = System.currentTimeMillis() + 3600000;
return new LivePagedListBuilder<>(appDatabase.getScheduleDao().getEventsWithStartTime(now, now + NEXT_EVENTS_INTERVAL), 20)
.build();
}
......@@ -34,7 +34,7 @@ public class LiveViewModel extends AndroidViewModel {
new Function<Long, LiveData<PagedList<StatusEvent>>>() {
@Override
public LiveData<PagedList<StatusEvent>> apply(Long version) {
final long now = System.currentTimeMillis();
final long now = System.currentTimeMillis() + 3600000;
return new LivePagedListBuilder<>(appDatabase.getScheduleDao().getEventsInProgress(now), 20)
.build();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment