mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-19 03:39:18 +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.R
|
||||||
import eu.kanade.tachiyomi.databinding.LicensesControllerBinding
|
import eu.kanade.tachiyomi.databinding.LicensesControllerBinding
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.BaseController
|
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
|
import eu.kanade.tachiyomi.util.system.openInBrowser
|
||||||
|
|
||||||
class LicensesController :
|
class LicensesController :
|
||||||
@ -30,16 +32,26 @@ class LicensesController :
|
|||||||
padding()
|
padding()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
binding.progress.applyInsetter {
|
||||||
|
type(navigationBars = true) {
|
||||||
|
padding()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
binding.recycler.layoutManager = LinearLayoutManager(view.context)
|
binding.recycler.layoutManager = LinearLayoutManager(view.context)
|
||||||
adapter = LicensesAdapter(this)
|
adapter = LicensesAdapter(this)
|
||||||
binding.recycler.adapter = adapter
|
binding.recycler.adapter = adapter
|
||||||
|
|
||||||
val licenseItems = Libs(view.context).libraries
|
viewScope.launchUI {
|
||||||
|
val licenseItems = withIOContext {
|
||||||
|
Libs(view.context).libraries
|
||||||
.sortedBy { it.libraryName.lowercase() }
|
.sortedBy { it.libraryName.lowercase() }
|
||||||
.map { LicensesItem(it) }
|
.map { LicensesItem(it) }
|
||||||
|
}
|
||||||
|
binding.progress.hide()
|
||||||
adapter?.updateDataSet(licenseItems)
|
adapter?.updateDataSet(licenseItems)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onDestroyView(view: View) {
|
override fun onDestroyView(view: View) {
|
||||||
adapter = null
|
adapter = null
|
||||||
|
@ -1,7 +1,21 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?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"
|
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:id="@+id/recycler"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:clipToPadding="false"
|
||||||
tools:listitem="@layout/licenses_item" />
|
tools:listitem="@layout/licenses_item" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
Loading…
Reference in New Issue
Block a user