|
|
|
@ -7,6 +7,8 @@ import android.widget.RemoteViewsService
|
|
|
|
import coil.ImageLoader
|
|
|
|
import coil.ImageLoader
|
|
|
|
import coil.executeBlocking
|
|
|
|
import coil.executeBlocking
|
|
|
|
import coil.request.ImageRequest
|
|
|
|
import coil.request.ImageRequest
|
|
|
|
|
|
|
|
import coil.size.Size
|
|
|
|
|
|
|
|
import coil.transform.RoundedCornersTransformation
|
|
|
|
import kotlinx.coroutines.runBlocking
|
|
|
|
import kotlinx.coroutines.runBlocking
|
|
|
|
import org.koitharu.kotatsu.R
|
|
|
|
import org.koitharu.kotatsu.R
|
|
|
|
import org.koitharu.kotatsu.base.domain.MangaIntent
|
|
|
|
import org.koitharu.kotatsu.base.domain.MangaIntent
|
|
|
|
@ -20,14 +22,20 @@ class ShelfListFactory(
|
|
|
|
private val context: Context,
|
|
|
|
private val context: Context,
|
|
|
|
private val favouritesRepository: FavouritesRepository,
|
|
|
|
private val favouritesRepository: FavouritesRepository,
|
|
|
|
private val coil: ImageLoader,
|
|
|
|
private val coil: ImageLoader,
|
|
|
|
widgetId: Int
|
|
|
|
widgetId: Int,
|
|
|
|
) : RemoteViewsService.RemoteViewsFactory {
|
|
|
|
) : RemoteViewsService.RemoteViewsFactory {
|
|
|
|
|
|
|
|
|
|
|
|
private val dataSet = ArrayList<Manga>()
|
|
|
|
private val dataSet = ArrayList<Manga>()
|
|
|
|
private val config = AppWidgetConfig(context, widgetId)
|
|
|
|
private val config = AppWidgetConfig(context, widgetId)
|
|
|
|
|
|
|
|
private val transformation = RoundedCornersTransformation(
|
|
|
|
|
|
|
|
context.resources.getDimension(R.dimen.appwidget_corner_radius_inner)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
private val coverSize = Size(
|
|
|
|
|
|
|
|
context.resources.getDimensionPixelSize(R.dimen.widget_cover_width),
|
|
|
|
|
|
|
|
context.resources.getDimensionPixelSize(R.dimen.widget_cover_height),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
override fun onCreate() {
|
|
|
|
override fun onCreate() = Unit
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun getLoadingView() = null
|
|
|
|
override fun getLoadingView() = null
|
|
|
|
|
|
|
|
|
|
|
|
@ -56,6 +64,8 @@ class ShelfListFactory(
|
|
|
|
val cover = coil.executeBlocking(
|
|
|
|
val cover = coil.executeBlocking(
|
|
|
|
ImageRequest.Builder(context)
|
|
|
|
ImageRequest.Builder(context)
|
|
|
|
.data(item.coverUrl)
|
|
|
|
.data(item.coverUrl)
|
|
|
|
|
|
|
|
.size(coverSize)
|
|
|
|
|
|
|
|
.transformations(transformation)
|
|
|
|
.build()
|
|
|
|
.build()
|
|
|
|
).requireBitmap()
|
|
|
|
).requireBitmap()
|
|
|
|
views.setImageViewBitmap(R.id.imageView_cover, cover)
|
|
|
|
views.setImageViewBitmap(R.id.imageView_cover, cover)
|
|
|
|
|