pull/83/head
kunfei 5 years ago
parent 3c9d0cf03e
commit 064f872cdb
  1. 30
      app/src/main/java/io/legado/app/ui/importbook/ImportBookActivity.kt
  2. 18
      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,17 +104,23 @@ class ImportBookActivity : VMBaseActivity<ImportBookViewModel>(R.layout.activity
} }
tv_path.text = path tv_path.text = path
importBookAdapter.selectedUris.clear() importBookAdapter.selectedUris.clear()
importBookAdapter.clearItems()
val docList = arrayListOf<DocumentFile>() rotate_loading.show()
lastDoc.listFiles().forEach { launch(IO) {
if (it.isDirectory && it.name?.startsWith(".") == false) { val docList = arrayListOf<DocumentFile>()
docList.add(it) lastDoc.listFiles().forEach {
} else if (it.name?.endsWith(".txt", true) == true) { if (it.isDirectory && it.name?.startsWith(".") == false) {
docList.add(it) docList.add(it)
} else if (it.name?.endsWith(".txt", true) == true) {
docList.add(it)
}
}
docList.sortWith(compareBy({ !it.isDirectory }, { it.name }))
withContext(Main) {
rotate_loading.hide()
importBookAdapter.setItems(docList)
} }
} }
docList.sortWith(compareBy({ !it.isDirectory }, { it.name }))
importBookAdapter.setItems(docList)
} }
} }

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

Loading…
Cancel
Save