diff --git a/app/src/main/java/com/github/catvod/spider/Notice.java b/app/src/main/java/com/github/catvod/spider/Notice.java index 29967b17..8dbe7e16 100644 --- a/app/src/main/java/com/github/catvod/spider/Notice.java +++ b/app/src/main/java/com/github/catvod/spider/Notice.java @@ -29,8 +29,8 @@ public class Notice extends Spider { private void createView(String text, int duration) { createText(text, duration); createLayout(); + hide(duration); updateColor(); - hide(); } private void createLayout() { @@ -52,8 +52,8 @@ public class Notice extends Spider { view.startScroll(); } - private void hide() { - Init.run(() -> Utils.removeView(view), 30 * 1000); + private void hide(int duration) { + Init.run(() -> Utils.removeView(view), duration * 1000); } private void updateColor() { diff --git a/app/src/main/java/com/github/catvod/ui/ScrollTextView.java b/app/src/main/java/com/github/catvod/ui/ScrollTextView.java index b5adae4e..8d016f35 100644 --- a/app/src/main/java/com/github/catvod/ui/ScrollTextView.java +++ b/app/src/main/java/com/github/catvod/ui/ScrollTextView.java @@ -10,8 +10,8 @@ import android.widget.TextView; public class ScrollTextView extends TextView { - private Scroller scroller; - private int duration = 30; + private final Scroller scroller; + private int duration; public ScrollTextView(Context context) { this(context, null); @@ -25,7 +25,8 @@ public class ScrollTextView extends TextView { super(context, attrs, defStyle); setSingleLine(); setEllipsize(null); - setVisibility(INVISIBLE); + setHorizontallyScrolling(true); + setScroller(scroller = new Scroller(getContext(), new LinearInterpolator())); } public void setDuration(int duration) { @@ -33,14 +34,11 @@ public class ScrollTextView extends TextView { } public void startScroll() { - int width = -1 * getWidth(); - setHorizontallyScrolling(true); - setScroller(scroller = new Scroller(getContext(), new LinearInterpolator())); - int scrollingLen = calculateScrollingLen(); - int distance = scrollingLen - (getWidth() + width); - scroller.startScroll(width, 0, distance, 0, duration * 1000); - setVisibility(VISIBLE); - invalidate(); + scroller.startScroll(-getWidth(), 0, calculateScrollingLen(), 0, duration * 1000); + } + + public void stopScroll() { + if (scroller != null) scroller.abortAnimation(); } private int calculateScrollingLen() { @@ -54,10 +52,6 @@ public class ScrollTextView extends TextView { @Override public void computeScroll() { super.computeScroll(); - if (scroller == null) return; - if (scroller.isFinished()) { - scroller.abortAnimation(); - setVisibility(GONE); - } + if (scroller != null && scroller.isFinished()) stopScroll(); } } \ No newline at end of file diff --git a/jar/custom_spider.jar b/jar/custom_spider.jar index 47b3331a..f0560ca3 100644 Binary files a/jar/custom_spider.jar and b/jar/custom_spider.jar differ diff --git a/jar/custom_spider.jar.md5 b/jar/custom_spider.jar.md5 index 7e14c33b..2f7cd615 100644 --- a/jar/custom_spider.jar.md5 +++ b/jar/custom_spider.jar.md5 @@ -1 +1 @@ -e18bc0418a1fe5f288275132c9d719b3 +d14ffa035bb1fef5445e235f28e3ee2f