Search in sources :

Example 71 with AnimationSet

use of android.view.animation.AnimationSet in project android_frameworks_base by ParanoidAndroid.

the class AppTransition method createThumbnailAnimationLocked.

Animation createThumbnailAnimationLocked(int transit, boolean enter, boolean thumb, int appWidth, int appHeight) {
    Animation a;
    final int thumbWidthI = mNextAppTransitionThumbnail.getWidth();
    final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1;
    final int thumbHeightI = mNextAppTransitionThumbnail.getHeight();
    final float thumbHeight = thumbHeightI > 0 ? thumbHeightI : 1;
    if (thumb) {
        // filling the screen.
        if (mNextAppTransitionScaleUp) {
            float scaleW = appWidth / thumbWidth;
            float scaleH = appHeight / thumbHeight;
            Animation scale = new ScaleAnimation(1, scaleW, 1, scaleH, computePivot(mNextAppTransitionStartX, 1 / scaleW), computePivot(mNextAppTransitionStartY, 1 / scaleH));
            scale.setInterpolator(mDecelerateInterpolator);
            Animation alpha = new AlphaAnimation(1, 0);
            alpha.setInterpolator(mThumbnailFadeoutInterpolator);
            // This AnimationSet uses the Interpolators assigned above.
            AnimationSet set = new AnimationSet(false);
            set.addAnimation(scale);
            set.addAnimation(alpha);
            a = set;
        } else {
            float scaleW = appWidth / thumbWidth;
            float scaleH = appHeight / thumbHeight;
            a = new ScaleAnimation(scaleW, 1, scaleH, 1, computePivot(mNextAppTransitionStartX, 1 / scaleW), computePivot(mNextAppTransitionStartY, 1 / scaleH));
        }
    } else if (enter) {
        // Entering app zooms out from the center of the thumbnail.
        if (mNextAppTransitionScaleUp) {
            float scaleW = thumbWidth / appWidth;
            float scaleH = thumbHeight / appHeight;
            a = new ScaleAnimation(scaleW, 1, scaleH, 1, computePivot(mNextAppTransitionStartX, scaleW), computePivot(mNextAppTransitionStartY, scaleH));
        } else {
            // noop animation
            a = new AlphaAnimation(1, 1);
        }
    } else {
        // Exiting app
        if (mNextAppTransitionScaleUp) {
            if (transit == TRANSIT_WALLPAPER_INTRA_OPEN) {
                // Fade out while bringing up selected activity. This keeps the
                // current activity from showing through a launching wallpaper
                // activity.
                a = new AlphaAnimation(1, 0);
            } else {
                // noop animation
                a = new AlphaAnimation(1, 1);
            }
        } else {
            float scaleW = thumbWidth / appWidth;
            float scaleH = thumbHeight / appHeight;
            Animation scale = new ScaleAnimation(1, scaleW, 1, scaleH, computePivot(mNextAppTransitionStartX, scaleW), computePivot(mNextAppTransitionStartY, scaleH));
            Animation alpha = new AlphaAnimation(1, 0);
            AnimationSet set = new AnimationSet(true);
            set.addAnimation(scale);
            set.addAnimation(alpha);
            set.setZAdjustment(Animation.ZORDER_TOP);
            a = set;
        }
    }
    // Pick the desired duration.  If this is an inter-activity transition,
    // it  is the standard duration for that.  Otherwise we use the longer
    // task transition duration.
    final long duration;
    switch(transit) {
        case TRANSIT_ACTIVITY_OPEN:
        case TRANSIT_ACTIVITY_CLOSE:
            duration = mConfigShortAnimTime;
            break;
        default:
            duration = DEFAULT_APP_TRANSITION_DURATION;
            break;
    }
    a.setDuration(duration);
    a.setFillAfter(true);
    a.setInterpolator(mDecelerateInterpolator);
    a.initialize(appWidth, appHeight, appWidth, appHeight);
    return a;
}
Also used : ScaleAnimation(android.view.animation.ScaleAnimation) WindowAnimation_wallpaperIntraCloseEnterAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperIntraCloseEnterAnimation) WindowAnimation_taskToBackExitAnimation(com.android.internal.R.styleable.WindowAnimation_taskToBackExitAnimation) WindowAnimation_wallpaperCloseExitAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperCloseExitAnimation) WindowAnimation_activityOpenEnterAnimation(com.android.internal.R.styleable.WindowAnimation_activityOpenEnterAnimation) WindowAnimation_wallpaperOpenExitAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperOpenExitAnimation) WindowAnimation_activityCloseEnterAnimation(com.android.internal.R.styleable.WindowAnimation_activityCloseEnterAnimation) WindowAnimation_taskToBackEnterAnimation(com.android.internal.R.styleable.WindowAnimation_taskToBackEnterAnimation) WindowAnimation_activityOpenExitAnimation(com.android.internal.R.styleable.WindowAnimation_activityOpenExitAnimation) WindowAnimation_taskCloseEnterAnimation(com.android.internal.R.styleable.WindowAnimation_taskCloseEnterAnimation) WindowAnimation_taskOpenEnterAnimation(com.android.internal.R.styleable.WindowAnimation_taskOpenEnterAnimation) Animation(android.view.animation.Animation) WindowAnimation_wallpaperIntraCloseExitAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperIntraCloseExitAnimation) WindowAnimation_taskOpenExitAnimation(com.android.internal.R.styleable.WindowAnimation_taskOpenExitAnimation) WindowAnimation_wallpaperOpenEnterAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperOpenEnterAnimation) WindowAnimation_activityCloseExitAnimation(com.android.internal.R.styleable.WindowAnimation_activityCloseExitAnimation) WindowAnimation_taskToFrontEnterAnimation(com.android.internal.R.styleable.WindowAnimation_taskToFrontEnterAnimation) WindowAnimation_wallpaperIntraOpenEnterAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperIntraOpenEnterAnimation) WindowAnimation_taskCloseExitAnimation(com.android.internal.R.styleable.WindowAnimation_taskCloseExitAnimation) WindowAnimation_wallpaperIntraOpenExitAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperIntraOpenExitAnimation) AlphaAnimation(android.view.animation.AlphaAnimation) WindowAnimation_taskToFrontExitAnimation(com.android.internal.R.styleable.WindowAnimation_taskToFrontExitAnimation) WindowAnimation_wallpaperCloseEnterAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperCloseEnterAnimation) AnimationSet(android.view.animation.AnimationSet) Point(android.graphics.Point) AlphaAnimation(android.view.animation.AlphaAnimation) ScaleAnimation(android.view.animation.ScaleAnimation)

Example 72 with AnimationSet

use of android.view.animation.AnimationSet in project android_frameworks_base by ParanoidAndroid.

the class ListWithDisappearingItemBug method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Toast.makeText(this, "Make sure you rotate screen to see bug", Toast.LENGTH_LONG).show();
    // Get a cursor with all people
    Cursor c = getContentResolver().query(People.CONTENT_URI, null, null, null, null);
    startManagingCursor(c);
    ListAdapter adapter = new SimpleCursorAdapter(this, // Use a template that displays a text view
    R.layout.list_with_disappearing_item_bug_item, // Give the cursor to the list adatper
    c, // Map the NAME column in the people database to...
    new String[] { People.NAME }, // The "text1" view defined in the XML template
    new int[] { R.id.text1 });
    setListAdapter(adapter);
    AnimationSet set = new AnimationSet(true);
    Animation animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(50);
    set.addAnimation(animation);
    animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, -1.0f, Animation.RELATIVE_TO_SELF, 0.0f);
    animation.setDuration(100);
    set.addAnimation(animation);
    LayoutAnimationController controller = new LayoutAnimationController(set, 0.5f);
    ListView listView = getListView();
    listView.setLayoutAnimation(controller);
}
Also used : ListView(android.widget.ListView) SimpleCursorAdapter(android.widget.SimpleCursorAdapter) LayoutAnimationController(android.view.animation.LayoutAnimationController) TranslateAnimation(android.view.animation.TranslateAnimation) AlphaAnimation(android.view.animation.AlphaAnimation) Animation(android.view.animation.Animation) TranslateAnimation(android.view.animation.TranslateAnimation) Cursor(android.database.Cursor) AnimationSet(android.view.animation.AnimationSet) ListAdapter(android.widget.ListAdapter) AlphaAnimation(android.view.animation.AlphaAnimation)

Example 73 with AnimationSet

use of android.view.animation.AnimationSet in project StickerCamera by Skykai521.

the class LabelView method wave.

public void wave() {
    AnimationSet as = new AnimationSet(true);
    ScaleAnimation sa = new ScaleAnimation(1f, 1.5f, 1f, 1.5f, ScaleAnimation.RELATIVE_TO_SELF, 0.5f, ScaleAnimation.RELATIVE_TO_SELF, 0.5f);
    sa.setDuration(ANIMATIONEACHOFFSET * 3);
    // 设置循环
    sa.setRepeatCount(10);
    AlphaAnimation aniAlp = new AlphaAnimation(1, 0.1f);
    // 设置循环
    aniAlp.setRepeatCount(10);
    as.setDuration(ANIMATIONEACHOFFSET * 3);
    as.addAnimation(sa);
    as.addAnimation(aniAlp);
    labelIcon.startAnimation(as);
}
Also used : AnimationSet(android.view.animation.AnimationSet) AlphaAnimation(android.view.animation.AlphaAnimation) ScaleAnimation(android.view.animation.ScaleAnimation)

Example 74 with AnimationSet

use of android.view.animation.AnimationSet in project cornerstone by Onskreen.

the class WindowManagerService method createThumbnailAnimationLocked.

private Animation createThumbnailAnimationLocked(int transit, boolean enter, boolean thumb, boolean delayed) {
    Animation a;
    final int thumbWidthI = mNextAppTransitionThumbnail.getWidth();
    final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1;
    final int thumbHeightI = mNextAppTransitionThumbnail.getHeight();
    final float thumbHeight = thumbHeightI > 0 ? thumbHeightI : 1;
    // Pick the desired duration.  If this is an inter-activity transition,
    // it  is the standard duration for that.  Otherwise we use the longer
    // task transition duration.
    int duration;
    int delayDuration = delayed ? 270 : 0;
    switch(transit) {
        case WindowManagerPolicy.TRANSIT_ACTIVITY_OPEN:
        case WindowManagerPolicy.TRANSIT_ACTIVITY_CLOSE:
            duration = mContext.getResources().getInteger(com.android.internal.R.integer.config_shortAnimTime);
            break;
        default:
            duration = delayed ? 250 : 300;
            break;
    }
    if (thumb) {
        // Animation for zooming thumbnail from its initial size to
        // filling the screen.
        float scaleW = mAppDisplayWidth / thumbWidth;
        float scaleH = mAppDisplayHeight / thumbHeight;
        Animation scale = new ScaleAnimation(1, scaleW, 1, scaleH, computePivot(mNextAppTransitionStartX, 1 / scaleW), computePivot(mNextAppTransitionStartY, 1 / scaleH));
        AnimationSet set = new AnimationSet(true);
        Animation alpha = new AlphaAnimation(1, 0);
        scale.setDuration(duration);
        scale.setInterpolator(new DecelerateInterpolator(THUMBNAIL_ANIMATION_DECELERATE_FACTOR));
        set.addAnimation(scale);
        alpha.setDuration(duration);
        set.addAnimation(alpha);
        set.setFillBefore(true);
        if (delayDuration > 0) {
            set.setStartOffset(delayDuration);
        }
        a = set;
    } else if (enter) {
        // Entering app zooms out from the center of the thumbnail.
        float scaleW = thumbWidth / mAppDisplayWidth;
        float scaleH = thumbHeight / mAppDisplayHeight;
        Animation scale = new ScaleAnimation(scaleW, 1, scaleH, 1, computePivot(mNextAppTransitionStartX, scaleW), computePivot(mNextAppTransitionStartY, scaleH));
        scale.setDuration(duration);
        scale.setInterpolator(new DecelerateInterpolator(THUMBNAIL_ANIMATION_DECELERATE_FACTOR));
        scale.setFillBefore(true);
        if (delayDuration > 0) {
            scale.setStartOffset(delayDuration);
        }
        a = scale;
    } else {
        if (delayed) {
            a = new AlphaAnimation(1, 0);
            a.setStartOffset(0);
            a.setDuration(delayDuration - 120);
            a.setBackgroundColor(0xFF000000);
        } else {
            a = createExitAnimationLocked(transit, duration);
        }
    }
    a.setFillAfter(true);
    final Interpolator interpolator = AnimationUtils.loadInterpolator(mContext, com.android.internal.R.interpolator.decelerate_quad);
    a.setInterpolator(interpolator);
    a.initialize(mAppDisplayWidth, mAppDisplayHeight, mAppDisplayWidth, mAppDisplayHeight);
    return a;
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) TranslateAnimation(android.view.animation.TranslateAnimation) AlphaAnimation(android.view.animation.AlphaAnimation) ScaleAnimation(android.view.animation.ScaleAnimation) Animation(android.view.animation.Animation) Interpolator(android.view.animation.Interpolator) DecelerateInterpolator(android.view.animation.DecelerateInterpolator) AnimationSet(android.view.animation.AnimationSet) Point(android.graphics.Point) AlphaAnimation(android.view.animation.AlphaAnimation) ScaleAnimation(android.view.animation.ScaleAnimation)

Example 75 with AnimationSet

use of android.view.animation.AnimationSet in project cornerstone by Onskreen.

the class WindowManagerService method createScaleUpAnimationLocked.

private Animation createScaleUpAnimationLocked(int transit, boolean enter) {
    Animation a;
    // Pick the desired duration.  If this is an inter-activity transition,
    // it  is the standard duration for that.  Otherwise we use the longer
    // task transition duration.
    int duration;
    switch(transit) {
        case WindowManagerPolicy.TRANSIT_ACTIVITY_OPEN:
        case WindowManagerPolicy.TRANSIT_ACTIVITY_CLOSE:
            duration = mContext.getResources().getInteger(com.android.internal.R.integer.config_shortAnimTime);
            break;
        default:
            duration = 300;
            break;
    }
    if (enter) {
        // Entering app zooms out from the center of the initial rect.
        float scaleW = mNextAppTransitionStartWidth / (float) mAppDisplayWidth;
        float scaleH = mNextAppTransitionStartHeight / (float) mAppDisplayHeight;
        Animation scale = new ScaleAnimation(scaleW, 1, scaleH, 1, computePivot(mNextAppTransitionStartX, scaleW), computePivot(mNextAppTransitionStartY, scaleH));
        scale.setDuration(duration);
        AnimationSet set = new AnimationSet(true);
        Animation alpha = new AlphaAnimation(0, 1);
        scale.setDuration(duration);
        set.addAnimation(scale);
        alpha.setDuration(duration);
        set.addAnimation(alpha);
        set.setDetachWallpaper(true);
        a = set;
    } else {
        a = createExitAnimationLocked(transit, duration);
    }
    a.setFillAfter(true);
    final Interpolator interpolator = AnimationUtils.loadInterpolator(mContext, com.android.internal.R.interpolator.decelerate_cubic);
    a.setInterpolator(interpolator);
    a.initialize(mAppDisplayWidth, mAppDisplayHeight, mAppDisplayWidth, mAppDisplayHeight);
    return a;
}
Also used : TranslateAnimation(android.view.animation.TranslateAnimation) AlphaAnimation(android.view.animation.AlphaAnimation) ScaleAnimation(android.view.animation.ScaleAnimation) Animation(android.view.animation.Animation) Interpolator(android.view.animation.Interpolator) DecelerateInterpolator(android.view.animation.DecelerateInterpolator) AnimationSet(android.view.animation.AnimationSet) Point(android.graphics.Point) AlphaAnimation(android.view.animation.AlphaAnimation) ScaleAnimation(android.view.animation.ScaleAnimation)

Aggregations

AnimationSet (android.view.animation.AnimationSet)118 AlphaAnimation (android.view.animation.AlphaAnimation)86 TranslateAnimation (android.view.animation.TranslateAnimation)75 Animation (android.view.animation.Animation)71 ScaleAnimation (android.view.animation.ScaleAnimation)69 ClipRectAnimation (android.view.animation.ClipRectAnimation)32 CurvedTranslateAnimation (com.android.server.wm.animation.CurvedTranslateAnimation)32 WindowAnimation_activityCloseEnterAnimation (com.android.internal.R.styleable.WindowAnimation_activityCloseEnterAnimation)30 WindowAnimation_activityCloseExitAnimation (com.android.internal.R.styleable.WindowAnimation_activityCloseExitAnimation)30 WindowAnimation_activityOpenEnterAnimation (com.android.internal.R.styleable.WindowAnimation_activityOpenEnterAnimation)30 WindowAnimation_activityOpenExitAnimation (com.android.internal.R.styleable.WindowAnimation_activityOpenExitAnimation)30 WindowAnimation_taskCloseEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskCloseEnterAnimation)30 WindowAnimation_taskCloseExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskCloseExitAnimation)30 WindowAnimation_taskOpenEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskOpenEnterAnimation)30 WindowAnimation_taskOpenExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskOpenExitAnimation)30 WindowAnimation_taskToBackEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskToBackEnterAnimation)30 WindowAnimation_taskToBackExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskToBackExitAnimation)30 WindowAnimation_taskToFrontEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskToFrontEnterAnimation)30 WindowAnimation_taskToFrontExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskToFrontExitAnimation)30 WindowAnimation_wallpaperCloseEnterAnimation (com.android.internal.R.styleable.WindowAnimation_wallpaperCloseEnterAnimation)30