feat: 优化代码

pull/172/head
kunfei 5 years ago
parent 2d9f041eac
commit cd3a9044df
  1. 8
      app/src/main/java/io/legado/app/ui/book/local/ImportBookActivity.kt
  2. 6
      app/src/main/java/io/legado/app/ui/book/local/ImportBookAdapter.kt

@ -213,8 +213,12 @@ class ImportBookActivity : VMBaseActivity<ImportBookViewModel>(R.layout.activity
} }
@Synchronized @Synchronized
override fun nextDoc(doc: DocumentFile) { override fun nextDoc(uri: Uri) {
subDocs.add(doc) if (uri.toString().isContentPath()) {
subDocs.add(DocumentFile.fromSingleUri(this, uri)!!)
} else {
path = uri.toString()
}
upPath() upPath()
} }

@ -1,7 +1,7 @@
package io.legado.app.ui.book.local package io.legado.app.ui.book.local
import android.content.Context import android.content.Context
import androidx.documentfile.provider.DocumentFile import android.net.Uri
import io.legado.app.R import io.legado.app.R
import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.ItemViewHolder
import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.base.adapter.SimpleRecyclerAdapter
@ -101,7 +101,7 @@ class ImportBookAdapter(context: Context, val callBack: CallBack) :
holder.itemView.onClick { holder.itemView.onClick {
getItem(holder.layoutPosition)?.let { getItem(holder.layoutPosition)?.let {
if (it.isDir) { if (it.isDir) {
callBack.nextDoc(DocumentFile.fromSingleUri(context, it.uri)!!) callBack.nextDoc(it.uri)
} else if (!bookshelf.contains(it.uri.toString())) { } else if (!bookshelf.contains(it.uri.toString())) {
if (!selectedUris.contains(it.uri.toString())) { if (!selectedUris.contains(it.uri.toString())) {
selectedUris.add(it.uri.toString()) selectedUris.add(it.uri.toString())
@ -116,7 +116,7 @@ class ImportBookAdapter(context: Context, val callBack: CallBack) :
} }
interface CallBack { interface CallBack {
fun nextDoc(doc: DocumentFile) fun nextDoc(uri: Uri)
fun upCountView() fun upCountView()
} }

Loading…
Cancel
Save