mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 18:31:51 +01:00
LicensesController: Move item init to IO thread (#6020)
This commit is contained in:
parent
dc92ffed87
commit
b0f87fdd21
@ -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
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user