use of android.view.animation.Animation.AnimationListener in project Android-SlideExpandableListView by tjerkw.
the class AbstractSlideExpandableListAdapter method animateView.
/**
* Performs either COLLAPSE or EXPAND animation on the target view
* @param target the view to animate
* @param type the animation type, either ExpandCollapseAnimation.COLLAPSE
* or ExpandCollapseAnimation.EXPAND
*/
private void animateView(final View target, final int type) {
Animation anim = new ExpandCollapseAnimation(target, type);
anim.setDuration(getAnimationDuration());
anim.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
if (type == ExpandCollapseAnimation.EXPAND) {
if (parent instanceof ListView) {
ListView listView = (ListView) parent;
int movement = target.getBottom();
Rect r = new Rect();
boolean visible = target.getGlobalVisibleRect(r);
Rect r2 = new Rect();
listView.getGlobalVisibleRect(r2);
if (!visible) {
listView.smoothScrollBy(movement, getAnimationDuration());
} else {
if (r2.bottom == r.bottom) {
listView.smoothScrollBy(movement, getAnimationDuration());
}
}
}
}
}
});
target.startAnimation(anim);
}
use of android.view.animation.Animation.AnimationListener in project XobotOS by xamarin.
the class SlidingTab method startAnimating.
void startAnimating(final boolean holdAfter) {
mAnimating = true;
final Animation trans1;
final Animation trans2;
final Slider slider = mCurrentSlider;
final Slider other = mOtherSlider;
final int dx;
final int dy;
if (isHorizontal()) {
int right = slider.tab.getRight();
int width = slider.tab.getWidth();
int left = slider.tab.getLeft();
int viewWidth = getWidth();
// how much of tab to show at the end of anim
int holdOffset = holdAfter ? 0 : width;
dx = slider == mRightSlider ? -(right + viewWidth - holdOffset) : (viewWidth - left) + viewWidth - holdOffset;
dy = 0;
} else {
int top = slider.tab.getTop();
int bottom = slider.tab.getBottom();
int height = slider.tab.getHeight();
int viewHeight = getHeight();
// how much of tab to show at end of anim
int holdOffset = holdAfter ? 0 : height;
dx = 0;
dy = slider == mRightSlider ? (top + viewHeight - holdOffset) : -((viewHeight - bottom) + viewHeight - holdOffset);
}
trans1 = new TranslateAnimation(0, dx, 0, dy);
trans1.setDuration(ANIM_DURATION);
trans1.setInterpolator(new LinearInterpolator());
trans1.setFillAfter(true);
trans2 = new TranslateAnimation(0, dx, 0, dy);
trans2.setDuration(ANIM_DURATION);
trans2.setInterpolator(new LinearInterpolator());
trans2.setFillAfter(true);
trans1.setAnimationListener(new AnimationListener() {
public void onAnimationEnd(Animation animation) {
Animation anim;
if (holdAfter) {
anim = new TranslateAnimation(dx, dx, dy, dy);
// plenty of time for transitions
anim.setDuration(1000);
mAnimating = false;
} else {
anim = new AlphaAnimation(0.5f, 1.0f);
anim.setDuration(ANIM_DURATION);
resetView();
}
anim.setAnimationListener(mAnimationDoneListener);
/* Animation can be the same for these since the animation just holds */
mLeftSlider.startAnimation(anim, anim);
mRightSlider.startAnimation(anim, anim);
}
public void onAnimationRepeat(Animation animation) {
}
public void onAnimationStart(Animation animation) {
}
});
slider.hideTarget();
slider.startAnimation(trans1, trans2);
}
use of android.view.animation.Animation.AnimationListener in project Roundr by MohammadAdib.
the class StandOutWindow method hide.
/**
* Hide a window corresponding to the id. Show a notification for the hidden
* window.
*
* @param id
* The id of the window.
*/
public final synchronized void hide(int id) {
// get the view corresponding to the id
final Window window = getWindow(id);
if (window == null) {
throw new IllegalArgumentException("Tried to hide(" + id + ") a null window.");
}
if (window.visibility == Window.VISIBILITY_GONE) {
throw new IllegalStateException("Tried to hide(" + id + ") a window that is not shown.");
}
// alert callbacks and cancel if instructed
if (onHide(id, window)) {
Log.w(TAG, "Window " + id + " hide cancelled by implementation.");
return;
}
// check if hide enabled
if (Utils.isSet(window.flags, StandOutFlags.FLAG_WINDOW_HIDE_ENABLE)) {
window.visibility = Window.VISIBILITY_TRANSITION;
// get the hidden notification for this view
Notification notification = getHiddenNotification(id);
// get animation
Animation animation = getHideAnimation(id);
try {
// animate
if (animation != null) {
animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
// remove the window from the window manager
mWindowManager.removeView(window);
window.visibility = Window.VISIBILITY_GONE;
}
});
window.getChildAt(0).startAnimation(animation);
} else {
// remove the window from the window manager
mWindowManager.removeView(window);
}
} catch (Exception ex) {
ex.printStackTrace();
}
// display the notification
notification.flags = notification.flags | Notification.FLAG_NO_CLEAR | Notification.FLAG_AUTO_CANCEL;
mNotificationManager.notify(getClass().hashCode() + id, notification);
} else {
// if hide not enabled, close window
close(id);
}
}
use of android.view.animation.Animation.AnimationListener in project android-fb-like-slideout-navigation by AlexKorovyansky.
the class SlideoutHelper method initAnimations.
protected void initAnimations() {
int displayWidth = ((WindowManager) mActivity.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getWidth();
final int shift = (mReverse ? -1 : 1) * (sWidth - displayWidth);
mStartAnimation = new TranslateAnimation(TranslateAnimation.ABSOLUTE, 0, TranslateAnimation.ABSOLUTE, -shift, TranslateAnimation.ABSOLUTE, 0, TranslateAnimation.ABSOLUTE, 0);
mStopAnimation = new TranslateAnimation(TranslateAnimation.ABSOLUTE, 0, TranslateAnimation.ABSOLUTE, shift, TranslateAnimation.ABSOLUTE, 0, TranslateAnimation.ABSOLUTE, 0);
mStartAnimation.setDuration(DURATION_MS);
mStartAnimation.setFillAfter(true);
mStartAnimation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
mCover.setAnimation(null);
@SuppressWarnings("deprecation") final android.widget.AbsoluteLayout.LayoutParams lp = new android.widget.AbsoluteLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT, -shift, 0);
mCover.setLayoutParams(lp);
}
});
mStopAnimation.setDuration(DURATION_MS);
mStopAnimation.setFillAfter(true);
mStopAnimation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
mActivity.finish();
mActivity.overridePendingTransition(0, 0);
}
});
}
use of android.view.animation.Animation.AnimationListener in project FlycoDialog_Master by H07000223.
the class BottomTopBaseDialog method dismissWithAnim.
/** dimiss dialog and mAnimateView with inner dismiss com.flyco.animation(设置dialog和animateView消失动画) */
protected void dismissWithAnim() {
if (mInnerDismissAnim != null) {
mInnerDismissAnim.setDuration(mInnerAnimDuration);
mInnerDismissAnim.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
mIsInnerDismissAnim = true;
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
mIsInnerDismissAnim = false;
superDismiss();
}
});
mLlControlHeight.startAnimation(mInnerDismissAnim);
} else {
superDismiss();
}
if (mAnimateView != null) {
if (getWindowOutAs() != null) {
mWindowOutAs = getWindowOutAs();
}
mWindowOutAs.duration(mInnerAnimDuration).playOn(mAnimateView);
}
}
Aggregations