Fixing a bug in the app

This commit is contained in:
oupson 2020-05-09 20:43:51 +02:00
parent f52b9e4563
commit f845202a50
2 changed files with 10 additions and 2 deletions

View File

@ -20,6 +20,11 @@ import java.io.File
import java.net.URL import java.net.URL
// TODO REWRITE WITH CALLBACKS // TODO REWRITE WITH CALLBACKS
// TODO REWRITE
/**
* USE [ApngDecoder] instead of this class to load an APNG
*/
/** /**
* @param file The APNG to load * @param file The APNG to load
@ -422,6 +427,7 @@ class ApngAnimator(private val context: Context?) {
GlobalScope.launch(Dispatchers.Main) { GlobalScope.launch(Dispatchers.Main) {
imageView?.apply { imageView?.apply {
scaleType = this@ApngAnimator.scaleType ?: ImageView.ScaleType.FIT_CENTER scaleType = this@ApngAnimator.scaleType ?: ImageView.ScaleType.FIT_CENTER
clearAnimation()
setImageDrawable(activeAnimation) setImageDrawable(activeAnimation)
} }
activeAnimation?.start() activeAnimation?.start()

View File

@ -4,6 +4,7 @@ import android.annotation.SuppressLint
import android.content.Intent import android.content.Intent
import android.net.http.HttpResponseCache import android.net.http.HttpResponseCache
import android.os.Bundle import android.os.Bundle
import android.util.Log
import android.view.MenuItem import android.view.MenuItem
import androidx.appcompat.app.ActionBarDrawerToggle import androidx.appcompat.app.ActionBarDrawerToggle
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
@ -29,6 +30,7 @@ class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
Log.i(TAG, "${supportFragmentManager.fragments.size}")
setContentView(R.layout.activity_main) setContentView(R.layout.activity_main)
@ -99,7 +101,7 @@ class MainActivity : AppCompatActivity() {
return@setNavigationItemSelectedListener true return@setNavigationItemSelectedListener true
} }
if (intent.hasExtra("fragment")) { if (intent.hasExtra("fragment") && supportFragmentManager.fragments.size == 0) {
when(intent.getStringExtra("fragment")) { when(intent.getStringExtra("fragment")) {
"kotlin" -> { "kotlin" -> {
supportFragmentManager.beginTransaction().apply { supportFragmentManager.beginTransaction().apply {
@ -131,7 +133,7 @@ class MainActivity : AppCompatActivity() {
selected = 2 selected = 2
} }
} }
} else { } else if (supportFragmentManager.fragments.size == 0) {
supportFragmentManager.beginTransaction().apply { supportFragmentManager.beginTransaction().apply {
add( add(
R.id.fragment_container, R.id.fragment_container,