Skip to content

Instantly share code, notes, and snippets.

@rahulkhatri19
Created February 18, 2020 04:51
Show Gist options
  • Save rahulkhatri19/77e31930664fdb83a6dce958f07d0ac9 to your computer and use it in GitHub Desktop.
Save rahulkhatri19/77e31930664fdb83a6dce958f07d0ac9 to your computer and use it in GitHub Desktop.
// package com.example.
import android.graphics.drawable.Drawable
import android.graphics.drawable.PictureDrawable
import android.widget.ImageView
import com.bumptech.glide.RequestBuilder
import com.bumptech.glide.load.DataSource
import com.bumptech.glide.load.engine.GlideException
import com.bumptech.glide.request.RequestListener
import com.bumptech.glide.request.target.ImageViewTarget
import com.bumptech.glide.request.target.Target
class SvgSoftwareLayerSetter : RequestListener<PictureDrawable> {
override fun onLoadFailed(
e: GlideException?,
model: Any?,
target: Target<PictureDrawable>?,
isFirstResource: Boolean
): Boolean {
val view:ImageView = (target as ImageViewTarget<*>).view
view.setLayerType(ImageView.LAYER_TYPE_NONE, null)
return false
}
override fun onResourceReady(
resource: PictureDrawable?,
model: Any?,
target: Target<PictureDrawable>?,
dataSource: DataSource?,
isFirstResource: Boolean
): Boolean {
val view:ImageView = (target as ImageViewTarget<*>).view
view.setLayerType(ImageView.LAYER_TYPE_SOFTWARE, null)
return false
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment