Utilize more KTX extensions (#7348)

This commit is contained in:
Taco
2022-06-20 22:54:42 -04:00
committed by GitHub
parent cd5bcc3673
commit c2520bff12
20 changed files with 89 additions and 98 deletions
@@ -19,7 +19,9 @@ import androidx.preference.Preference
import androidx.preference.PreferenceGroupAdapter
import androidx.preference.PreferenceManager
import androidx.preference.PreferenceScreen
import androidx.preference.get
import androidx.preference.getOnBindEditTextListener
import androidx.preference.isNotEmpty
import androidx.recyclerview.widget.LinearLayoutManager
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.preference.SharedPreferencesDataStore
@@ -111,8 +113,8 @@ class SourcePreferencesController(bundle: Bundle? = null) :
source.setupPreferenceScreen(newScreen)
// Reparent the preferences
while (newScreen.preferenceCount != 0) {
val pref = newScreen.getPreference(0)
while (newScreen.isNotEmpty()) {
val pref = newScreen[0]
pref.isIconSpaceReserved = false
pref.order = Int.MAX_VALUE // reset to default order
@@ -143,7 +145,7 @@ class SourcePreferencesController(bundle: Bundle? = null) :
val screen = preference.parent!!
lastOpenPreferencePosition = (0 until screen.preferenceCount).indexOfFirst {
screen.getPreference(it) === preference
screen[it] === preference
}
val f = when (preference) {
@@ -169,7 +171,7 @@ class SourcePreferencesController(bundle: Bundle? = null) :
override fun <T : Preference> findPreference(key: CharSequence): T? {
// We track [lastOpenPreferencePosition] when displaying the dialog
// [key] isn't useful since there may be duplicates
return preferenceScreen!!.getPreference(lastOpenPreferencePosition!!) as T
return preferenceScreen!![lastOpenPreferencePosition!!] as T
}
}
@@ -8,6 +8,7 @@ import android.view.MenuInflater
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import androidx.core.view.get
import androidx.core.view.isVisible
import androidx.core.view.updatePadding
import androidx.recyclerview.widget.GridLayoutManager
@@ -202,7 +203,7 @@ open class BrowseSourceController(bundle: Bundle) :
numColumnsJob?.cancel()
var oldPosition = RecyclerView.NO_POSITION
val oldRecycler = binding.catalogueView.getChildAt(1)
val oldRecycler = binding.catalogueView[1]
if (oldRecycler is RecyclerView) {
oldPosition = (oldRecycler.layoutManager as LinearLayoutManager).findFirstVisibleItemPosition()
oldRecycler.adapter = null
@@ -6,6 +6,7 @@ import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.view.get
import eu.davidea.flexibleadapter.FlexibleAdapter
import eu.davidea.flexibleadapter.items.IFlexible
import eu.kanade.tachiyomi.databinding.SourceFilterSheetBinding
@@ -55,7 +56,7 @@ class SourceFilterSheet(
init {
recycler.adapter = adapter
recycler.setHasFixedSize(true)
(binding.root.getChildAt(1) as ViewGroup).addView(recycler)
(binding.root[1] as ViewGroup).addView(recycler)
addView(binding.root)
binding.filterBtn.setOnClickListener { onFilterClicked() }
binding.resetBtn.setOnClickListener { onResetClicked() }