Commit 3cb2d59d authored by Rufus's avatar Rufus
parents b8f733d6 2f166836
......@@ -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);
}
}
......
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