Fix crashes
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
package org.koitharu.kotatsu.core.util.ext
|
||||
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
|
||||
fun Toolbar.setNavigationIconSafe(@DrawableRes iconRes: Int, retry: Boolean = true) {
|
||||
try {
|
||||
setNavigationIcon(iconRes)
|
||||
} catch (e: IllegalStateException) {
|
||||
if (retry) {
|
||||
post { setNavigationIconSafe(iconRes, retry = false) }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,6 +43,7 @@ import org.koitharu.kotatsu.core.util.ext.measureHeight
|
||||
import org.koitharu.kotatsu.core.util.ext.observe
|
||||
import org.koitharu.kotatsu.core.util.ext.observeEvent
|
||||
import org.koitharu.kotatsu.core.util.ext.setNavigationBarTransparentCompat
|
||||
import org.koitharu.kotatsu.core.util.ext.setNavigationIconSafe
|
||||
import org.koitharu.kotatsu.core.util.ext.textAndVisible
|
||||
import org.koitharu.kotatsu.databinding.ActivityDetailsBinding
|
||||
import org.koitharu.kotatsu.details.service.MangaPrefetchService
|
||||
@@ -211,7 +212,7 @@ class DetailsActivity :
|
||||
}
|
||||
if (isExpanded) {
|
||||
toolbar.addMenuProvider(chaptersMenuProvider)
|
||||
toolbar.setNavigationIcon(materialR.drawable.abc_ic_clear_material)
|
||||
toolbar.setNavigationIconSafe(materialR.drawable.abc_ic_clear_material)
|
||||
} else {
|
||||
toolbar.removeMenuProvider(chaptersMenuProvider)
|
||||
toolbar.navigationIcon = null
|
||||
|
||||
@@ -48,7 +48,7 @@ class RecentListFactory(
|
||||
|
||||
override fun getViewAt(position: Int): RemoteViews {
|
||||
val views = RemoteViews(context.packageName, R.layout.item_recent)
|
||||
val item = dataSet[position]
|
||||
val item = dataSet.getOrNull(position) ?: return views
|
||||
runCatching {
|
||||
coil.executeBlocking(
|
||||
ImageRequest.Builder(context)
|
||||
|
||||
@@ -58,7 +58,7 @@ class ShelfListFactory(
|
||||
|
||||
override fun getViewAt(position: Int): RemoteViews {
|
||||
val views = RemoteViews(context.packageName, R.layout.item_shelf)
|
||||
val item = dataSet[position]
|
||||
val item = dataSet.getOrNull(position) ?: return views
|
||||
views.setTextViewText(R.id.textView_title, item.title)
|
||||
runCatching {
|
||||
coil.executeBlocking(
|
||||
|
||||
Reference in New Issue
Block a user