aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/glide/GlideUtils.kt
blob: 6d2b3cdafa2169813eabb39aa1440a4a2e5a84b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package com.pitchedapps.frost.glide

import com.bumptech.glide.RequestBuilder
import com.bumptech.glide.load.MultiTransformation
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation
import com.bumptech.glide.load.resource.bitmap.CircleCrop
import com.bumptech.glide.request.RequestOptions

/**
 * Created by Allan Wang on 28/12/17.
 *
 * Collection of transformations
 * Each caller will generate a new one upon request
 */
object FrostGlide {
    val roundCorner
        get() = RoundCornerTransformation()
    val circleCrop
        get() = CircleCrop()
}

fun <T> RequestBuilder<T>.transform(vararg transformation: BitmapTransformation): RequestBuilder<T> =
        when (transformation.size) {
            0 -> this
            1 -> apply(RequestOptions.bitmapTransform(transformation[0]))
            else -> apply(RequestOptions.bitmapTransform(MultiTransformation(*transformation)))
        }