LicensesController: Move item init to IO thread (#6020)

This commit is contained in:
Ivan Iskandar 2021-10-03 23:00:00 +07:00 committed by GitHub
parent dc92ffed87
commit b0f87fdd21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 8 deletions

View File

@ -9,6 +9,8 @@ import eu.davidea.flexibleadapter.FlexibleAdapter
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.databinding.LicensesControllerBinding
import eu.kanade.tachiyomi.ui.base.controller.BaseController
import eu.kanade.tachiyomi.util.lang.launchUI
import eu.kanade.tachiyomi.util.lang.withIOContext
import eu.kanade.tachiyomi.util.system.openInBrowser
class LicensesController :
@ -30,16 +32,26 @@ class LicensesController :
padding()
}
}
binding.progress.applyInsetter {
type(navigationBars = true) {
padding()
}
}
binding.recycler.layoutManager = LinearLayoutManager(view.context)
adapter = LicensesAdapter(this)
binding.recycler.adapter = adapter
val licenseItems = Libs(view.context).libraries
viewScope.launchUI {
val licenseItems = withIOContext {
Libs(view.context).libraries
.sortedBy { it.libraryName.lowercase() }
.map { LicensesItem(it) }
}
binding.progress.hide()
adapter?.updateDataSet(licenseItems)
}
}
override fun onDestroyView(view: View) {
adapter = null

View File

@ -1,7 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.progressindicator.CircularProgressIndicator
android:id="@+id/progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:indeterminate="true" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
tools:listitem="@layout/licenses_item" />
</RelativeLayout>