Remove usages of deprecated Handler constructor.

This commit is contained in:
Alan Evans
2021-01-05 17:40:18 -04:00
parent 64312f9c7f
commit 6dd3fdaa55
16 changed files with 42 additions and 20 deletions

View File

@@ -1,6 +1,7 @@
package org.thoughtcrime.securesms.util;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import androidx.annotation.MainThread;
@@ -52,6 +53,10 @@ public class ThrottledDebouncer {
private static class OverflowHandler extends Handler {
public OverflowHandler() {
super(Looper.getMainLooper());
}
private Runnable runnable;
@Override

View File

@@ -1,6 +1,7 @@
package org.thoughtcrime.securesms.util;
import android.os.Handler;
import android.os.Looper;
/**
* A class that will throttle the number of runnables executed to be at most once every specified
@@ -26,7 +27,7 @@ public class Throttler {
* {@code threshold} milliseconds.
*/
public Throttler(long threshold) {
this.handler = new Handler();
this.handler = new Handler(Looper.getMainLooper());
this.threshold = threshold;
}

View File

@@ -1,6 +1,7 @@
package org.thoughtcrime.securesms.util.livedata;
import android.os.Handler;
import android.os.Looper;
import androidx.annotation.NonNull;
import androidx.lifecycle.LiveData;
@@ -162,7 +163,7 @@ public final class LiveDataUtil {
@Override
protected void onActive() {
if (emittedValue) return;
new Handler().postDelayed(() -> setValue(value), delay);
new Handler(Looper.getMainLooper()).postDelayed(() -> setValue(value), delay);
emittedValue = true;
}
};