diff --git a/app/src/main/java/io/legado/app/api/controller/BookController.kt b/app/src/main/java/io/legado/app/api/controller/BookController.kt index 7239abc47..766e36c69 100644 --- a/app/src/main/java/io/legado/app/api/controller/BookController.kt +++ b/app/src/main/java/io/legado/app/api/controller/BookController.kt @@ -10,6 +10,7 @@ import io.legado.app.data.entities.Book import io.legado.app.help.BookHelp import io.legado.app.help.ContentProcessor import io.legado.app.help.glide.ImageLoader +import io.legado.app.help.storage.AppWebDav import io.legado.app.model.ReadBook import io.legado.app.model.localBook.EpubFile import io.legado.app.model.localBook.LocalBook @@ -167,6 +168,7 @@ object BookController { val returnData = ReturnData() if (book != null) { book.save() + AppWebDav.uploadBookProgress(book) if (ReadBook.book?.bookUrl == book.bookUrl) { ReadBook.book = book ReadBook.durChapterIndex = book.durChapterIndex @@ -177,17 +179,16 @@ object BookController { } private fun saveBookReadIndex(book: Book, index: Int) { - if (index > book.durChapterIndex) { - book.durChapterIndex = index - book.durChapterTime = System.currentTimeMillis() - appDb.bookChapterDao.getChapter(book.bookUrl, index)?.let { - book.durChapterTitle = it.title - } - appDb.bookDao.update(book) - if (ReadBook.book?.bookUrl == book.bookUrl) { - ReadBook.book = book - ReadBook.durChapterIndex = index - } + book.durChapterIndex = index + book.durChapterTime = System.currentTimeMillis() + appDb.bookChapterDao.getChapter(book.bookUrl, index)?.let { + book.durChapterTitle = it.title + } + appDb.bookDao.update(book) + AppWebDav.uploadBookProgress(book) + if (ReadBook.book?.bookUrl == book.bookUrl) { + ReadBook.book = book + ReadBook.durChapterIndex = index } } diff --git a/app/src/main/java/io/legado/app/help/storage/BookWebDav.kt b/app/src/main/java/io/legado/app/help/storage/AppWebDav.kt similarity index 99% rename from app/src/main/java/io/legado/app/help/storage/BookWebDav.kt rename to app/src/main/java/io/legado/app/help/storage/AppWebDav.kt index f98b1bd68..5a07165a6 100644 --- a/app/src/main/java/io/legado/app/help/storage/BookWebDav.kt +++ b/app/src/main/java/io/legado/app/help/storage/AppWebDav.kt @@ -20,7 +20,7 @@ import java.io.File import java.text.SimpleDateFormat import java.util.* -object BookWebDav { +object AppWebDav { private const val defaultWebDavUrl = "https://dav.jianguoyun.com/dav/" private val bookProgressUrl = "${rootWebDavUrl}bookProgress/" private val zipFilePath = "${appCtx.externalFiles.absolutePath}${File.separator}backup.zip" diff --git a/app/src/main/java/io/legado/app/help/storage/Backup.kt b/app/src/main/java/io/legado/app/help/storage/Backup.kt index 6bd8cd01c..971a09e82 100644 --- a/app/src/main/java/io/legado/app/help/storage/Backup.kt +++ b/app/src/main/java/io/legado/app/help/storage/Backup.kt @@ -98,7 +98,7 @@ object Backup { } edit.commit() } - BookWebDav.backUpWebDav(backupPath) + AppWebDav.backUpWebDav(backupPath) if (path.isContentScheme()) { copyBackup(context, Uri.parse(path), isAuto) } else { diff --git a/app/src/main/java/io/legado/app/model/ReadBook.kt b/app/src/main/java/io/legado/app/model/ReadBook.kt index 5c0f66c01..90cc3661b 100644 --- a/app/src/main/java/io/legado/app/model/ReadBook.kt +++ b/app/src/main/java/io/legado/app/model/ReadBook.kt @@ -7,7 +7,7 @@ import io.legado.app.data.appDb import io.legado.app.data.entities.* import io.legado.app.help.* import io.legado.app.help.coroutine.Coroutine -import io.legado.app.help.storage.BookWebDav +import io.legado.app.help.storage.AppWebDav import io.legado.app.model.webBook.WebBook import io.legado.app.service.BaseReadAloudService import io.legado.app.service.help.CacheBook @@ -100,7 +100,7 @@ object ReadBook : CoroutineScope by MainScope() { fun uploadProgress(syncBookProgress: Boolean = AppConfig.syncBookProgress) { if (syncBookProgress) { book?.let { - BookWebDav.uploadBookProgress(it) + AppWebDav.uploadBookProgress(it) } } } diff --git a/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt index e2f2e6d69..83d7584af 100644 --- a/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt @@ -6,7 +6,6 @@ import android.view.Menu import android.view.MenuItem import androidx.activity.viewModels import androidx.appcompat.widget.PopupMenu -import androidx.lifecycle.whenStarted import androidx.recyclerview.widget.ItemTouchHelper import androidx.recyclerview.widget.LinearLayoutManager import io.legado.app.R @@ -111,13 +110,11 @@ class ArrangeBookActivity : VMBaseActivity appDb.bookDao.flowAll() - AppConst.bookGroupLocalId -> appDb.bookDao.flowLocal() - AppConst.bookGroupAudioId -> appDb.bookDao.flowAudio() - AppConst.bookGroupNoneId -> appDb.bookDao.flowNoGroup() - else -> appDb.bookDao.flowByGroup(groupId) - }.collect { list -> - val books = when (getPrefInt(PreferKey.bookshelfSort)) { - 1 -> list.sortedByDescending { it.latestChapterTime } - 2 -> list.sortedWith { o1, o2 -> - o1.name.cnCompare(o2.name) - } - 3 -> list.sortedBy { it.order } - else -> list.sortedByDescending { it.durChapterTime } + when (groupId) { + AppConst.bookGroupAllId -> appDb.bookDao.flowAll() + AppConst.bookGroupLocalId -> appDb.bookDao.flowLocal() + AppConst.bookGroupAudioId -> appDb.bookDao.flowAudio() + AppConst.bookGroupNoneId -> appDb.bookDao.flowNoGroup() + else -> appDb.bookDao.flowByGroup(groupId) + }.collect { list -> + val books = when (getPrefInt(PreferKey.bookshelfSort)) { + 1 -> list.sortedByDescending { it.latestChapterTime } + 2 -> list.sortedWith { o1, o2 -> + o1.name.cnCompare(o2.name) } - adapter.setItems(books) + 3 -> list.sortedBy { it.order } + else -> list.sortedByDescending { it.durChapterTime } } + adapter.setItems(books) } } } diff --git a/app/src/main/java/io/legado/app/ui/book/cache/CacheViewModel.kt b/app/src/main/java/io/legado/app/ui/book/cache/CacheViewModel.kt index 64fd14c36..966eb451d 100644 --- a/app/src/main/java/io/legado/app/ui/book/cache/CacheViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/cache/CacheViewModel.kt @@ -18,7 +18,7 @@ import io.legado.app.data.entities.BookChapter import io.legado.app.help.AppConfig import io.legado.app.help.BookHelp import io.legado.app.help.ContentProcessor -import io.legado.app.help.storage.BookWebDav +import io.legado.app.help.storage.AppWebDav import io.legado.app.utils.* import me.ag2s.epublib.domain.* import me.ag2s.epublib.epub.EpubWriter @@ -78,7 +78,7 @@ class CacheViewModel(application: Application) : BaseViewModel(application) { // 导出到webdav val byteArray = stringBuilder.toString().toByteArray(Charset.forName(AppConfig.exportCharset)) - BookWebDav.exportWebDav(byteArray, filename) + AppWebDav.exportWebDav(byteArray, filename) } } getSrcList(book).forEach { @@ -105,7 +105,7 @@ class CacheViewModel(application: Application) : BaseViewModel(application) { if (AppConfig.exportToWebDav) { val byteArray = stringBuilder.toString().toByteArray(Charset.forName(AppConfig.exportCharset)) - BookWebDav.exportWebDav(byteArray, filename) // 导出到webdav + AppWebDav.exportWebDav(byteArray, filename) // 导出到webdav } getSrcList(book).forEach { val vFile = BookHelp.getImage(book, it.third) diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt index 8419585c7..c79096391 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt @@ -7,7 +7,6 @@ import androidx.appcompat.widget.Toolbar import androidx.core.os.bundleOf import androidx.fragment.app.FragmentManager import androidx.fragment.app.viewModels -import androidx.lifecycle.whenStarted import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import io.legado.app.R @@ -154,14 +153,12 @@ class ChangeSourceDialog : BaseDialogFragment(), adapter.setItems(it) }) launch { - lifecycle.whenStarted { - appDb.bookSourceDao.flowGroupEnabled().collect { - groups.clear() - it.map { group -> - groups.addAll(group.splitNotBlank(AppPattern.splitGroupRegex)) - } - upGroupMenu() + appDb.bookSourceDao.flowGroupEnabled().collect { + groups.clear() + it.map { group -> + groups.addAll(group.splitNotBlank(AppPattern.splitGroupRegex)) } + upGroupMenu() } } } diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt index 9cfdf3fae..0abfe72de 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt @@ -13,7 +13,7 @@ import io.legado.app.data.entities.BookProgress import io.legado.app.help.AppConfig import io.legado.app.help.BookHelp import io.legado.app.help.ContentProcessor -import io.legado.app.help.storage.BookWebDav +import io.legado.app.help.storage.AppWebDav import io.legado.app.model.ReadBook import io.legado.app.model.localBook.LocalBook import io.legado.app.model.webBook.PreciseSearch @@ -169,7 +169,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { ) { if (syncBookProgress) execute { - BookWebDav.getBookProgress(book) + AppWebDav.getBookProgress(book) }.onSuccess { it?.let { progress -> if (progress.durChapterIndex < book.durChapterIndex || diff --git a/app/src/main/java/io/legado/app/ui/book/toc/ChapterListFragment.kt b/app/src/main/java/io/legado/app/ui/book/toc/ChapterListFragment.kt index dcd6aa7e7..fdf1a2183 100644 --- a/app/src/main/java/io/legado/app/ui/book/toc/ChapterListFragment.kt +++ b/app/src/main/java/io/legado/app/ui/book/toc/ChapterListFragment.kt @@ -6,7 +6,6 @@ import android.content.Intent import android.os.Bundle import android.view.View import androidx.fragment.app.activityViewModels -import androidx.lifecycle.whenStarted import io.legado.app.R import io.legado.app.base.VMBaseFragment import io.legado.app.constant.EventBus @@ -110,16 +109,14 @@ class ChapterListFragment : VMBaseFragment(R.layout.fragment_chapt override fun upChapterList(searchKey: String?) { tocFlowJob?.cancel() tocFlowJob = launch { - lifecycle.whenStarted { - when { - searchKey.isNullOrBlank() -> appDb.bookChapterDao.flowByBook(viewModel.bookUrl) - else -> appDb.bookChapterDao.flowSearch(viewModel.bookUrl, searchKey) - }.collect { - adapter.setItems(it) - if (searchKey.isNullOrBlank() && !scrollToDurChapter) { - mLayoutManager.scrollToPositionWithOffset(durChapterIndex, 0) - scrollToDurChapter = true - } + when { + searchKey.isNullOrBlank() -> appDb.bookChapterDao.flowByBook(viewModel.bookUrl) + else -> appDb.bookChapterDao.flowSearch(viewModel.bookUrl, searchKey) + }.collect { + adapter.setItems(it) + if (searchKey.isNullOrBlank() && !scrollToDurChapter) { + mLayoutManager.scrollToPositionWithOffset(durChapterIndex, 0) + scrollToDurChapter = true } } } diff --git a/app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt index 651c8b042..e0464e33f 100644 --- a/app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt @@ -19,8 +19,8 @@ import io.legado.app.constant.PreferKey import io.legado.app.help.AppConfig import io.legado.app.help.LocalConfig import io.legado.app.help.coroutine.Coroutine +import io.legado.app.help.storage.AppWebDav import io.legado.app.help.storage.Backup -import io.legado.app.help.storage.BookWebDav import io.legado.app.help.storage.ImportOldData import io.legado.app.help.storage.Restore import io.legado.app.lib.dialogs.alert @@ -268,7 +268,7 @@ class BackupConfigFragment : BasePreferenceFragment(), fun restore() { Coroutine.async(context = Main) { - BookWebDav.showRestoreDialog(requireContext()) + AppWebDav.showRestoreDialog(requireContext()) }.onError { alert { setTitle(R.string.restore) diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/style1/BookshelfFragment1.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/style1/BookshelfFragment1.kt index b62bef803..bb818c303 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/style1/BookshelfFragment1.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/style1/BookshelfFragment1.kt @@ -10,7 +10,6 @@ import androidx.appcompat.widget.SearchView import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentStatePagerAdapter -import androidx.lifecycle.whenStarted import com.google.android.material.tabs.TabLayout import io.legado.app.R import io.legado.app.constant.AppConst @@ -79,11 +78,9 @@ class BookshelfFragment1 : BaseBookshelfFragment(R.layout.fragment_bookshelf), private fun initBookGroupData() { launch { - lifecycle.whenStarted { - appDb.bookGroupDao.flowShow().collect { - viewModel.checkGroup(it) - upGroup(it) - } + appDb.bookGroupDao.flowShow().collect { + viewModel.checkGroup(it) + upGroup(it) } } } diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/style1/books/BooksFragment.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/style1/books/BooksFragment.kt index 025bb7c21..0ae3e207b 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/style1/books/BooksFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/style1/books/BooksFragment.kt @@ -5,7 +5,6 @@ import android.os.Bundle import android.view.View import androidx.core.view.isGone import androidx.fragment.app.activityViewModels -import androidx.lifecycle.whenStarted import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView @@ -107,25 +106,23 @@ class BooksFragment : BaseFragment(R.layout.fragment_books), private fun upRecyclerData() { booksFlowJob?.cancel() booksFlowJob = launch { - lifecycle.whenStarted { - when (groupId) { - AppConst.bookGroupAllId -> appDb.bookDao.flowAll() - AppConst.bookGroupLocalId -> appDb.bookDao.flowLocal() - AppConst.bookGroupAudioId -> appDb.bookDao.flowAudio() - AppConst.bookGroupNoneId -> appDb.bookDao.flowNoGroup() - else -> appDb.bookDao.flowByGroup(groupId) - }.collect { list -> - binding.tvEmptyMsg.isGone = list.isNotEmpty() - val books = when (getPrefInt(PreferKey.bookshelfSort)) { - 1 -> list.sortedByDescending { it.latestChapterTime } - 2 -> list.sortedWith { o1, o2 -> - o1.name.cnCompare(o2.name) - } - 3 -> list.sortedBy { it.order } - else -> list.sortedByDescending { it.durChapterTime } + when (groupId) { + AppConst.bookGroupAllId -> appDb.bookDao.flowAll() + AppConst.bookGroupLocalId -> appDb.bookDao.flowLocal() + AppConst.bookGroupAudioId -> appDb.bookDao.flowAudio() + AppConst.bookGroupNoneId -> appDb.bookDao.flowNoGroup() + else -> appDb.bookDao.flowByGroup(groupId) + }.collect { list -> + binding.tvEmptyMsg.isGone = list.isNotEmpty() + val books = when (getPrefInt(PreferKey.bookshelfSort)) { + 1 -> list.sortedByDescending { it.latestChapterTime } + 2 -> list.sortedWith { o1, o2 -> + o1.name.cnCompare(o2.name) } - booksAdapter.setItems(books) + 3 -> list.sortedBy { it.order } + else -> list.sortedByDescending { it.durChapterTime } } + booksAdapter.setItems(books) } } } diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BookshelfFragment2.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BookshelfFragment2.kt index fb48d30d1..a78178258 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BookshelfFragment2.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BookshelfFragment2.kt @@ -6,7 +6,6 @@ import android.view.Menu import android.view.View import androidx.appcompat.widget.SearchView import androidx.core.view.isGone -import androidx.lifecycle.whenStarted import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView @@ -101,13 +100,11 @@ class BookshelfFragment2 : BaseBookshelfFragment(R.layout.fragment_bookshelf1), @SuppressLint("NotifyDataSetChanged") private fun initGroupData() { launch { - lifecycle.whenStarted { - appDb.bookGroupDao.flowShow().collect { - if (it != bookGroups) { - bookGroups = it - booksAdapter.notifyDataSetChanged() - binding.tvEmptyMsg.isGone = getItemCount() > 0 - } + appDb.bookGroupDao.flowShow().collect { + if (it != bookGroups) { + bookGroups = it + booksAdapter.notifyDataSetChanged() + binding.tvEmptyMsg.isGone = getItemCount() > 0 } } } @@ -126,31 +123,29 @@ class BookshelfFragment2 : BaseBookshelfFragment(R.layout.fragment_bookshelf1), } booksFlowJob?.cancel() booksFlowJob = launch { - lifecycle.whenStarted { - when (groupId) { - AppConst.bookGroupAllId -> appDb.bookDao.flowAll() - AppConst.bookGroupLocalId -> appDb.bookDao.flowLocal() - AppConst.bookGroupAudioId -> appDb.bookDao.flowAudio() - AppConst.bookGroupNoneId -> appDb.bookDao.flowNoGroup() - else -> appDb.bookDao.flowByGroup(groupId) - }.collect { list -> - books = when (getPrefInt(PreferKey.bookshelfSort)) { - 1 -> list.sortedByDescending { - it.latestChapterTime - } - 2 -> list.sortedWith { o1, o2 -> - o1.name.cnCompare(o2.name) - } - 3 -> list.sortedBy { - it.order - } - else -> list.sortedByDescending { - it.durChapterTime - } + when (groupId) { + AppConst.bookGroupAllId -> appDb.bookDao.flowAll() + AppConst.bookGroupLocalId -> appDb.bookDao.flowLocal() + AppConst.bookGroupAudioId -> appDb.bookDao.flowAudio() + AppConst.bookGroupNoneId -> appDb.bookDao.flowNoGroup() + else -> appDb.bookDao.flowByGroup(groupId) + }.collect { list -> + books = when (getPrefInt(PreferKey.bookshelfSort)) { + 1 -> list.sortedByDescending { + it.latestChapterTime + } + 2 -> list.sortedWith { o1, o2 -> + o1.name.cnCompare(o2.name) + } + 3 -> list.sortedBy { + it.order + } + else -> list.sortedByDescending { + it.durChapterTime } - booksAdapter.notifyDataSetChanged() - binding.tvEmptyMsg.isGone = getItemCount() > 0 } + booksAdapter.notifyDataSetChanged() + binding.tvEmptyMsg.isGone = getItemCount() > 0 } } } diff --git a/app/src/main/java/io/legado/app/ui/main/rss/RssFragment.kt b/app/src/main/java/io/legado/app/ui/main/rss/RssFragment.kt index cdc68c6bc..b140c4638 100644 --- a/app/src/main/java/io/legado/app/ui/main/rss/RssFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/rss/RssFragment.kt @@ -7,7 +7,6 @@ import android.view.SubMenu import android.view.View import androidx.appcompat.widget.SearchView import androidx.fragment.app.viewModels -import androidx.lifecycle.whenStarted import io.legado.app.R import io.legado.app.base.VMBaseFragment import io.legado.app.constant.AppPattern @@ -122,14 +121,12 @@ class RssFragment : VMBaseFragment(R.layout.fragment_rss), private fun initGroupData() { launch { - lifecycle.whenStarted { - appDb.rssSourceDao.flowGroup().collect { - groups.clear() - it.map { group -> - groups.addAll(group.splitNotBlank(AppPattern.splitGroupRegex)) - } - upGroupsMenu() + appDb.rssSourceDao.flowGroup().collect { + groups.clear() + it.map { group -> + groups.addAll(group.splitNotBlank(AppPattern.splitGroupRegex)) } + upGroupsMenu() } } } diff --git a/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesFragment.kt b/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesFragment.kt index 3f74c8e81..cfa244702 100644 --- a/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesFragment.kt +++ b/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesFragment.kt @@ -6,7 +6,6 @@ import android.view.View import androidx.fragment.app.activityViewModels import androidx.fragment.app.viewModels import androidx.lifecycle.lifecycleScope -import androidx.lifecycle.whenStarted import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView @@ -98,10 +97,8 @@ class RssArticlesFragment : VMBaseFragment(R.layout.fragme val rssUrl = activityViewModel.url ?: return articlesFlowJob?.cancel() articlesFlowJob = lifecycleScope.launch { - lifecycle.whenStarted { - appDb.rssArticleDao.flowByOriginSort(rssUrl, viewModel.sortName).collect { - adapter.setItems(it) - } + appDb.rssArticleDao.flowByOriginSort(rssUrl, viewModel.sortName).collect { + adapter.setItems(it) } } } diff --git a/app/src/main/java/io/legado/app/ui/rss/subscription/RuleSubActivity.kt b/app/src/main/java/io/legado/app/ui/rss/subscription/RuleSubActivity.kt index 33c5434e3..50ab2871f 100644 --- a/app/src/main/java/io/legado/app/ui/rss/subscription/RuleSubActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/subscription/RuleSubActivity.kt @@ -4,7 +4,6 @@ import android.os.Bundle import android.view.Menu import android.view.MenuItem import androidx.core.view.isGone -import androidx.lifecycle.whenStarted import androidx.recyclerview.widget.ItemTouchHelper import io.legado.app.R import io.legado.app.base.BaseActivity @@ -63,11 +62,9 @@ class RuleSubActivity : BaseActivity(), private fun initData() { launch { - lifecycle.whenStarted { - appDb.ruleSubDao.flowAll().collect { - binding.tvEmptyMsg.isGone = it.isNotEmpty() - adapter.setItems(it) - } + appDb.ruleSubDao.flowAll().collect { + binding.tvEmptyMsg.isGone = it.isNotEmpty() + adapter.setItems(it) } } } diff --git a/app/src/main/java/io/legado/app/ui/welcome/WelcomeActivity.kt b/app/src/main/java/io/legado/app/ui/welcome/WelcomeActivity.kt index 75e9adc12..be364818e 100644 --- a/app/src/main/java/io/legado/app/ui/welcome/WelcomeActivity.kt +++ b/app/src/main/java/io/legado/app/ui/welcome/WelcomeActivity.kt @@ -9,7 +9,7 @@ import io.legado.app.data.appDb import io.legado.app.databinding.ActivityWelcomeBinding import io.legado.app.help.AppConfig import io.legado.app.help.coroutine.Coroutine -import io.legado.app.help.storage.BookWebDav +import io.legado.app.help.storage.AppWebDav import io.legado.app.lib.theme.accentColor import io.legado.app.ui.book.read.ReadBookActivity import io.legado.app.ui.main.MainActivity @@ -37,7 +37,7 @@ open class WelcomeActivity : BaseActivity() { Coroutine.async { val books = appDb.bookDao.all books.forEach { book -> - BookWebDav.getBookProgress(book)?.let { bookProgress -> + AppWebDav.getBookProgress(book)?.let { bookProgress -> if (bookProgress.durChapterIndex > book.durChapterIndex || (bookProgress.durChapterIndex == book.durChapterIndex && bookProgress.durChapterPos > book.durChapterPos)