MainThreadExecutor to Kotlin

This commit is contained in:
Maxence G 2022-07-04 18:42:14 +02:00
parent 0929a6a1bd
commit b8c924be27
No known key found for this signature in database
GPG Key ID: DC1FD9409E3FE284
2 changed files with 22 additions and 26 deletions

View File

@ -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);
}
}

View File

@ -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)
}
}