1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-23 08:14:45 +00:00
FairEmail/patches/ComputableLiveData.patch

30 lines
1.7 KiB
Diff
Raw Normal View History

2020-06-15 13:38:17 +00:00
--- /home/marcel/support/lifecycle/lifecycle-livedata/src/main/java/androidx/lifecycle/ComputableLiveData.java 2020-03-23 17:03:45.426122318 +0100
+++ /home/marcel/email/app/src/main/java/androidx/lifecycle/ComputableLiveData.java 2020-06-14 11:48:36.977868184 +0200
@@ -96,13 +96,26 @@ public abstract class ComputableLiveData
2019-07-06 08:51:16 +00:00
// as long as it is invalid, keep computing.
try {
T value = null;
2019-08-16 07:58:12 +00:00
+ boolean once = true;
+ long last = android.os.SystemClock.elapsedRealtime();
2019-07-06 08:51:16 +00:00
while (mInvalid.compareAndSet(true, false)) {
+ long now = android.os.SystemClock.elapsedRealtime();
2019-08-14 08:33:34 +00:00
+ if (value != null && (once || last + 2500 < now)) {
+ eu.faircode.email.Log.i(mLiveData + " post once=" + once + " age=" + (now - last) + " ms");
+ once = false;
2019-07-06 08:51:16 +00:00
+ last = now;
+ mLiveData.postValue(value);
+ }
computed = true;
value = compute();
}
2020-06-15 13:38:17 +00:00
if (computed) {
mLiveData.postValue(value);
}
+ } catch (Throwable ex) {
+ // java.lang.IllegalStateException: Couldn't read row xxx column yyy
+ eu.faircode.email.Log.e(ex);
+ mInvalid.set(true);
} finally {
// release compute lock
mComputing.set(false);