Forked from balachandarlinks/ViewAnimationUtilsCircularReveal.java
Created
June 15, 2019 21:31
-
-
Save mimoccc/85bb1a0363e47a526a564c6865b635d4 to your computer and use it in GitHub Desktop.
ViewAnimationUtils - Circular Reveal Effect
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Reveal View. Note: View should be invisible before revealing | |
currentTubeStatusContainer.setVisibility(View.INVISIBLE); | |
// Do the API compatibility check | |
new Timer().schedule(new TimerTask() { | |
@Override | |
public void run() { | |
getActivity().runOnUiThread(new Runnable() { | |
@Override | |
public void run() { | |
currentTubeStatusContainer.setVisibility(View.VISIBLE); | |
} | |
}); | |
int cx = (currentTubeStatusContainer.getLeft() + currentTubeStatusContainer.getRight()) / 2; | |
int cy = (currentTubeStatusContainer.getTop() + currentTubeStatusContainer.getBottom()) / 2; | |
Animator anim = ViewAnimationUtils.createCircularReveal(currentTubeStatusContainer, cx, | |
cy, 0, currentTubeStatusContainer.getWidth()); | |
anim.start(); | |
} | |
}, 5000); | |
//Hide View | |
new Timer().schedule(new TimerTask() { | |
@Override | |
public void run() { | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { | |
Toast.makeText(getActivity().getApplicationContext(), "Animation running!", Toast.LENGTH_SHORT).show(); | |
int cx = (currentTubeStatusContainer.getLeft() + currentTubeStatusContainer.getRight()) / 2; | |
int cy = (currentTubeStatusContainer.getTop() + currentTubeStatusContainer.getBottom()) / 2; | |
Animator anim = ViewAnimationUtils.createCircularReveal(currentTubeStatusContainer, cx, | |
cy, currentTubeStatusContainer.getWidth(), 0); | |
anim.addListener(new Animator.AnimatorListener() { | |
@Override | |
public void onAnimationStart(Animator animation) {} | |
@Override | |
public void onAnimationEnd(Animator animation) { | |
currentTubeStatusContainer.setVisibility(View.INVISIBLE); | |
} | |
@Override | |
public void onAnimationCancel(Animator animation) {} | |
@Override | |
public void onAnimationRepeat(Animator animation) {} | |
}); | |
anim.start(); | |
} | |
} | |
}, 5000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment