feat: 优化代码

pull/154/head
kunfei 5 years ago
parent dbdc079141
commit 8ddcb73892
  1. 1
      app/build.gradle
  2. 7
      app/src/main/java/io/legado/app/ui/book/local/ImportBookActivity.kt

@ -139,7 +139,6 @@ dependencies {
def room_version = '2.2.4' def room_version = '2.2.4'
implementation "androidx.room:room-runtime:$room_version" implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version" kapt "androidx.room:room-compiler:$room_version"
kapt "android.arch.persistence.room:compiler:$room_version"
//paging //paging
implementation 'androidx.paging:paging-runtime:2.1.1' implementation 'androidx.paging:paging-runtime:2.1.1'

@ -40,7 +40,8 @@ class ImportBookActivity : VMBaseActivity<ImportBookViewModel>(R.layout.activity
private val subDocs = arrayListOf<DocumentFile>() private val subDocs = arrayListOf<DocumentFile>()
private lateinit var adapter: ImportBookAdapter private lateinit var adapter: ImportBookAdapter
private var localUriLiveData: LiveData<List<String>>? = null private var localUriLiveData: LiveData<List<String>>? = null
private var path = FileUtils.getSdCardPath() private var sdPath = FileUtils.getSdCardPath()
private var path = sdPath
override val viewModel: ImportBookViewModel override val viewModel: ImportBookViewModel
get() = getViewModel(ImportBookViewModel::class.java) get() = getViewModel(ImportBookViewModel::class.java)
@ -159,7 +160,7 @@ class ImportBookActivity : VMBaseActivity<ImportBookViewModel>(R.layout.activity
} }
} }
} ?: let { } ?: let {
tv_path.text = path tv_path.text = path.replace(sdPath, "SD")
val docList = arrayListOf<DocItem>() val docList = arrayListOf<DocItem>()
File(path).listFiles()?.forEach { File(path).listFiles()?.forEach {
if (it.isDirectory) { if (it.isDirectory) {
@ -228,7 +229,7 @@ class ImportBookActivity : VMBaseActivity<ImportBookViewModel>(R.layout.activity
@Synchronized @Synchronized
private fun goBackDir(): Boolean { private fun goBackDir(): Boolean {
if (rootDoc == null) { if (rootDoc == null) {
if (path != FileUtils.getSdCardPath()) { if (path != sdPath) {
File(path).parent?.let { File(path).parent?.let {
path = it path = it
upPath() upPath()

Loading…
Cancel
Save