Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save balachandarlinks/1901f904887694c0b255 to your computer and use it in GitHub Desktop.
Save balachandarlinks/1901f904887694c0b255 to your computer and use it in GitHub Desktop.
ViewAnimationUtils - Circular Reveal Effect
//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