From 7bed07c2901066ae0aa6751f948e7f4bfdbe96fe Mon Sep 17 00:00:00 2001 From: Thijs Suijten Date: Wed, 21 Oct 2015 09:02:42 +0200 Subject: [PATCH] Added setter for speed --- .../android/scrollingimageview/ScrollingImageView.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/library/src/main/java/com/q42/android/scrollingimageview/ScrollingImageView.java b/library/src/main/java/com/q42/android/scrollingimageview/ScrollingImageView.java index 0fb8379..bdf77ea 100644 --- a/library/src/main/java/com/q42/android/scrollingimageview/ScrollingImageView.java +++ b/library/src/main/java/com/q42/android/scrollingimageview/ScrollingImageView.java @@ -122,7 +122,7 @@ public void onDraw(Canvas canvas) { left += width; } - if (isStarted) { + if (isStarted && speed != 0) { offset -= abs(speed); postInvalidateOnAnimation(); } @@ -159,4 +159,11 @@ public void stop() { invalidate(); } } + + public void setSpeed(float speed) { + this.speed = speed; + if (isStarted) { + postInvalidateOnAnimation(); + } + } }