pull/83/head
kunfei 5 years ago
parent 81eda56ea9
commit 985a53f862
  1. 2
      app/build.gradle
  2. 13
      app/src/main/java/io/legado/app/ui/importbook/ImportBookActivity.kt
  3. 4
      app/src/main/res/layout/activity_import_book.xml

@ -117,7 +117,7 @@ dependencies {
implementation 'com.google.android:flexbox:1.1.0' implementation 'com.google.android:flexbox:1.1.0'
//lifecycle //lifecycle
def lifecycle_version = '2.1.0' def lifecycle_version = '2.2.0'
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version" implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version" implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"

@ -13,12 +13,14 @@ import io.legado.app.base.VMBaseActivity
import io.legado.app.help.AppConfig import io.legado.app.help.AppConfig
import io.legado.app.utils.getViewModel import io.legado.app.utils.getViewModel
import kotlinx.android.synthetic.main.activity_import_book.* import kotlinx.android.synthetic.main.activity_import_book.*
import java.io.File
class ImportBookActivity : VMBaseActivity<ImportBookViewModel>(R.layout.activity_import_book) { class ImportBookActivity : VMBaseActivity<ImportBookViewModel>(R.layout.activity_import_book) {
private val requestCodeSelectFolder = 342 private val requestCodeSelectFolder = 342
private var rootDoc: DocumentFile? = null private var rootDoc: DocumentFile? = null
private val subDirs = arrayListOf<String>() private val subDirs = arrayListOf<String>()
private lateinit var importBookAdapter: ImportBookAdapter
override val viewModel: ImportBookViewModel override val viewModel: ImportBookViewModel
get() = getViewModel(ImportBookViewModel::class.java) get() = getViewModel(ImportBookViewModel::class.java)
@ -42,15 +44,26 @@ class ImportBookActivity : VMBaseActivity<ImportBookViewModel>(R.layout.activity
private fun initView() { private fun initView() {
recycler_view.layoutManager = LinearLayoutManager(this) recycler_view.layoutManager = LinearLayoutManager(this)
importBookAdapter = ImportBookAdapter(this)
recycler_view.adapter = importBookAdapter
} }
private fun upPath() { private fun upPath() {
AppConfig.importBookPath?.let { AppConfig.importBookPath?.let {
val rootUri = Uri.parse(it) val rootUri = Uri.parse(it)
rootDoc = DocumentFile.fromTreeUri(this, rootUri) rootDoc = DocumentFile.fromTreeUri(this, rootUri)
subDirs.clear()
tv_path.text = getPath()
} }
} }
private fun getPath(): String {
rootDoc?.let {
return it.name + File.separator + subDirs.joinToString(File.separator)
}
return ""
}
private fun selectImportFolder() { private fun selectImportFolder() {
try { try {
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT_TREE) val intent = Intent(Intent.ACTION_OPEN_DOCUMENT_TREE)

@ -21,7 +21,7 @@
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <TextView
android:id="@+id/file_category_tv_path" android:id="@+id/tv_path"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
@ -33,7 +33,7 @@
tools:text="/" /> tools:text="/" />
<io.legado.app.lib.theme.view.ATEStrokeTextView <io.legado.app.lib.theme.view.ATEStrokeTextView
android:id="@+id/file_category_tv_back_last" android:id="@+id/tv_go_back"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"

Loading…
Cancel
Save