mirror of
https://github.com/gedoor/legado.git
synced 2024-09-01 09:34:25 +08:00
优化
This commit is contained in:
parent
536577b869
commit
a0860ca956
@ -95,6 +95,7 @@ object PreferKey {
|
||||
const val uploadRule = "uploadRule"
|
||||
const val tocUiUseReplace = "tocUiUseReplace"
|
||||
const val enableReadRecord = "enableReadRecord"
|
||||
const val localBookImportSort = "localBookImportSort"
|
||||
const val customWelcome = "customWelcome"
|
||||
const val welcomeImage = "welcomeImagePath"
|
||||
const val welcomeImageDark = "welcomeImagePathDark"
|
||||
@ -103,6 +104,7 @@ object PreferKey {
|
||||
const val welcomeShowIcon = "welcomeShowIcon"
|
||||
const val welcomeShowIconDark = "welcomeShowIconDark"
|
||||
|
||||
|
||||
const val cPrimary = "colorPrimary"
|
||||
const val cAccent = "colorAccent"
|
||||
const val cBackground = "colorBackground"
|
||||
|
@ -12,6 +12,7 @@ import androidx.documentfile.provider.DocumentFile
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import io.legado.app.R
|
||||
import io.legado.app.base.VMBaseActivity
|
||||
import io.legado.app.constant.PreferKey
|
||||
import io.legado.app.data.appDb
|
||||
import io.legado.app.databinding.ActivityImportBookBinding
|
||||
import io.legado.app.databinding.DialogEditTextBinding
|
||||
@ -80,18 +81,9 @@ class ImportBookActivity : VMBaseActivity<ActivityImportBookBinding, ImportBookV
|
||||
R.id.menu_select_folder -> selectFolder.launch()
|
||||
R.id.menu_scan_folder -> scanFolder()
|
||||
R.id.menu_import_file_name -> alertImportFileName()
|
||||
R.id.menu_sort_name -> {
|
||||
viewModel.sort = 0
|
||||
upSort()
|
||||
}
|
||||
R.id.menu_sort_size -> {
|
||||
viewModel.sort = 1
|
||||
upSort()
|
||||
}
|
||||
R.id.menu_sort_time -> {
|
||||
viewModel.sort = 2
|
||||
upSort()
|
||||
}
|
||||
R.id.menu_sort_name -> upSort(0)
|
||||
R.id.menu_sort_size -> upSort(1)
|
||||
R.id.menu_sort_time -> upSort(2)
|
||||
}
|
||||
return super.onCompatOptionsItemSelected(item)
|
||||
}
|
||||
@ -203,7 +195,9 @@ class ImportBookActivity : VMBaseActivity<ActivityImportBookBinding, ImportBookV
|
||||
.request()
|
||||
}
|
||||
|
||||
private fun upSort() {
|
||||
private fun upSort(sort: Int) {
|
||||
viewModel.sort = sort
|
||||
putPrefInt(PreferKey.localBookImportSort, sort)
|
||||
if (scanDocJob?.isCancelled == true || scanDocJob?.isCompleted == true) {
|
||||
viewModel.dataCallback?.setItems(adapter.getItems())
|
||||
}
|
||||
|
@ -4,11 +4,9 @@ import android.app.Application
|
||||
import android.net.Uri
|
||||
import androidx.documentfile.provider.DocumentFile
|
||||
import io.legado.app.base.BaseViewModel
|
||||
import io.legado.app.constant.PreferKey
|
||||
import io.legado.app.model.localBook.LocalBook
|
||||
import io.legado.app.utils.DocumentUtils
|
||||
import io.legado.app.utils.FileDoc
|
||||
import io.legado.app.utils.isContentScheme
|
||||
import io.legado.app.utils.toastOnUi
|
||||
import io.legado.app.utils.*
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers.IO
|
||||
import kotlinx.coroutines.Dispatchers.Main
|
||||
@ -24,7 +22,7 @@ import java.util.*
|
||||
|
||||
class ImportBookViewModel(application: Application) : BaseViewModel(application) {
|
||||
private val bookFileRegex = Regex("(?i).*\\.(txt|epub|umd)")
|
||||
var sort = 0
|
||||
var sort = context.getPrefInt(PreferKey.localBookImportSort)
|
||||
var dataCallback: DataCallback? = null
|
||||
var dataFlowStart: (() -> Unit)? = null
|
||||
val dataFlow = callbackFlow<List<FileDoc>> {
|
||||
|
Loading…
Reference in New Issue
Block a user