Deprecate thread helper

This commit is contained in:
Mygod
2019-01-26 01:33:35 +08:00
parent 59713a1eb5
commit 074252ad1c
2 changed files with 5 additions and 22 deletions

View File

@@ -7,9 +7,6 @@ import android.widget.ImageView
import androidx.annotation.DrawableRes
import androidx.core.view.isVisible
import androidx.databinding.BindingAdapter
import be.mygod.vpnhotspot.R
import be.mygod.vpnhotspot.widget.SmartSnackbar
import timber.log.Timber
import java.net.InetAddress
import java.net.NetworkInterface
import java.net.SocketException
@@ -62,20 +59,6 @@ private val parseNumericAddress by lazy {
}
fun parseNumericAddress(address: String) = parseNumericAddress.invoke(null, address) as InetAddress
/**
* Wrapper for kotlin.concurrent.thread that silences uncaught exceptions.
*/
fun thread(name: String? = null, start: Boolean = true, isDaemon: Boolean = false,
contextClassLoader: ClassLoader? = null, priority: Int = -1, block: () -> Unit): Thread {
val thread = kotlin.concurrent.thread(false, isDaemon, contextClassLoader, name, priority, block)
thread.setUncaughtExceptionHandler { _, e ->
SmartSnackbar.make(R.string.noisy_su_failure).show()
Timber.w(e)
}
if (start) thread.start()
return thread
}
fun Context.stopAndUnbind(connection: ServiceConnection) {
connection.onServiceDisconnected(null)
unbindService(connection)