Skip to content

Commit

Permalink
Fixes animator not restarting when scrolled outside of screen (boonco…
Browse files Browse the repository at this point in the history
  • Loading branch information
spatenotte committed Oct 30, 2018
1 parent 109e6f2 commit d2376ec
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public class PulsatorLayout extends RelativeLayout {
private float mCenterX;
private float mCenterY;
private boolean mIsStarted;
private boolean mStoppedDueToDetachedFromWindow;

/**
* Simple constructor to use when creating a view from code.
Expand Down Expand Up @@ -418,10 +419,20 @@ protected void onDetachedFromWindow() {
super.onDetachedFromWindow();

if (mAnimators != null) {
for (Animator animator : mAnimators) {
animator.cancel();
if (isStarted()) {
mStoppedDueToDetachedFromWindow = true;
stop();
}
}
}

@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
if (mAnimators != null) {
if (mStoppedDueToDetachedFromWindow) {
start();
}
mAnimators = null;
}
}

Expand Down

0 comments on commit d2376ec

Please sign in to comment.