Fix crash on widgets update
This commit is contained in:
@@ -73,7 +73,7 @@ class KotatsuApp : Application() {
|
||||
appWidgetModule,
|
||||
suggestionsModule,
|
||||
shikimoriModule,
|
||||
bookmarksModule,
|
||||
bookmarksModule
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -91,8 +91,7 @@ class KotatsuApp : Application() {
|
||||
ReportField.PHONE_MODEL,
|
||||
ReportField.CRASH_CONFIGURATION,
|
||||
ReportField.STACK_TRACE,
|
||||
ReportField.CUSTOM_DATA,
|
||||
ReportField.SHARED_PREFERENCES,
|
||||
ReportField.SHARED_PREFERENCES
|
||||
)
|
||||
dialog {
|
||||
text = getString(R.string.crash_text)
|
||||
|
||||
@@ -15,12 +15,13 @@ import org.koitharu.kotatsu.R
|
||||
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.parsers.util.replaceWith
|
||||
import org.koitharu.kotatsu.utils.ext.requireBitmap
|
||||
|
||||
class RecentListFactory(
|
||||
private val context: Context,
|
||||
private val historyRepository: HistoryRepository,
|
||||
private val coil: ImageLoader
|
||||
private val coil: ImageLoader,
|
||||
) : RemoteViewsService.RemoteViewsFactory {
|
||||
|
||||
private val dataSet = ArrayList<Manga>()
|
||||
@@ -29,7 +30,7 @@ class RecentListFactory(
|
||||
)
|
||||
private val coverSize = Size(
|
||||
context.resources.getDimensionPixelSize(R.dimen.widget_cover_width),
|
||||
context.resources.getDimensionPixelSize(R.dimen.widget_cover_height),
|
||||
context.resources.getDimensionPixelSize(R.dimen.widget_cover_height)
|
||||
)
|
||||
|
||||
override fun onCreate() = Unit
|
||||
@@ -39,9 +40,8 @@ class RecentListFactory(
|
||||
override fun getItemId(position: Int) = dataSet[position].id
|
||||
|
||||
override fun onDataSetChanged() {
|
||||
dataSet.clear()
|
||||
val data = runBlocking { historyRepository.getList(0, 10) }
|
||||
dataSet.addAll(data)
|
||||
dataSet.replaceWith(data)
|
||||
}
|
||||
|
||||
override fun hasStableIds() = true
|
||||
|
||||
@@ -16,6 +16,7 @@ import org.koitharu.kotatsu.base.domain.MangaIntent
|
||||
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.parsers.util.replaceWith
|
||||
import org.koitharu.kotatsu.utils.ext.requireBitmap
|
||||
|
||||
class ShelfListFactory(
|
||||
@@ -32,7 +33,7 @@ class ShelfListFactory(
|
||||
)
|
||||
private val coverSize = Size(
|
||||
context.resources.getDimensionPixelSize(R.dimen.widget_cover_width),
|
||||
context.resources.getDimensionPixelSize(R.dimen.widget_cover_height),
|
||||
context.resources.getDimensionPixelSize(R.dimen.widget_cover_height)
|
||||
)
|
||||
|
||||
override fun onCreate() = Unit
|
||||
@@ -42,7 +43,6 @@ class ShelfListFactory(
|
||||
override fun getItemId(position: Int) = dataSet[position].id
|
||||
|
||||
override fun onDataSetChanged() {
|
||||
dataSet.clear()
|
||||
val data = runBlocking {
|
||||
val category = config.categoryId
|
||||
if (category == 0L) {
|
||||
@@ -51,7 +51,7 @@ class ShelfListFactory(
|
||||
favouritesRepository.getManga(category)
|
||||
}
|
||||
}
|
||||
dataSet.addAll(data)
|
||||
dataSet.replaceWith(data)
|
||||
}
|
||||
|
||||
override fun hasStableIds() = true
|
||||
@@ -85,4 +85,4 @@ class ShelfListFactory(
|
||||
override fun getViewTypeCount() = 1
|
||||
|
||||
override fun onDestroy() = Unit
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user