|
|
|
|
@ -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
|
|
|
|
|
|