Skip to content

Instantly share code, notes, and snippets.

@marenovakovic
Last active May 26, 2021 17:55
Show Gist options
  • Select an option

  • Save marenovakovic/2f32a53ae6f02186a0178a7ced6e367e to your computer and use it in GitHub Desktop.

Select an option

Save marenovakovic/2f32a53ae6f02186a0178a7ced6e367e to your computer and use it in GitHub Desktop.
import android.graphics.Bitmap
import android.graphics.drawable.Drawable
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.core.graphics.drawable.toBitmap
import coil.target.Target
@Composable
fun rememberCoilTarget(onBitmapReady: (Bitmap) -> Unit): Target = remember {
object : Target {
override fun onSuccess(result: Drawable) = onBitmapReady(result.toBitmap())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment