Dependencies of application

This commit is contained in:
oupson 2019-10-05 20:31:38 +02:00
parent 61adbcfd34
commit b24ae6d28f
4 changed files with 11 additions and 10 deletions

View File

@ -95,9 +95,7 @@ fun ImageView.loadApng(@RawRes res : Int, speed : Float? = null, apngAnimatorOpt
*/
class ApngAnimator(private val context: Context?) {
var isPlaying = true
private set(value) {
field = value
}
private set
var speed: Float? = null
set(value) {
@ -222,7 +220,6 @@ class ApngAnimator(private val context: Context?) {
input.read(bytes)
input.close()
if (isPng(bytes)) {
isApng = true
this@ApngAnimator.speed = speed
scaleType = apngAnimatorOptions?.scaleType
// Download PNG
@ -231,12 +228,14 @@ class ApngAnimator(private val context: Context?) {
APNGDisassembler.disassemble(inputStream).also {
inputStream.close()
if (it.isApng) {
isApng = true
it.frames.also {frames ->
draw(frames).apply {
setupAnimationDrawableAndStart(this)
}
}
} else {
isApng = false
GlobalScope.launch(Dispatchers.Main) {
imageView?.setImageBitmap(it.cover)
}

View File

@ -34,7 +34,7 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
//noinspection GradleCompatible
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
@ -48,5 +48,5 @@ dependencies {
implementation "org.jetbrains.anko:anko-appcompat-v7:$anko_version"
implementation "org.jetbrains.anko:anko-design:$anko_version"
implementation "org.jetbrains.anko:anko-constraint-layout:$anko_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.0-M1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.2'
}

View File

@ -53,10 +53,12 @@ class Main2Activity : AppCompatActivity() {
val animator = imageView.loadApng(uri, null)
imageView.onClick {
try {
if (animator.isPlaying) {
animator.pause()
} else {
animator.play()
if (animator.isApng) {
if (animator.isPlaying) {
animator.pause()
} else {
animator.play()
}
}
} catch (e: Exception) {
e.printStackTrace()