Catch HttpException in widgets as well
This commit is contained in:
@@ -16,7 +16,6 @@ import org.koitharu.kotatsu.base.domain.MangaIntent
|
||||
import org.koitharu.kotatsu.history.domain.HistoryRepository
|
||||
import org.koitharu.kotatsu.parsers.model.Manga
|
||||
import org.koitharu.kotatsu.utils.ext.requireBitmap
|
||||
import java.io.IOException
|
||||
|
||||
class RecentListFactory(
|
||||
private val context: Context,
|
||||
@@ -50,8 +49,8 @@ class RecentListFactory(
|
||||
override fun getViewAt(position: Int): RemoteViews {
|
||||
val views = RemoteViews(context.packageName, R.layout.item_recent)
|
||||
val item = dataSet[position]
|
||||
try {
|
||||
val cover = coil.executeBlocking(
|
||||
runCatching {
|
||||
coil.executeBlocking(
|
||||
ImageRequest.Builder(context)
|
||||
.data(item.coverUrl)
|
||||
.size(coverSize)
|
||||
@@ -59,8 +58,9 @@ class RecentListFactory(
|
||||
.transformations(transformation)
|
||||
.build()
|
||||
).requireBitmap()
|
||||
}.onSuccess { cover ->
|
||||
views.setImageViewBitmap(R.id.imageView_cover, cover)
|
||||
} catch (e: IOException) {
|
||||
}.onFailure {
|
||||
views.setImageViewResource(R.id.imageView_cover, R.drawable.ic_placeholder)
|
||||
}
|
||||
val intent = Intent()
|
||||
|
||||
@@ -17,7 +17,6 @@ import org.koitharu.kotatsu.core.prefs.AppWidgetConfig
|
||||
import org.koitharu.kotatsu.favourites.domain.FavouritesRepository
|
||||
import org.koitharu.kotatsu.parsers.model.Manga
|
||||
import org.koitharu.kotatsu.utils.ext.requireBitmap
|
||||
import java.io.IOException
|
||||
|
||||
class ShelfListFactory(
|
||||
private val context: Context,
|
||||
@@ -61,8 +60,8 @@ class ShelfListFactory(
|
||||
val views = RemoteViews(context.packageName, R.layout.item_shelf)
|
||||
val item = dataSet[position]
|
||||
views.setTextViewText(R.id.textView_title, item.title)
|
||||
try {
|
||||
val cover = coil.executeBlocking(
|
||||
runCatching {
|
||||
coil.executeBlocking(
|
||||
ImageRequest.Builder(context)
|
||||
.data(item.coverUrl)
|
||||
.size(coverSize)
|
||||
@@ -70,8 +69,9 @@ class ShelfListFactory(
|
||||
.transformations(transformation)
|
||||
.build()
|
||||
).requireBitmap()
|
||||
}.onSuccess { cover ->
|
||||
views.setImageViewBitmap(R.id.imageView_cover, cover)
|
||||
} catch (e: IOException) {
|
||||
}.onFailure {
|
||||
views.setImageViewResource(R.id.imageView_cover, R.drawable.ic_placeholder)
|
||||
}
|
||||
val intent = Intent()
|
||||
|
||||
Reference in New Issue
Block a user