blob: d6c51bc40c45bef10206f9ee109d7a8b3b794c09 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
package moe.yuuta.ext;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import androidx.annotation.Nullable;
import java.util.concurrent.Executor;
/**
* https://stackoverflow.com/a/21256419/6792243
*/
public class HandlerThreadExecutor implements Executor {
private final Handler mHandler;
public HandlerThreadExecutor(@Nullable Handler optionalHandler) {
mHandler = optionalHandler != null ? optionalHandler : new Handler(Looper.getMainLooper());
}
@Override
public void execute(Runnable command) {
Log.d("Debug", "execute: " + command.toString());
mHandler.post(command);
Log.d("Debug", "done executing");
//
}
}
|