MainThreadExecutor to Kotlin
This commit is contained in:
parent
0929a6a1bd
commit
b8c924be27
|
@ -1,26 +0,0 @@
|
|||
/*
|
||||
* MainThreadExecutor.java
|
||||
* Copyright (C) 2009-2022 Ultrasonic developers
|
||||
*
|
||||
* Distributed under terms of the GNU GPLv3 license.
|
||||
*/
|
||||
|
||||
package org.moire.ultrasonic.util;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
/*
|
||||
* Executor for running Futures on the main thread
|
||||
* See https://stackoverflow.com/questions/52642246/how-to-get-executor-for-main-thread-on-api-level-28
|
||||
*/
|
||||
public class MainThreadExecutor implements Executor {
|
||||
private final Handler handler = new Handler(Looper.getMainLooper());
|
||||
|
||||
@Override
|
||||
public void execute(Runnable r) {
|
||||
handler.post(r);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* MainThreadExecutor.java
|
||||
* Copyright (C) 2009-2022 Ultrasonic developers
|
||||
*
|
||||
* Distributed under terms of the GNU GPLv3 license.
|
||||
*/
|
||||
package org.moire.ultrasonic.util
|
||||
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import java.util.concurrent.Executor
|
||||
|
||||
/*
|
||||
* Executor for running Futures on the main thread
|
||||
* See https://stackoverflow.com/questions/52642246/how-to-get-executor-for-main-thread-on-api-level-28
|
||||
*/
|
||||
class MainThreadExecutor : Executor {
|
||||
private val handler = Handler(Looper.getMainLooper())
|
||||
override fun execute(r: Runnable) {
|
||||
handler.post(r)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue