Skip to content

Commit

Permalink
Merge pull request #8 from Mori-Atsushi/coil-2.0
Browse files Browse the repository at this point in the history
Update coil 2.0.0-rc01
  • Loading branch information
wasabeef authored Mar 10, 2022
2 parents cabb37e + 9f6a683 commit f5ce5ff
Show file tree
Hide file tree
Showing 31 changed files with 58 additions and 58 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ allprojects {
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class).configureEach {
kotlinOptions {
allWarningsAsErrors = true
// allWarningsAsErrors = true
jvmTarget = "1.8"
}
}
Expand Down
6 changes: 3 additions & 3 deletions buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
object BuildConfig {
const val compileSdk = 30
const val compileSdk = 31

const val appId = "jp.wasabeef.transformers"
const val minSdk = 21
const val targetSdk = 30
const val targetSdk = 31
const val appVersionCode = 3
const val appVersionName = "1.0.5"

Expand Down Expand Up @@ -56,7 +56,7 @@ object Libraries {
private const val glideVersion = "4.12.0"
const val glide = "com.github.bumptech.glide:glide:$glideVersion"
const val glideCompiler = "com.github.bumptech.glide:compiler:$glideVersion"
const val coil = "io.coil-kt:coil:1.4.0"
const val coil = "io.coil-kt:coil:2.0.0-rc01"
const val fresco = "com.facebook.fresco:fresco:2.5.0"
const val gpuImage = "jp.co.cyberagent.android:gpuimage:2.1.0"
}
1 change: 1 addition & 0 deletions sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
>
<activity
android:name="jp.wasabeef.transformers.MainActivity"
android:exported="true"
android:label="@string/app_name"
>
<intent-filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ class BrightnessFilterTransformation @JvmOverloads constructor(
}
) {

override fun key(): String = "$id(brightness=$brightness)"
override val cacheKey: String get() = "$id(brightness=$brightness)"
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,5 @@ class ContrastFilterTransformation @JvmOverloads constructor(
setContrast(contrast)
}
) {

override fun key(): String = "$id(contrast=$contrast)"
override val cacheKey: String get() = "$id(contrast=$contrast)"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package jp.wasabeef.transformers.coil.gpu

import android.content.Context
import android.graphics.Bitmap
import coil.bitmap.BitmapPool
import coil.size.Size
import coil.transform.Transformation
import jp.co.cyberagent.android.gpuimage.GPUImage
Expand Down Expand Up @@ -35,7 +34,7 @@ abstract class GPUFilterTransformation(
protected val id: String
get() = "${this::class.java.name}-$version"

override suspend fun transform(pool: BitmapPool, input: Bitmap, size: Size): Bitmap {
override suspend fun transform(input: Bitmap, size: Size): Bitmap {
val gpuImage = GPUImage(context)
gpuImage.setImage(input)
gpuImage.setFilter(filter)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ class HalftoneFilterTransformation constructor(
context: Context
) : GPUFilterTransformation(context, GPUImageHalftoneFilter()) {

override fun key(): String = "$id()"
override val cacheKey: String get() = "$id()"
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ class InvertFilterTransformation constructor(
context: Context
) : GPUFilterTransformation(context, GPUImageColorInvertFilter()) {

override fun key(): String = "$id()"
override val cacheKey: String get() = "$id()"
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ class KuwaharaFilterTransformation @JvmOverloads constructor(
}
) {

override fun key(): String = "$id(radius=$radius)"
override val cacheKey: String get() = "$id(radius=$radius)"
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ class PixelationFilterTransformation @JvmOverloads constructor(
}
) {

override fun key(): String = "$id(pixel=$pixel)"
override val cacheKey: String get() = "$id(pixel=$pixel)"
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ class SepiaFilterTransformation @JvmOverloads constructor(
}
) {

override fun key(): String = "$id(intensity=$intensity)"
override val cacheKey: String get() = "$id(intensity=$intensity)"
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ class SharpenFilterTransformation @JvmOverloads constructor(
}
) {

override fun key(): String = "$id(sharpness=$sharpness)"
override val cacheKey: String get() = "$id(sharpness=$sharpness)"
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ class SketchFilterTransformation constructor(
context: Context
) : GPUFilterTransformation(context, GPUImageSketchFilter()) {

override fun key(): String = "$id()"
override val cacheKey: String get() = "$id()"
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ class SwirlFilterTransformation @JvmOverloads constructor(
}
) {

override fun key(): String = "$id(radius=$radius, angle=$angle, center=$center)"
override val cacheKey: String get() = "$id(radius=$radius, angle=$angle, center=$center)"
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ class ToneCurveFilterTransformation constructor(
}
) {

override fun key(): String = "$id(toneCurveId=$toneCurveId)"
override val cacheKey: String get() = "$id(toneCurveId=$toneCurveId)"
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ class ToonFilterTransformation @JvmOverloads constructor(
}
) {

override fun key(): String = "$id(threshold=$threshold, quantizationLevels=$quantizationLevels)"
override val cacheKey: String
get() = "$id(threshold=$threshold, quantizationLevels=$quantizationLevels)"
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class VignetteFilterTransformation @JvmOverloads constructor(
}
) {

override fun key(): String =
"$id(center=$center," +
override val cacheKey: String
get() = "$id(center=$center," +
" vignetteColor=${vignetteColor.contentToString()}, vignetteStart=$vignetteStart," +
" vignetteEnd=$vignetteEnd)"
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ class WhiteBalanceFilterTransformation @JvmOverloads constructor(
}
) {

override fun key(): String = "$id(temperature=$temperature, tint=$tint)"
override val cacheKey: String get() = "$id(temperature=$temperature, tint=$tint)"
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ class ZoomBlurFilterTransformation @JvmOverloads constructor(
}
) {

override fun key(): String = "$id(blurCenter=$blurCenter, blurSize=$blurSize)"
override val cacheKey: String get() = "$id(blurCenter=$blurCenter, blurSize=$blurSize)"
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ import jp.wasabeef.transformers.core.Transformer
abstract class BaseTransformation(
val transformer: Transformer
) : Transformation {

override fun key() = transformer.key()
override val cacheKey: String
get() = transformer.key()
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package jp.wasabeef.transformers.coil

import android.content.Context
import android.graphics.Bitmap
import coil.bitmap.BitmapPool
import android.graphics.Bitmap.createBitmap
import coil.size.Size
import jp.wasabeef.transformers.core.Blur
import jp.wasabeef.transformers.core.bitmapConfig
Expand Down Expand Up @@ -30,10 +30,10 @@ class BlurTransformation @JvmOverloads constructor(
rs: Boolean = true
) : BaseTransformation(Blur(context, radius, sampling, rs)) {

override suspend fun transform(pool: BitmapPool, input: Bitmap, size: Size): Bitmap {
override suspend fun transform(input: Bitmap, size: Size): Bitmap {
val scaledWidth: Int = input.width / sampling
val scaledHeight: Int = input.height / sampling
val output = pool.get(scaledWidth, scaledHeight, bitmapConfig(input))
val output = createBitmap(scaledWidth, scaledHeight, bitmapConfig(input))
return transformer.transform(input, output)
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package jp.wasabeef.transformers.coil

import android.graphics.Bitmap
import android.graphics.Bitmap.createBitmap
import androidx.annotation.ColorInt
import coil.bitmap.BitmapPool
import coil.size.Size
import jp.wasabeef.transformers.core.ColorFilter
import jp.wasabeef.transformers.core.bitmapConfig
Expand All @@ -27,8 +27,8 @@ class ColorFilterTransformation constructor(
@ColorInt color: Int
) : BaseTransformation(ColorFilter(color)) {

override suspend fun transform(pool: BitmapPool, input: Bitmap, size: Size): Bitmap {
val output = pool.get(input.width, input.height, bitmapConfig(input))
override suspend fun transform(input: Bitmap, size: Size): Bitmap {
val output = createBitmap(input.width, input.height, bitmapConfig(input))
return transformer.transform(input, output)
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package jp.wasabeef.transformers.coil

import android.graphics.Bitmap
import coil.bitmap.BitmapPool
import android.graphics.Bitmap.createBitmap
import coil.size.Size
import jp.wasabeef.transformers.core.Crop
import jp.wasabeef.transformers.core.bitmapConfig
Expand Down Expand Up @@ -34,9 +34,9 @@ class CropCenterBottomTransformation : BaseTransformation(
)
) {

override suspend fun transform(pool: BitmapPool, input: Bitmap, size: Size): Bitmap {
override suspend fun transform(input: Bitmap, size: Size): Bitmap {
val calcSize = (transformer as Crop).calculateSize(input)
val output = pool.get(calcSize.width, calcSize.height, bitmapConfig(input))
val output = createBitmap(calcSize.width, calcSize.height, bitmapConfig(input))
return transformer.transform(input, output)
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package jp.wasabeef.transformers.coil

import android.graphics.Bitmap
import coil.bitmap.BitmapPool
import android.graphics.Bitmap.createBitmap
import coil.size.Size
import jp.wasabeef.transformers.core.Crop
import jp.wasabeef.transformers.core.bitmapConfig
Expand Down Expand Up @@ -34,9 +34,9 @@ class CropCenterTopTransformation : BaseTransformation(
)
) {

override suspend fun transform(pool: BitmapPool, input: Bitmap, size: Size): Bitmap {
override suspend fun transform(input: Bitmap, size: Size): Bitmap {
val calcSize = (transformer as Crop).calculateSize(input)
val output = pool.get(calcSize.width, calcSize.height, bitmapConfig(input))
val output = createBitmap(calcSize.width, calcSize.height, bitmapConfig(input))
return transformer.transform(input, output)
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package jp.wasabeef.transformers.coil

import android.graphics.Bitmap
import coil.bitmap.BitmapPool
import android.graphics.Bitmap.createBitmap
import coil.size.Size
import jp.wasabeef.transformers.core.CropCircle
import jp.wasabeef.transformers.core.bitmapConfig
Expand All @@ -25,9 +25,9 @@ import kotlin.math.min

class CropCircleTransformation : BaseTransformation(CropCircle()) {

override suspend fun transform(pool: BitmapPool, input: Bitmap, size: Size): Bitmap {
override suspend fun transform(input: Bitmap, size: Size): Bitmap {
val minSize = min(input.width, input.height)
val output = pool.get(minSize, minSize, bitmapConfig(input))
val output = createBitmap(minSize, minSize, bitmapConfig(input))
return transformer.transform(input, output)
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package jp.wasabeef.transformers.coil

import android.graphics.Bitmap
import android.graphics.Bitmap.createBitmap
import android.graphics.Color
import androidx.annotation.ColorInt
import coil.bitmap.BitmapPool
import coil.size.Size
import jp.wasabeef.transformers.core.CropCircleWithBorder
import jp.wasabeef.transformers.core.bitmapConfig
Expand Down Expand Up @@ -31,9 +31,9 @@ class CropCircleWithBorderTransformation @JvmOverloads constructor(
@ColorInt borderColor: Int = Color.BLACK
) : BaseTransformation(CropCircleWithBorder(borderSize, borderColor)) {

override suspend fun transform(pool: BitmapPool, input: Bitmap, size: Size): Bitmap {
override suspend fun transform(input: Bitmap, size: Size): Bitmap {
val minSize = min(input.width, input.height)
val output = pool.get(minSize, minSize, bitmapConfig(input))
val output = createBitmap(minSize, minSize, bitmapConfig(input))
return transformer.transform(input, output)
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package jp.wasabeef.transformers.coil

import android.graphics.Bitmap
import coil.bitmap.BitmapPool
import android.graphics.Bitmap.createBitmap
import coil.size.Size
import jp.wasabeef.transformers.core.CropSquare
import jp.wasabeef.transformers.core.bitmapConfig
Expand All @@ -25,9 +25,9 @@ import kotlin.math.min

class CropSquareTransformation : BaseTransformation(CropSquare()) {

override suspend fun transform(pool: BitmapPool, input: Bitmap, size: Size): Bitmap {
override suspend fun transform(input: Bitmap, size: Size): Bitmap {
val minSize = min(input.width, input.height)
val output = pool.get(minSize, minSize, bitmapConfig(input))
val output = createBitmap(minSize, minSize, bitmapConfig(input))
return transformer.transform(input, output)
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package jp.wasabeef.transformers.coil

import android.graphics.Bitmap
import coil.bitmap.BitmapPool
import android.graphics.Bitmap.createBitmap
import coil.size.Size
import jp.wasabeef.transformers.core.Crop
import jp.wasabeef.transformers.core.bitmapConfig
Expand Down Expand Up @@ -117,9 +117,9 @@ class CropTransformation : BaseTransformation {
this.gravityVertical = gravityVertical
}

override suspend fun transform(pool: BitmapPool, input: Bitmap, size: Size): Bitmap {
override suspend fun transform(input: Bitmap, size: Size): Bitmap {
val calcSize = (transformer as Crop).calculateSize(input)
val output = pool.get(calcSize.width, calcSize.height, bitmapConfig(input))
val output = createBitmap(calcSize.width, calcSize.height, bitmapConfig(input))
return transformer.transform(input, output)
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package jp.wasabeef.transformers.coil

import android.graphics.Bitmap
import coil.bitmap.BitmapPool
import android.graphics.Bitmap.createBitmap
import coil.size.Size
import jp.wasabeef.transformers.core.Grayscale
import jp.wasabeef.transformers.core.bitmapConfig
Expand All @@ -24,8 +24,8 @@ import jp.wasabeef.transformers.core.bitmapConfig

class GrayscaleTransformation : BaseTransformation(Grayscale()) {

override suspend fun transform(pool: BitmapPool, input: Bitmap, size: Size): Bitmap {
val output = pool.get(input.width, input.height, bitmapConfig(input))
override suspend fun transform(input: Bitmap, size: Size): Bitmap {
val output = createBitmap(input.width, input.height, bitmapConfig(input))
return transformer.transform(input, output)
}
}
Loading

0 comments on commit f5ce5ff

Please sign in to comment.