From 9a75db3ec6f5cd4dab84caeef0956fcb7864bc58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20Wr=C3=B3tniak?= Date: Tue, 9 Jun 2015 02:39:50 +0200 Subject: [PATCH] setter range annotations added --- .../java/pl/droidsonroids/gif/GifDrawable.java | 16 +++++++++------- .../pl/droidsonroids/gif/GifTextureView.java | 3 ++- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main/java/pl/droidsonroids/gif/GifDrawable.java b/src/main/java/pl/droidsonroids/gif/GifDrawable.java index cf2d96b8..265a7323 100644 --- a/src/main/java/pl/droidsonroids/gif/GifDrawable.java +++ b/src/main/java/pl/droidsonroids/gif/GifDrawable.java @@ -23,6 +23,8 @@ import android.os.StrictMode; import android.os.SystemClock; import android.support.annotation.DrawableRes; +import android.support.annotation.FloatRange; +import android.support.annotation.IntRange; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.RawRes; @@ -261,7 +263,7 @@ public int getIntrinsicWidth() { } @Override - public void setAlpha(int alpha) { + public void setAlpha(@IntRange(from = 0, to = 255) int alpha) { mPaint.setAlpha(alpha); } @@ -363,7 +365,7 @@ public int getLoopCount() { * * @param loopCount loop count, 0 means infinity */ - public void setLoopCount(final int loopCount) { + public void setLoopCount(@IntRange(from = 0, to = 65535) final int loopCount) { mNativeInfoHandle.setLoopCount(loopCount); } @@ -418,7 +420,7 @@ public static GifDrawable createFromResource(@NonNull Resources res, @DrawableRe * @param factor new speed factor, eg. 0.5f means half speed, 1.0f - normal, 2.0f - double speed * @throws IllegalArgumentException if factor<=0 */ - public void setSpeed(float factor) { + public void setSpeed(@FloatRange(from = 0, fromInclusive = false) float factor) { mNativeInfoHandle.setSpeedFactor(factor); } @@ -469,7 +471,7 @@ public int getCurrentPosition() { * @throws IllegalArgumentException if position<0 */ @Override - public void seekTo(final int position) { + public void seekTo(@IntRange(from = 0, to = Integer.MAX_VALUE) final int position) { if (position < 0) { throw new IllegalArgumentException("Position is not positive"); } @@ -489,7 +491,7 @@ public void doWork() { * @param frameIndex index of the frame to seek to (zero based) * @throws IndexOutOfBoundsException if frameIndex<0 */ - public void seekToFrame(final int frameIndex) { + public void seekToFrame(@IntRange(from = 0, to = Integer.MAX_VALUE) final int frameIndex) { if (frameIndex < 0) { throw new IndexOutOfBoundsException("Frame index is not positive"); } @@ -509,7 +511,7 @@ public void doWork() { * @return frame at desired index * @throws IndexOutOfBoundsException if frameIndex<0 */ - public Bitmap seekToFrameAndGet(final int frameIndex) { + public Bitmap seekToFrameAndGet(@IntRange(from = 0, to = Integer.MAX_VALUE) final int frameIndex) { if (frameIndex < 0) { throw new IndexOutOfBoundsException("Frame index is not positive"); } @@ -529,7 +531,7 @@ public Bitmap seekToFrameAndGet(final int frameIndex) { * @return frame at desired position * @throws IndexOutOfBoundsException if position<0 */ - public Bitmap seekToPositionAndGet(final int position) { + public Bitmap seekToPositionAndGet(@IntRange(from = 0, to = Integer.MAX_VALUE) final int position) { if (position < 0) { throw new IllegalArgumentException("Position is not positive"); } diff --git a/src/main/java/pl/droidsonroids/gif/GifTextureView.java b/src/main/java/pl/droidsonroids/gif/GifTextureView.java index 558da292..4d845fcf 100644 --- a/src/main/java/pl/droidsonroids/gif/GifTextureView.java +++ b/src/main/java/pl/droidsonroids/gif/GifTextureView.java @@ -8,6 +8,7 @@ import android.graphics.SurfaceTexture; import android.os.Build; import android.os.Parcelable; +import android.support.annotation.FloatRange; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.util.AttributeSet; @@ -298,7 +299,7 @@ public synchronized void setInputSource(@Nullable InputSource inputSource) { * @throws IllegalArgumentException if factor<=0 * @see GifDrawable#setSpeed(float) */ - public void setSpeed(float factor) { + public void setSpeed(@FloatRange(from = 0, fromInclusive = false) float factor) { mSpeedFactor = factor; mRenderThread.mGifInfoHandle.setSpeedFactor(factor); }