pull/1336/head
gedoor 3 years ago
parent b5e8f29cf9
commit 486333dcbd
  1. 3
      app/src/main/java/io/legado/app/base/BaseActivity.kt
  2. 4
      app/src/main/java/io/legado/app/service/AudioPlayService.kt
  3. 3
      app/src/main/java/io/legado/app/service/BaseReadAloudService.kt
  4. 8
      app/src/main/java/io/legado/app/service/CacheBookService.kt

@ -35,8 +35,7 @@ abstract class BaseActivity<VB : ViewBinding>(
private val toolBarTheme: Theme = Theme.Auto,
private val transparent: Boolean = false,
private val imageBg: Boolean = true
) : AppCompatActivity(),
CoroutineScope by MainScope() {
) : AppCompatActivity(), CoroutineScope by MainScope() {
protected abstract val binding: VB

@ -44,9 +44,13 @@ class AudioPlayService : BaseService(),
companion object {
var isRun = false
private set
var pause = false
private set
var timeMinute: Int = 0
private set
var url: String = ""
private set
}
private val audioManager: AudioManager by lazy {

@ -33,8 +33,11 @@ abstract class BaseReadAloudService : BaseService(),
companion object {
var isRun = false
private set
var timeMinute: Int = 0
private set
var pause = true
private set
fun isPlay(): Boolean {
return isRun && !pause

@ -18,6 +18,12 @@ import java.util.concurrent.Executors
import kotlin.math.min
class CacheBookService : BaseService() {
companion object {
var isRun = false
private set
}
private val threadCount = AppConfig.threadCount
private var cachePool =
Executors.newFixedThreadPool(min(threadCount, AppConst.MAX_THREAD)).asCoroutineDispatcher()
@ -39,6 +45,7 @@ class CacheBookService : BaseService() {
override fun onCreate() {
super.onCreate()
isRun = true
upNotification(getString(R.string.starting_download))
launch {
while (isActive) {
@ -65,6 +72,7 @@ class CacheBookService : BaseService() {
}
override fun onDestroy() {
isRun = false
cachePool.close()
CacheBook.cacheBookMap.clear()
super.onDestroy()

Loading…
Cancel
Save