arkon 15d52784f8 Convert BackupRestoreService to a WorkManager job
Co-authored-by: Jays2Kings <Jays2Kings@users.noreply.github.com>
(cherry picked from commit cdc160afc2e3bb615fe35c8d7261a3bc16f61996)

# Conflicts:
#	app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupRestorer.kt
2023-03-20 18:42:05 -04:00

30 lines
1006 B
Kotlin

package eu.kanade.presentation.util
import android.content.res.Resources
import androidx.annotation.DrawableRes
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.graphics.painter.BitmapPainter
import androidx.compose.ui.platform.LocalContext
import androidx.core.content.ContextCompat
import androidx.core.graphics.drawable.toBitmap
/**
* Create a BitmapPainter from a drawable resource.
* Use this only if [androidx.compose.ui.res.painterResource] doesn't work.
*
* @param id the resource identifier
*
* @return the bitmap associated with the resource
*/
@Composable
fun rememberResourceBitmapPainter(@DrawableRes id: Int): BitmapPainter {
val context = LocalContext.current
return remember(id) {
val drawable = ContextCompat.getDrawable(context, id)
?: throw Resources.NotFoundException()
BitmapPainter(drawable.toBitmap().asImageBitmap())
}
}