Better exception name and deprecation

This commit is contained in:
Oupson 2021-02-06 17:24:58 +01:00
parent 338a875b9c
commit 322d433467
5 changed files with 8 additions and 5 deletions

View File

@ -6,6 +6,7 @@ import android.graphics.ColorFilter
import android.graphics.PixelFormat
import android.graphics.drawable.Drawable
@Deprecated("Deprecated, Use ApngEncoder and ApngDecoder instead", level = DeprecationLevel.WARNING)
internal class BitmapDrawable(private val bitmap: Bitmap) : Drawable() {
override fun draw(canvas: Canvas) {

View File

@ -6,6 +6,7 @@ import android.graphics.drawable.AnimationDrawable
* Extension of the [AnimationDrawable] that provides an animationListener This will allow
* for the caller to listen for specific animation related events.
*/
@Deprecated("Deprecated, Use ApngEncoder and ApngDecoder instead", level = DeprecationLevel.WARNING)
class CustomAnimationDrawable : AnimationDrawable() {
private var onFrameChangeListener : (index : Int) -> Unit? = {}

View File

@ -19,6 +19,7 @@ import oupson.apng.utils.Utils.Companion.isPng
* @param maxWidth The max width of the APNG
* @param maxHeight The max height of the APNG
*/
@Deprecated("Deprecated, Use ApngEncoder and ApngDecoder instead", level = DeprecationLevel.WARNING)
class Frame // Get width and height for image
(
byteArray: ByteArray,

View File

@ -28,6 +28,6 @@ class InvalidFrameSizeException(animationWidth : Int, animationHeight : Int, fra
}
}
class BadFrameDiffSize(firstFrameWidth : Int, firstFrameHeight : Int, secondFrameWidth : Int, secondFrameHeight : Int) : Exception() {
override val message: String = "${firstFrameWidth}x${firstFrameHeight} must be smaller than ${secondFrameWidth}x${secondFrameHeight}"
class BadBitmapsDiffSize(firstBitmapWidth : Int, firstBitmapHeight : Int, secondBitmapWidth : Int, secondBitmapHeight : Int) : Exception() {
override val message: String = "${firstBitmapWidth}x${firstBitmapHeight} must be bigger than or equal to ${secondBitmapWidth}x${secondBitmapHeight}"
}

View File

@ -2,7 +2,7 @@ package oupson.apng.utils
import android.graphics.Bitmap
import android.graphics.Color
import oupson.apng.exceptions.BadFrameDiffSize
import oupson.apng.exceptions.BadBitmapsDiffSize
import oupson.apng.utils.Utils.Companion.BlendOp.APNG_BLEND_OP_OVER
import oupson.apng.utils.Utils.Companion.BlendOp.APNG_BLEND_OP_SOURCE
import oupson.apng.utils.Utils.Companion.DisposeOp.*
@ -225,10 +225,10 @@ class Utils {
* @param secondBitmap A [Bitmap], a second bitmap
* @return [DiffResult], the difference between the second and the first bitmap
*/
@Throws(BadFrameDiffSize::class)
@Throws(BadBitmapsDiffSize::class)
fun getDiffBitmap(firstBitmap : Bitmap, secondBitmap : Bitmap) : DiffResult {
if (firstBitmap.width < secondBitmap.width || firstBitmap.height < secondBitmap.height) {
throw BadFrameDiffSize(firstBitmap.width, firstBitmap.height, firstBitmap.width, firstBitmap.height)
throw BadBitmapsDiffSize(firstBitmap.width, firstBitmap.height, firstBitmap.width, firstBitmap.height)
}
val resultBtm = Bitmap.createBitmap(secondBitmap.width, secondBitmap.height, Bitmap.Config.ARGB_8888)