Skip to content

Commit edef0f9

Browse files
committed
add PaintFlagsDrawFilter setting to Drawer.
1 parent 8cea88d commit edef0f9

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

app/build.gradle

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
apply plugin: 'com.android.application'
22

33
android {
4-
compileSdkVersion 25
4+
compileSdkVersion 26
55
buildToolsVersion '26.0.2'
66
defaultConfig {
77
applicationId "com.example.ponycui_home.svgaplayer"
8-
minSdkVersion 16
9-
targetSdkVersion 25
8+
minSdkVersion 14
9+
targetSdkVersion 26
1010
versionCode 1
1111
versionName "1.0"
1212
}
@@ -30,7 +30,7 @@ android {
3030

3131
dependencies {
3232
compile fileTree(include: ['*.jar'], dir: 'libs')
33-
compile 'com.android.support:appcompat-v7:25.3.1'
33+
compile 'com.android.support:appcompat-v7:26.1.0'
3434
compile project(':library')
3535
compile 'com.squareup.okhttp3:okhttp:3.4.1'
3636
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"

build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ buildscript {
1818
allprojects {
1919
repositories {
2020
jcenter()
21+
google()
2122
}
2223
}

library/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ apply plugin: 'com.android.library'
22
apply plugin: 'kotlin-android'
33

44
android {
5-
compileSdkVersion 25
5+
compileSdkVersion 26
66
buildToolsVersion '26.0.2'
77
defaultConfig {
88
minSdkVersion 14
9-
targetSdkVersion 25
9+
targetSdkVersion 26
1010
versionCode 1
1111
versionName "1.0"
1212
}

library/src/main/java/com/opensource/svgaplayer/SVGACanvasDrawer.kt

+8
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,18 @@ class SVGACanvasDrawer(videoItem: SVGAVideoEntity, val dynamicItem: SVGADynamicE
2020

2121
override fun drawFrame(frameIndex: Int, scaleType: ImageView.ScaleType) {
2222
super.drawFrame(frameIndex, scaleType)
23+
var originalFilter: DrawFilter? = null
24+
if (videoItem.antiAlias) {
25+
originalFilter = this.canvas?.drawFilter
26+
this.canvas?.drawFilter = PaintFlagsDrawFilter(0, Paint.FILTER_BITMAP_FLAG or Paint.ANTI_ALIAS_FLAG)
27+
}
2328
val sprites = requestFrameSprites(frameIndex)
2429
sprites.forEach {
2530
drawSprite(it, scaleType)
2631
}
32+
if (videoItem.antiAlias) {
33+
this.canvas?.drawFilter = originalFilter
34+
}
2735
}
2836

2937
private fun performScaleType(scaleType: ImageView.ScaleType) {

0 commit comments

Comments
 (0)