ultrasonic-app-subsonic-and.../ultrasonic/src/main/kotlin/org/moire/ultrasonic/util/SilentBackgroundTask.kt

33 lines
829 B
Kotlin
Raw Normal View History

2012-02-26 21:25:13 +01:00
/*
* SilentBackgroundTask.kt
* Copyright (C) 2009-2021 Ultrasonic developers
*
* Distributed under terms of the GNU GPLv3 license.
2012-02-26 21:25:13 +01:00
*/
2021-06-19 20:42:03 +02:00
package org.moire.ultrasonic.util
2012-02-26 21:25:13 +01:00
2021-06-19 20:42:03 +02:00
import android.app.Activity
2012-02-26 21:25:13 +01:00
/**
* @author Sindre Mehus
*/
2021-06-19 20:42:03 +02:00
abstract class SilentBackgroundTask<T>(activity: Activity?) : BackgroundTask<T>(activity) {
override fun execute() {
val thread: Thread = object : Thread() {
override fun run() {
try {
val result = doInBackground()
handler.post { done(result) }
} catch (all: Throwable) {
handler.post { error(all) }
}
}
}
thread.start()
}
override fun updateProgress(messageId: Int) {}
override fun updateProgress(message: String) {}
2012-02-26 21:25:13 +01:00
}