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 Roundr by MohammadAdib.
the class StandOutWindow method close.
/**
* Close a window corresponding to the id.
*
* @param id
* The id of the window.
*/
public final synchronized void close(final int id) {
// get the view corresponding to the id
final Window window = getWindow(id);
if (window == null) {
return;
}
if (window.visibility == Window.VISIBILITY_TRANSITION) {
return;
}
// alert callbacks and cancel if instructed
if (onClose(id, window)) {
Log.w(TAG, "Window " + id + " close cancelled by implementation.");
return;
}
// remove hidden notification
mNotificationManager.cancel(getClass().hashCode() + id);
unfocus(window);
window.visibility = Window.VISIBILITY_TRANSITION;
// get animation
Animation animation = getCloseAnimation(id);
// remove window
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;
// remove view from internal map
sWindowCache.removeCache(id, StandOutWindow.this.getClass());
// if we just released the last window, quit
if (getExistingIds().size() == 0) {
// tell Android to remove the persistent
// notification
// the Service will be shutdown by the system on low
// memory
startedForeground = false;
stopForeground(true);
}
}
});
window.getChildAt(0).startAnimation(animation);
} else {
// remove the window from the window manager
mWindowManager.removeView(window);
// remove view from internal map
sWindowCache.removeCache(id, getClass());
// if we just released the last window, quit
if (sWindowCache.getCacheSize(getClass()) == 0) {
// tell Android to remove the persistent notification
// the Service will be shutdown by the system on low memory
startedForeground = false;
stopForeground(true);
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
use of android.view.animation.Animation.AnimationListener in project JustAndroid by chinaltz.
the class AbAnimationUtil method playLandAnimation.
/**
* 跳动-落下动画.
*
* @param view the view
* @param offsetY the offset y
*/
private void playLandAnimation(final View view, final float offsetY) {
float originalY = -offsetY;
float finalY = 0;
AnimationSet animationSet = new AnimationSet(true);
animationSet.addAnimation(new TranslateAnimation(0, 0, originalY, finalY));
animationSet.setDuration(200);
animationSet.setInterpolator(new AccelerateInterpolator());
animationSet.setFillAfter(true);
animationSet.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
//两秒后再调
view.postDelayed(new Runnable() {
@Override
public void run() {
playJumpAnimation(view, offsetY);
}
}, 2000);
}
});
view.startAnimation(animationSet);
}
use of android.view.animation.Animation.AnimationListener in project JustAndroid by chinaltz.
the class AbAnimationUtil method playJumpAnimation.
/**
* 跳动-跳起动画.
*
* @param view the view
* @param offsetY the offset y
*/
private void playJumpAnimation(final View view, final float offsetY) {
float originalY = 0;
float finalY = -offsetY;
AnimationSet animationSet = new AnimationSet(true);
animationSet.addAnimation(new TranslateAnimation(0, 0, originalY, finalY));
animationSet.setDuration(300);
animationSet.setInterpolator(new AccelerateDecelerateInterpolator());
animationSet.setFillAfter(true);
animationSet.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
playLandAnimation(view, offsetY);
}
});
view.startAnimation(animationSet);
}
use of android.view.animation.Animation.AnimationListener in project superCleanMaster by joyoyao.
the class SplishActivity method setListener.
/**
* 监听事件
*/
public void setListener() {
/**
* 动画切换原理:开始时是用第一个渐现动画,当第一个动画结束时开始第二个放大动画,当第二个动画结束时调用第三个渐隐动画,
* 第三个动画结束时修改显示的内容并且重新调用第一个动画,从而达到循环效果
*/
mFadeIn.setAnimationListener(new AnimationListener() {
public void onAnimationStart(Animation animation) {
}
public void onAnimationRepeat(Animation animation) {
}
public void onAnimationEnd(Animation animation) {
mImageView.startAnimation(mFadeInScale);
}
});
mFadeInScale.setAnimationListener(new AnimationListener() {
public void onAnimationStart(Animation animation) {
}
public void onAnimationRepeat(Animation animation) {
}
public void onAnimationEnd(Animation animation) {
startActivity(MainActivity.class);
finish();
// mImageView.startAnimation(mFadeOut);
}
});
mFadeOut.setAnimationListener(new AnimationListener() {
public void onAnimationStart(Animation animation) {
}
public void onAnimationRepeat(Animation animation) {
}
public void onAnimationEnd(Animation animation) {
// startActivity(MainActivity.class);
}
});
}
Aggregations