From 322d4334671c2148778cfb5d8e6c0dd54c999618 Mon Sep 17 00:00:00 2001 From: Oupson Date: Sat, 6 Feb 2021 17:24:58 +0100 Subject: [PATCH] Better exception name and deprecation --- apng_library/src/main/java/oupson/apng/BitmapDrawable.kt | 1 + .../src/main/java/oupson/apng/CustomAnimationDrawable.kt | 1 + apng_library/src/main/java/oupson/apng/Frame.kt | 1 + .../src/main/java/oupson/apng/exceptions/customException.kt | 4 ++-- apng_library/src/main/java/oupson/apng/utils/Utils.kt | 6 +++--- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/apng_library/src/main/java/oupson/apng/BitmapDrawable.kt b/apng_library/src/main/java/oupson/apng/BitmapDrawable.kt index 30ce351..51891bd 100644 --- a/apng_library/src/main/java/oupson/apng/BitmapDrawable.kt +++ b/apng_library/src/main/java/oupson/apng/BitmapDrawable.kt @@ -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) { diff --git a/apng_library/src/main/java/oupson/apng/CustomAnimationDrawable.kt b/apng_library/src/main/java/oupson/apng/CustomAnimationDrawable.kt index 7552167..349673c 100644 --- a/apng_library/src/main/java/oupson/apng/CustomAnimationDrawable.kt +++ b/apng_library/src/main/java/oupson/apng/CustomAnimationDrawable.kt @@ -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? = {} diff --git a/apng_library/src/main/java/oupson/apng/Frame.kt b/apng_library/src/main/java/oupson/apng/Frame.kt index 2ca4ebc..d85bfee 100644 --- a/apng_library/src/main/java/oupson/apng/Frame.kt +++ b/apng_library/src/main/java/oupson/apng/Frame.kt @@ -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, diff --git a/apng_library/src/main/java/oupson/apng/exceptions/customException.kt b/apng_library/src/main/java/oupson/apng/exceptions/customException.kt index 4954094..38b7254 100644 --- a/apng_library/src/main/java/oupson/apng/exceptions/customException.kt +++ b/apng_library/src/main/java/oupson/apng/exceptions/customException.kt @@ -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}" } \ No newline at end of file diff --git a/apng_library/src/main/java/oupson/apng/utils/Utils.kt b/apng_library/src/main/java/oupson/apng/utils/Utils.kt index c67ad4d..ccba598 100644 --- a/apng_library/src/main/java/oupson/apng/utils/Utils.kt +++ b/apng_library/src/main/java/oupson/apng/utils/Utils.kt @@ -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)