Skip to content

Commit

Permalink
setter range annotations added
Browse files Browse the repository at this point in the history
  • Loading branch information
koral-- committed Jun 9, 2015
1 parent b82789c commit 9a75db3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
16 changes: 9 additions & 7 deletions src/main/java/pl/droidsonroids/gif/GifDrawable.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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");
}
Expand All @@ -489,7 +491,7 @@ public void doWork() {
* @param frameIndex index of the frame to seek to (zero based)
* @throws IndexOutOfBoundsException if frameIndex&lt;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");
}
Expand All @@ -509,7 +511,7 @@ public void doWork() {
* @return frame at desired index
* @throws IndexOutOfBoundsException if frameIndex&lt;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");
}
Expand All @@ -529,7 +531,7 @@ public Bitmap seekToFrameAndGet(final int frameIndex) {
* @return frame at desired position
* @throws IndexOutOfBoundsException if position&lt;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");
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/pl/droidsonroids/gif/GifTextureView.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -298,7 +299,7 @@ public synchronized void setInputSource(@Nullable InputSource inputSource) {
* @throws IllegalArgumentException if factor&lt;=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);
}
Expand Down

0 comments on commit 9a75db3

Please sign in to comment.