mirror of
https://github.com/gedoor/legado.git
synced 2024-07-06 23:47:49 +08:00
Compare commits
1 Commits
170edff5b4
...
4e5caaf804
Author | SHA1 | Date | |
---|---|---|---|
|
4e5caaf804 |
@ -1,7 +1,6 @@
|
||||
package io.legado.app.base
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.os.IBinder
|
||||
import androidx.annotation.CallSuper
|
||||
import androidx.lifecycle.LifecycleService
|
||||
@ -84,11 +83,9 @@ abstract class BaseService : LifecycleService() {
|
||||
}
|
||||
}
|
||||
.request()
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
PermissionsCompat.Builder()
|
||||
.addPermissions(Permissions.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS)
|
||||
.rationale(R.string.ignore_battery_permission_rationale)
|
||||
.request()
|
||||
}
|
||||
PermissionsCompat.Builder()
|
||||
.addPermissions(Permissions.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS)
|
||||
.rationale(R.string.ignore_battery_permission_rationale)
|
||||
.request()
|
||||
}
|
||||
}
|
||||
}
|
@ -27,7 +27,6 @@ import io.legado.app.help.book.BookHelp
|
||||
import io.legado.app.help.book.ContentProcessor
|
||||
import io.legado.app.help.book.getExportFileName
|
||||
import io.legado.app.help.book.isLocal
|
||||
import io.legado.app.help.book.isLocalModified
|
||||
import io.legado.app.help.config.AppConfig
|
||||
import io.legado.app.model.localBook.LocalBook
|
||||
import io.legado.app.ui.book.cache.CacheActivity
|
||||
@ -58,7 +57,6 @@ import kotlinx.coroutines.coroutineScope
|
||||
import kotlinx.coroutines.ensureActive
|
||||
import kotlinx.coroutines.flow.collectIndexed
|
||||
import kotlinx.coroutines.flow.flow
|
||||
import kotlinx.coroutines.isActive
|
||||
import kotlinx.coroutines.launch
|
||||
import me.ag2s.epublib.domain.Author
|
||||
import me.ag2s.epublib.domain.Date
|
||||
@ -123,10 +121,7 @@ class ExportBookService : BaseService() {
|
||||
toastOnUi(it.localizedMessage)
|
||||
}
|
||||
|
||||
IntentAction.stop -> {
|
||||
notificationManager.cancel(NotificationId.ExportBook)
|
||||
stopSelf()
|
||||
}
|
||||
IntentAction.stop -> stopSelf()
|
||||
}
|
||||
return super.onStartCommand(intent, flags, startId)
|
||||
}
|
||||
@ -135,9 +130,6 @@ class ExportBookService : BaseService() {
|
||||
super.onDestroy()
|
||||
exportProgress.clear()
|
||||
exportMsg.clear()
|
||||
waitExportBooks.keys.forEach {
|
||||
postEvent(EventBus.EXPORT_BOOK, it)
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
@ -176,7 +168,7 @@ class ExportBookService : BaseService() {
|
||||
return
|
||||
}
|
||||
exportJob = lifecycleScope.launch(IO) {
|
||||
while (isActive) {
|
||||
while (true) {
|
||||
val (bookUrl, exportConfig) = waitExportBooks.entries.firstOrNull() ?: let {
|
||||
notificationContentText = "导出完成"
|
||||
upExportNotification(true)
|
||||
@ -208,7 +200,6 @@ class ExportBookService : BaseService() {
|
||||
}
|
||||
exportMsg[book.bookUrl] = getString(R.string.export_success)
|
||||
} catch (e: Throwable) {
|
||||
ensureActive()
|
||||
exportMsg[bookUrl] = e.localizedMessage ?: "ERROR"
|
||||
AppLog.put("导出书籍<${book?.name ?: bookUrl}>出错", e)
|
||||
} finally {
|
||||
@ -220,7 +211,10 @@ class ExportBookService : BaseService() {
|
||||
}
|
||||
|
||||
private fun refreshChapterList(book: Book) {
|
||||
if (!book.isLocal || !book.isLocalModified()) {
|
||||
if (!book.isLocal) {
|
||||
return
|
||||
}
|
||||
if (LocalBook.getLastModified(book).getOrDefault(0L) < book.latestChapterTime) {
|
||||
return
|
||||
}
|
||||
kotlin.runCatching {
|
||||
|
Loading…
Reference in New Issue
Block a user