Files
Simple-Gallery/app/src/main/kotlin/com/simplemobiletools/gallery/pro/svg/SvgDrawableTranscoder.kt
2018-11-04 21:25:51 +01:00

18 lines
694 B
Kotlin

package com.simplemobiletools.gallery.pro.svg
import android.graphics.drawable.PictureDrawable
import com.bumptech.glide.load.Options
import com.bumptech.glide.load.engine.Resource
import com.bumptech.glide.load.resource.SimpleResource
import com.bumptech.glide.load.resource.transcode.ResourceTranscoder
import com.caverock.androidsvg.SVG
class SvgDrawableTranscoder : ResourceTranscoder<SVG, PictureDrawable> {
override fun transcode(toTranscode: Resource<SVG>, options: Options): Resource<PictureDrawable>? {
val svg = toTranscode.get()
val picture = svg.renderToPicture()
val drawable = PictureDrawable(picture)
return SimpleResource(drawable)
}
}