Skip to content

Commit 39f8f15

Browse files
committedJan 8, 2020
Coil transformation added
1 parent 33c0a90 commit 39f8f15

File tree

10 files changed

+206
-27
lines changed

10 files changed

+206
-27
lines changed
 

‎.idea/codeStyles/Project.xml

+109-25
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎glimpse-coil/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

‎glimpse-coil/build.gradle

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
apply plugin: 'com.android.library'
2+
apply plugin: 'kotlin-android'
3+
apply plugin: 'com.github.dcendents.android-maven'
4+
group = glimpse_group
5+
version = glimpse_version
6+
7+
android {
8+
compileSdkVersion sdk_version
9+
10+
11+
defaultConfig {
12+
minSdkVersion min_sdk_version
13+
targetSdkVersion sdk_version
14+
15+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
16+
}
17+
18+
buildTypes {
19+
release {
20+
minifyEnabled false
21+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
22+
}
23+
}
24+
25+
}
26+
27+
dependencies {
28+
implementation project(':glimpse-core')
29+
implementation("io.coil-kt:coil:0.9.1")
30+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
31+
32+
}

‎glimpse-coil/consumer-rules.pro

Whitespace-only changes.

‎glimpse-coil/proguard-rules.pro

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="glimpse.coil" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package glimpse.coil
2+
3+
import android.graphics.Bitmap
4+
import coil.bitmappool.BitmapPool
5+
import coil.size.PixelSize
6+
import coil.size.Size
7+
import coil.transform.Transformation
8+
import glimpse.core.crop
9+
import glimpse.core.findCenter
10+
11+
class GlimpseTransformation : Transformation {
12+
override fun key(): String = GlimpseTransformation::class.java.name
13+
14+
override suspend fun transform(pool: BitmapPool, input: Bitmap, size: Size): Bitmap {
15+
val pixelSize = size as PixelSize
16+
if (input.width == pixelSize.width && input.height == pixelSize.height) {
17+
pool.put(input)
18+
return input
19+
}
20+
21+
val (xPercentage, yPercentage) = input.findCenter()
22+
23+
val config = if (input.config != null) input.config else Bitmap.Config.ARGB_8888
24+
val recycled = pool.get(pixelSize.width, pixelSize.height, config)
25+
26+
val outBitmap =
27+
input.crop(xPercentage, yPercentage, pixelSize.width, pixelSize.height, recycled)
28+
29+
pool.put(input)
30+
31+
return outBitmap
32+
}
33+
34+
35+
}
36+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<resources>
2+
<string name="app_name">glimpse-coil</string>
3+
</resources>
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[{"outputType":{"type":"MERGED_MANIFESTS"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":-1,"enabled":true,"outputFile":"glimpse-core-debug.aar","fullName":"debug","baseName":"debug"},"path":"../../library_manifest/debug/AndroidManifest.xml","properties":{"packageId":"glimpse.core","split":""}}]
1+
[{"outputType":{"type":"MERGED_MANIFESTS"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":-1,"enabled":true,"outputFile":"glimpse-core-debug.aar","fullName":"debug","baseName":"debug"},"path":"..\\..\\library_manifest\\debug\\AndroidManifest.xml","properties":{"packageId":"glimpse.core","split":""}}]

‎settings.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
include ':sample-app', ':glimpse-core', ':glimpse-glide'
1+
include ':sample-app', ':glimpse-core', ':glimpse-glide', ':glimpse-coil'

0 commit comments

Comments
 (0)
Please sign in to comment.