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

@ -50,11 +50,23 @@
tools:ignore="UnusedAttribute" /> tools:ignore="UnusedAttribute" />
</LinearLayout> </LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view" android:id="@+id/recycler_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="match_parent" />
android:layout_weight="1" />
<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 <RelativeLayout

Loading…
Cancel
Save