Search in sources :

Example 26 with AlphaAnimation

use of android.view.animation.AlphaAnimation in project android_frameworks_base by DirtyUnicorns.

the class AppTransition method createThumbnailScaleAnimationLocked.

/**
     * This animation runs for the thumbnail that gets cross faded with the enter/exit activity
     * when a thumbnail is specified with the pending animation override.
     */
Animation createThumbnailScaleAnimationLocked(int appWidth, int appHeight, int transit, Bitmap thumbnailHeader) {
    Animation a;
    getDefaultNextAppTransitionStartRect(mTmpRect);
    final int thumbWidthI = thumbnailHeader.getWidth();
    final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1;
    final int thumbHeightI = thumbnailHeader.getHeight();
    final float thumbHeight = thumbHeightI > 0 ? thumbHeightI : 1;
    if (mNextAppTransitionScaleUp) {
        // Animation for the thumbnail zooming from its initial size to the full screen
        float scaleW = appWidth / thumbWidth;
        float scaleH = appHeight / thumbHeight;
        Animation scale = new ScaleAnimation(1, scaleW, 1, scaleH, computePivot(mTmpRect.left, 1 / scaleW), computePivot(mTmpRect.top, 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 {
        // Animation for the thumbnail zooming down from the full screen to its final size
        float scaleW = appWidth / thumbWidth;
        float scaleH = appHeight / thumbHeight;
        a = new ScaleAnimation(scaleW, 1, scaleH, 1, computePivot(mTmpRect.left, 1 / scaleW), computePivot(mTmpRect.top, 1 / scaleH));
    }
    return prepareThumbnailAnimation(a, appWidth, appHeight, transit);
}
Also used : ScaleAnimation(android.view.animation.ScaleAnimation) WindowAnimation_wallpaperCloseExitAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperCloseExitAnimation) CurvedTranslateAnimation(com.android.server.wm.animation.CurvedTranslateAnimation) WindowAnimation_activityOpenEnterAnimation(com.android.internal.R.styleable.WindowAnimation_activityOpenEnterAnimation) WindowAnimation_wallpaperOpenExitAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperOpenExitAnimation) WindowAnimation_taskToBackEnterAnimation(com.android.internal.R.styleable.WindowAnimation_taskToBackEnterAnimation) WindowAnimation_activityOpenExitAnimation(com.android.internal.R.styleable.WindowAnimation_activityOpenExitAnimation) TranslateAnimation(android.view.animation.TranslateAnimation) Animation(android.view.animation.Animation) ClipRectAnimation(android.view.animation.ClipRectAnimation) WindowAnimation_wallpaperOpenEnterAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperOpenEnterAnimation) WindowAnimation_launchTaskBehindTargetAnimation(com.android.internal.R.styleable.WindowAnimation_launchTaskBehindTargetAnimation) WindowAnimation_launchTaskBehindSourceAnimation(com.android.internal.R.styleable.WindowAnimation_launchTaskBehindSourceAnimation) WindowAnimation_taskCloseExitAnimation(com.android.internal.R.styleable.WindowAnimation_taskCloseExitAnimation) AlphaAnimation(android.view.animation.AlphaAnimation) WindowAnimation_wallpaperIntraCloseEnterAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperIntraCloseEnterAnimation) WindowAnimation_taskToBackExitAnimation(com.android.internal.R.styleable.WindowAnimation_taskToBackExitAnimation) WindowAnimation_activityCloseEnterAnimation(com.android.internal.R.styleable.WindowAnimation_activityCloseEnterAnimation) WindowAnimation_taskCloseEnterAnimation(com.android.internal.R.styleable.WindowAnimation_taskCloseEnterAnimation) WindowAnimation_taskOpenEnterAnimation(com.android.internal.R.styleable.WindowAnimation_taskOpenEnterAnimation) WindowAnimation_wallpaperIntraCloseExitAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperIntraCloseExitAnimation) ClipRectTBAnimation(com.android.server.wm.animation.ClipRectTBAnimation) WindowAnimation_taskOpenExitAnimation(com.android.internal.R.styleable.WindowAnimation_taskOpenExitAnimation) ClipRectLRAnimation(com.android.server.wm.animation.ClipRectLRAnimation) 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_wallpaperIntraOpenExitAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperIntraOpenExitAnimation) WindowAnimation_taskToFrontExitAnimation(com.android.internal.R.styleable.WindowAnimation_taskToFrontExitAnimation) WindowAnimation_wallpaperCloseEnterAnimation(com.android.internal.R.styleable.WindowAnimation_wallpaperCloseEnterAnimation) AnimationSet(android.view.animation.AnimationSet) AlphaAnimation(android.view.animation.AlphaAnimation) ScaleAnimation(android.view.animation.ScaleAnimation)

Example 27 with AlphaAnimation

use of android.view.animation.AlphaAnimation in project android_frameworks_base by DirtyUnicorns.

the class WindowAnimator method updateWindowsLocked.

private void updateWindowsLocked(final int displayId) {
    ++mAnimTransactionSequence;
    final WindowList windows = mService.getWindowListLocked(displayId);
    final boolean keyguardGoingAwayToShade = (mKeyguardGoingAwayFlags & KEYGUARD_GOING_AWAY_FLAG_TO_SHADE) != 0;
    final boolean keyguardGoingAwayNoAnimation = (mKeyguardGoingAwayFlags & KEYGUARD_GOING_AWAY_FLAG_NO_WINDOW_ANIMATIONS) != 0;
    final boolean keyguardGoingAwayWithWallpaper = (mKeyguardGoingAwayFlags & KEYGUARD_GOING_AWAY_FLAG_WITH_WALLPAPER) != 0;
    if (mKeyguardGoingAway) {
        for (int i = windows.size() - 1; i >= 0; i--) {
            WindowState win = windows.get(i);
            if (!mPolicy.isKeyguardHostWindow(win.mAttrs)) {
                continue;
            }
            final WindowStateAnimator winAnimator = win.mWinAnimator;
            if ((win.mAttrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) {
                if (!winAnimator.mAnimating) {
                    if (DEBUG_KEYGUARD)
                        Slog.d(TAG, "updateWindowsLocked: creating delay animation");
                    // Create a new animation to delay until keyguard is gone on its own.
                    winAnimator.mAnimation = new AlphaAnimation(1.0f, 1.0f);
                    winAnimator.mAnimation.setDuration(KEYGUARD_ANIM_TIMEOUT_MS);
                    winAnimator.mAnimationIsEntrance = false;
                    winAnimator.mAnimationStartTime = -1;
                    winAnimator.mKeyguardGoingAwayAnimation = true;
                    winAnimator.mKeyguardGoingAwayWithWallpaper = keyguardGoingAwayWithWallpaper;
                }
            } else {
                if (DEBUG_KEYGUARD)
                    Slog.d(TAG, "updateWindowsLocked: StatusBar is no longer keyguard");
                mKeyguardGoingAway = false;
                winAnimator.clearAnimation();
            }
            break;
        }
    }
    mForceHiding = KEYGUARD_NOT_SHOWN;
    boolean wallpaperInUnForceHiding = false;
    boolean startingInUnForceHiding = false;
    ArrayList<WindowStateAnimator> unForceHiding = null;
    WindowState wallpaper = null;
    final WallpaperController wallpaperController = mService.mWallpaperControllerLocked;
    for (int i = windows.size() - 1; i >= 0; i--) {
        WindowState win = windows.get(i);
        WindowStateAnimator winAnimator = win.mWinAnimator;
        final int flags = win.mAttrs.flags;
        boolean canBeForceHidden = mPolicy.canBeForceHidden(win, win.mAttrs);
        boolean shouldBeForceHidden = shouldForceHide(win);
        if (winAnimator.hasSurface()) {
            final boolean wasAnimating = winAnimator.mWasAnimating;
            final boolean nowAnimating = winAnimator.stepAnimationLocked(mCurrentTime);
            winAnimator.mWasAnimating = nowAnimating;
            orAnimating(nowAnimating);
            if (DEBUG_WALLPAPER) {
                Slog.v(TAG, win + ": wasAnimating=" + wasAnimating + ", nowAnimating=" + nowAnimating);
            }
            if (wasAnimating && !winAnimator.mAnimating && wallpaperController.isWallpaperTarget(win)) {
                mBulkUpdateParams |= SET_WALLPAPER_MAY_CHANGE;
                setPendingLayoutChanges(Display.DEFAULT_DISPLAY, WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER);
                if (DEBUG_LAYOUT_REPEATS) {
                    mWindowPlacerLocked.debugLayoutRepeats("updateWindowsAndWallpaperLocked 2", getPendingLayoutChanges(Display.DEFAULT_DISPLAY));
                }
            }
            if (mPolicy.isForceHiding(win.mAttrs)) {
                if (!wasAnimating && nowAnimating) {
                    if (DEBUG_KEYGUARD || DEBUG_ANIM || DEBUG_VISIBILITY)
                        Slog.v(TAG, "Animation started that could impact force hide: " + win);
                    mBulkUpdateParams |= SET_FORCE_HIDING_CHANGED;
                    setPendingLayoutChanges(displayId, WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER);
                    if (DEBUG_LAYOUT_REPEATS) {
                        mWindowPlacerLocked.debugLayoutRepeats("updateWindowsAndWallpaperLocked 3", getPendingLayoutChanges(displayId));
                    }
                    mService.mFocusMayChange = true;
                } else if (mKeyguardGoingAway && !nowAnimating) {
                    // Timeout!!
                    Slog.e(TAG, "Timeout waiting for animation to startup");
                    mPolicy.startKeyguardExitAnimation(0, 0);
                    mKeyguardGoingAway = false;
                }
                if (win.isReadyForDisplay()) {
                    if (nowAnimating && win.mWinAnimator.mKeyguardGoingAwayAnimation) {
                        mForceHiding = KEYGUARD_ANIMATING_OUT;
                    } else {
                        mForceHiding = win.isDrawnLw() ? KEYGUARD_SHOWN : KEYGUARD_NOT_SHOWN;
                    }
                }
                if (DEBUG_KEYGUARD || DEBUG_VISIBILITY)
                    Slog.v(TAG, "Force hide " + forceHidingToString() + " hasSurface=" + win.mHasSurface + " policyVis=" + win.mPolicyVisibility + " destroying=" + win.mDestroying + " attHidden=" + win.mAttachedHidden + " vis=" + win.mViewVisibility + " hidden=" + win.mRootToken.hidden + " anim=" + win.mWinAnimator.mAnimation);
            } else if (canBeForceHidden) {
                if (shouldBeForceHidden) {
                    if (!win.hideLw(false, false)) {
                        // Was already hidden
                        continue;
                    }
                    if (DEBUG_KEYGUARD || DEBUG_VISIBILITY)
                        Slog.v(TAG, "Now policy hidden: " + win);
                } else {
                    boolean applyExistingExitAnimation = mPostKeyguardExitAnimation != null && !mPostKeyguardExitAnimation.hasEnded() && !winAnimator.mKeyguardGoingAwayAnimation && win.hasDrawnLw() && win.mAttachedWindow == null && !win.mIsImWindow && displayId == Display.DEFAULT_DISPLAY;
                    // Keyguard exit animation, skip.
                    if (!win.showLw(false, false) && !applyExistingExitAnimation) {
                        continue;
                    }
                    final boolean visibleNow = win.isVisibleNow();
                    if (!visibleNow) {
                        // Couldn't really show, must showLw() again when win becomes visible.
                        win.hideLw(false, false);
                        continue;
                    }
                    if (DEBUG_KEYGUARD || DEBUG_VISIBILITY)
                        Slog.v(TAG, "Now policy shown: " + win);
                    if ((mBulkUpdateParams & SET_FORCE_HIDING_CHANGED) != 0 && win.mAttachedWindow == null) {
                        if (unForceHiding == null) {
                            unForceHiding = new ArrayList<>();
                        }
                        unForceHiding.add(winAnimator);
                        if ((flags & FLAG_SHOW_WALLPAPER) != 0) {
                            wallpaperInUnForceHiding = true;
                        }
                        if (win.mAttrs.type == TYPE_APPLICATION_STARTING) {
                            startingInUnForceHiding = true;
                        }
                    } else if (applyExistingExitAnimation) {
                        // animation to bring in this window.
                        if (DEBUG_KEYGUARD)
                            Slog.v(TAG, "Applying existing Keyguard exit animation to new window: win=" + win);
                        Animation a = mPolicy.createForceHideEnterAnimation(false, keyguardGoingAwayToShade);
                        winAnimator.setAnimation(a, mPostKeyguardExitAnimation.getStartTime(), STACK_CLIP_BEFORE_ANIM);
                        winAnimator.mKeyguardGoingAwayAnimation = true;
                        winAnimator.mKeyguardGoingAwayWithWallpaper = keyguardGoingAwayWithWallpaper;
                    }
                    final WindowState currentFocus = mService.mCurrentFocus;
                    if (currentFocus == null || currentFocus.mLayer < win.mLayer) {
                        // sure it is correct.
                        if (DEBUG_FOCUS_LIGHT)
                            Slog.v(TAG, "updateWindowsLocked: setting mFocusMayChange true");
                        mService.mFocusMayChange = true;
                    }
                }
                if ((flags & FLAG_SHOW_WALLPAPER) != 0) {
                    mBulkUpdateParams |= SET_WALLPAPER_MAY_CHANGE;
                    setPendingLayoutChanges(Display.DEFAULT_DISPLAY, WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER);
                    if (DEBUG_LAYOUT_REPEATS) {
                        mWindowPlacerLocked.debugLayoutRepeats("updateWindowsAndWallpaperLocked 4", getPendingLayoutChanges(Display.DEFAULT_DISPLAY));
                    }
                }
            }
        } else // policy visibility.
        if (canBeForceHidden) {
            if (shouldBeForceHidden) {
                win.hideLw(false, false);
            } else {
                win.showLw(false, false);
            }
        }
        final AppWindowToken atoken = win.mAppToken;
        if (winAnimator.mDrawState == READY_TO_SHOW) {
            if (atoken == null || atoken.allDrawn) {
                if (winAnimator.performShowLocked()) {
                    setPendingLayoutChanges(displayId, WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM);
                    if (DEBUG_LAYOUT_REPEATS) {
                        mWindowPlacerLocked.debugLayoutRepeats("updateWindowsAndWallpaperLocked 5", getPendingLayoutChanges(displayId));
                    }
                }
            }
        }
        final AppWindowAnimator appAnimator = winAnimator.mAppAnimator;
        if (appAnimator != null && appAnimator.thumbnail != null) {
            if (appAnimator.thumbnailTransactionSeq != mAnimTransactionSequence) {
                appAnimator.thumbnailTransactionSeq = mAnimTransactionSequence;
                appAnimator.thumbnailLayer = 0;
            }
            if (appAnimator.thumbnailLayer < winAnimator.mAnimLayer) {
                appAnimator.thumbnailLayer = winAnimator.mAnimLayer;
            }
        }
        if (win.mIsWallpaper) {
            wallpaper = win;
        }
    }
    // disabled.
    if (unForceHiding != null) {
        if (!keyguardGoingAwayNoAnimation) {
            boolean first = true;
            for (int i = unForceHiding.size() - 1; i >= 0; i--) {
                final WindowStateAnimator winAnimator = unForceHiding.get(i);
                Animation a = mPolicy.createForceHideEnterAnimation(wallpaperInUnForceHiding && !startingInUnForceHiding, keyguardGoingAwayToShade);
                if (a != null) {
                    if (DEBUG_KEYGUARD)
                        Slog.v(TAG, "Starting keyguard exit animation on window " + winAnimator.mWin);
                    winAnimator.setAnimation(a, STACK_CLIP_BEFORE_ANIM);
                    winAnimator.mKeyguardGoingAwayAnimation = true;
                    winAnimator.mKeyguardGoingAwayWithWallpaper = keyguardGoingAwayWithWallpaper;
                    if (first) {
                        mPostKeyguardExitAnimation = a;
                        mPostKeyguardExitAnimation.setStartTime(mCurrentTime);
                        first = false;
                    }
                }
            }
        } else if (mKeyguardGoingAway) {
            mPolicy.startKeyguardExitAnimation(mCurrentTime, 0);
            mKeyguardGoingAway = false;
        }
        // Wallpaper is going away in un-force-hide motion, animate it as well.
        if (!wallpaperInUnForceHiding && wallpaper != null && !keyguardGoingAwayNoAnimation) {
            if (DEBUG_KEYGUARD)
                Slog.d(TAG, "updateWindowsLocked: wallpaper animating away");
            Animation a = mPolicy.createForceHideWallpaperExitAnimation(keyguardGoingAwayToShade);
            if (a != null) {
                wallpaper.mWinAnimator.setAnimation(a);
            }
        }
    }
    if (mPostKeyguardExitAnimation != null) {
        // We're in the midst of a keyguard exit animation.
        if (mKeyguardGoingAway) {
            mPolicy.startKeyguardExitAnimation(mCurrentTime + mPostKeyguardExitAnimation.getStartOffset(), mPostKeyguardExitAnimation.getDuration());
            mKeyguardGoingAway = false;
        } else // ended normally and cancelled case, and check the time for the "orphaned" case.
        if (mPostKeyguardExitAnimation.hasEnded() || mCurrentTime - mPostKeyguardExitAnimation.getStartTime() > mPostKeyguardExitAnimation.getDuration()) {
            // Done with the animation, reset.
            if (DEBUG_KEYGUARD)
                Slog.v(TAG, "Done with Keyguard exit animations.");
            mPostKeyguardExitAnimation = null;
        }
    }
    final WindowState winShowWhenLocked = (WindowState) mPolicy.getWinShowWhenLockedLw();
    if (winShowWhenLocked != null) {
        mLastShowWinWhenLocked = winShowWhenLocked;
    }
}
Also used : ArrayList(java.util.ArrayList) Animation(android.view.animation.Animation) AlphaAnimation(android.view.animation.AlphaAnimation) AlphaAnimation(android.view.animation.AlphaAnimation)

Example 28 with AlphaAnimation

use of android.view.animation.AlphaAnimation in project android_frameworks_base by DirtyUnicorns.

the class TransformsAndAnimationsActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.transforms_and_animations);
    button1 = (Button) findViewById(R.id.button1);
    button2 = (Button) findViewById(R.id.button2);
    button3 = (Button) findViewById(R.id.button3);
    button1a = (Button) findViewById(R.id.button1a);
    button2a = (Button) findViewById(R.id.button2a);
    button3a = (Button) findViewById(R.id.button3a);
    button1b = (Button) findViewById(R.id.button1b);
    button2b = (Button) findViewById(R.id.button2b);
    button3b = (Button) findViewById(R.id.button3b);
    button4 = (Button) findViewById(R.id.button4);
    button5 = (Button) findViewById(R.id.button5);
    button6 = (Button) findViewById(R.id.button6);
    button7 = (Button) findViewById(R.id.button7);
    button8 = (Button) findViewById(R.id.button8);
    layersNoneCB = (CheckBox) findViewById(R.id.layersNoneCB);
    layersHardwareCB = (CheckBox) findViewById(R.id.layersHwCB);
    layersSoftwareCB = (CheckBox) findViewById(R.id.layersSwCB);
    layersNoneCB.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                setLayerType(View.LAYER_TYPE_NONE);
                layersHardwareCB.setChecked(false);
                layersSoftwareCB.setChecked(false);
            }
        }
    });
    layersSoftwareCB.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                setLayerType(View.LAYER_TYPE_SOFTWARE);
                layersHardwareCB.setChecked(false);
                layersNoneCB.setChecked(false);
            }
        }
    });
    layersHardwareCB.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                setLayerType(View.LAYER_TYPE_HARDWARE);
                layersNoneCB.setChecked(false);
                layersSoftwareCB.setChecked(false);
            }
        }
    });
    button1a.setAlpha(.5f);
    button2a.setAlpha(.5f);
    button3a.setAlpha(.5f);
    button3.setTranslationX(50);
    button7.setTranslationX(50);
    button8.setTranslationX(50);
    final AlphaAnimation alphaAnim = new AlphaAnimation(1, 0);
    alphaAnim.setDuration(1000);
    alphaAnim.setRepeatCount(Animation.INFINITE);
    alphaAnim.setRepeatMode(Animation.REVERSE);
    final TranslateAnimation transAnim = new TranslateAnimation(0, -50, 0, 0);
    transAnim.setDuration(1000);
    transAnim.setRepeatCount(Animation.INFINITE);
    transAnim.setRepeatMode(Animation.REVERSE);
    getWindow().getDecorView().postDelayed(new Runnable() {

        @Override
        public void run() {
            button1.startAnimation(alphaAnim);
            button2.startAnimation(alphaAnim);
            button3.startAnimation(alphaAnim);
            button1a.startAnimation(alphaAnim);
            button2a.startAnimation(alphaAnim);
            button3a.startAnimation(alphaAnim);
            button1b.startAnimation(alphaAnim);
            button2b.startAnimation(alphaAnim);
            button3b.startAnimation(alphaAnim);
            startAnimator(button1b);
            startAnimator(button2b);
            startAnimator(button3b);
            button7.startAnimation(transAnim);
            button8.startAnimation(transAnim);
        }
    }, 2000);
}
Also used : CheckBox(android.widget.CheckBox) TranslateAnimation(android.view.animation.TranslateAnimation) CompoundButton(android.widget.CompoundButton) AlphaAnimation(android.view.animation.AlphaAnimation)

Example 29 with AlphaAnimation

use of android.view.animation.AlphaAnimation in project android_frameworks_base by DirtyUnicorns.

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 30 with AlphaAnimation

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

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);
}
Also used : LinearInterpolator(android.view.animation.LinearInterpolator) TranslateAnimation(android.view.animation.TranslateAnimation) AlphaAnimation(android.view.animation.AlphaAnimation) Animation(android.view.animation.Animation) TranslateAnimation(android.view.animation.TranslateAnimation) AnimationListener(android.view.animation.Animation.AnimationListener) AlphaAnimation(android.view.animation.AlphaAnimation)

Aggregations

AlphaAnimation (android.view.animation.AlphaAnimation)349 Animation (android.view.animation.Animation)152 TranslateAnimation (android.view.animation.TranslateAnimation)102 AnimationSet (android.view.animation.AnimationSet)101 ScaleAnimation (android.view.animation.ScaleAnimation)65 View (android.view.View)33 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)30 LinearInterpolator (android.view.animation.LinearInterpolator)28 WindowAnimation_activityCloseEnterAnimation (com.android.internal.R.styleable.WindowAnimation_activityCloseEnterAnimation)26 WindowAnimation_activityCloseExitAnimation (com.android.internal.R.styleable.WindowAnimation_activityCloseExitAnimation)26 WindowAnimation_activityOpenEnterAnimation (com.android.internal.R.styleable.WindowAnimation_activityOpenEnterAnimation)26 WindowAnimation_activityOpenExitAnimation (com.android.internal.R.styleable.WindowAnimation_activityOpenExitAnimation)26 WindowAnimation_taskCloseEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskCloseEnterAnimation)26 WindowAnimation_taskCloseExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskCloseExitAnimation)26 WindowAnimation_taskOpenEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskOpenEnterAnimation)26 WindowAnimation_taskOpenExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskOpenExitAnimation)26 WindowAnimation_taskToBackEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskToBackEnterAnimation)26 WindowAnimation_taskToBackExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskToBackExitAnimation)26 WindowAnimation_taskToFrontEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskToFrontEnterAnimation)26 WindowAnimation_taskToFrontExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskToFrontExitAnimation)26