pull/83/head
kunfei 5 years ago
parent 3c9d0cf03e
commit 064f872cdb
  1. 14
      app/src/main/java/io/legado/app/ui/importbook/ImportBookActivity.kt
  2. 16
      app/src/main/res/layout/activity_import_book.xml

@ -15,8 +15,13 @@ import io.legado.app.App
import io.legado.app.R
import io.legado.app.base.VMBaseActivity
import io.legado.app.help.AppConfig
import io.legado.app.lib.theme.accentColor
import io.legado.app.utils.getViewModel
import kotlinx.android.synthetic.main.activity_import_book.*
import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.jetbrains.anko.sdk27.listeners.onClick
import java.io.File
@ -55,6 +60,7 @@ class ImportBookActivity : VMBaseActivity<ImportBookViewModel>(R.layout.activity
recycler_view.layoutManager = LinearLayoutManager(this)
importBookAdapter = ImportBookAdapter(this, this)
recycler_view.adapter = importBookAdapter
rotate_loading.loadingColor = accentColor
}
private fun initEvent() {
@ -98,7 +104,9 @@ class ImportBookActivity : VMBaseActivity<ImportBookViewModel>(R.layout.activity
}
tv_path.text = path
importBookAdapter.selectedUris.clear()
importBookAdapter.clearItems()
rotate_loading.show()
launch(IO) {
val docList = arrayListOf<DocumentFile>()
lastDoc.listFiles().forEach {
if (it.isDirectory && it.name?.startsWith(".") == false) {
@ -108,9 +116,13 @@ class ImportBookActivity : VMBaseActivity<ImportBookViewModel>(R.layout.activity
}
}
docList.sortWith(compareBy({ !it.isDirectory }, { it.name }))
withContext(Main) {
rotate_loading.hide()
importBookAdapter.setItems(docList)
}
}
}
}
private fun selectImportFolder() {
try {

@ -50,11 +50,23 @@
tools:ignore="UnusedAttribute" />
</LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
android:layout_height="match_parent" />
<io.legado.app.ui.widget.anima.RotateLoading
android:id="@+id/rotate_loading"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_gravity="center" />
</FrameLayout>
<!--文件点击按钮-->
<RelativeLayout

Loading…
Cancel
Save