fix buggy isApng()

This commit is contained in:
oupson 2018-11-15 20:41:14 +01:00
parent 66055221f1
commit 84fbac97b3
3 changed files with 10 additions and 3 deletions

View File

@ -7,7 +7,7 @@ android {
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0.3"
versionName "1.0.4"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

View File

@ -18,8 +18,15 @@ class Utils {
* @return True if is an APNG
*/
fun isApng(byteArray: ByteArray): Boolean {
// if byteArray contain acTL
return byteArray.toList().containsAll(byteArrayOf(0x66, 0x63, 0x54, 0x4c).toList())
val acTL = byteArrayOf(0x66, 0x63, 0x54, 0x4c)
loop@for (i in 0 until byteArray.size) {
val it = byteArray.copyOfRange(i, i + 4)
// if byteArray contain acTL
if (it.contentEquals(acTL)) {
return true
}
}
return false
}
/**