Fixed crash when using a reader mode from main tachi

The else case will default to R2L reader when the index is out of range
This commit is contained in:
Jays2Kings 2021-07-09 22:10:33 -04:00
parent c438236bf7
commit 784bd22989
2 changed files with 12 additions and 8 deletions

View File

@ -832,11 +832,11 @@ class ReaderActivity :
val noDefault = manga.viewer == -1
val mangaViewer = presenter.getMangaViewer()
val newViewer = when (mangaViewer) {
RIGHT_TO_LEFT -> R2LPagerViewer(this)
LEFT_TO_RIGHT -> L2RPagerViewer(this)
VERTICAL -> VerticalPagerViewer(this)
WEBTOON -> WebtoonViewer(this)
VERTICAL_PLUS -> WebtoonViewer(this, hasMargins = true)
else -> L2RPagerViewer(this)
else -> R2LPagerViewer(this)
}
if (noDefault && presenter.manga?.viewer!! > 0) {

View File

@ -102,14 +102,18 @@ class MaterialSpinnerView @JvmOverloads constructor(context: Context, attrs: Att
}
fun setSelection(selection: Int) {
popup?.menu?.get(selectedPosition)?.let {
it.icon = ContextCompat.getDrawable(context, R.drawable.ic_blank_24dp)
it.title = entries[selectedPosition]
if (selectedPosition >= 0 && selectedPosition < popup?.menu?.size() ?: 0) {
popup?.menu?.get(selectedPosition)?.let {
it.icon = ContextCompat.getDrawable(context, R.drawable.ic_blank_24dp)
it.title = entries[selectedPosition]
}
}
selectedPosition = selection
popup?.menu?.get(selectedPosition)?.let {
it.icon = tintedCheck()
it.title = it.title?.tintText(blendedAccent)
if (selectedPosition >= 0 && selectedPosition < popup?.menu?.size() ?: 0) {
popup?.menu?.get(selectedPosition)?.let {
it.icon = tintedCheck()
it.title = it.title?.tintText(blendedAccent)
}
}
binding.detailView.text = entries.getOrNull(selection).orEmpty()
}