Search in sources :

Example 91 with Animation

use of android.view.animation.Animation in project Talon-for-Twitter by klinker24.

the class SettingsActivityOld method switchToSettingsList.

private void switchToSettingsList(boolean settings) {
    if (settings && settingsList.getVisibility() != View.VISIBLE) {
        // animate the settings list showing and other list hiding
        Animation in = AnimationUtils.loadAnimation(this, android.R.anim.fade_in);
        Animation out = AnimationUtils.loadAnimation(this, R.anim.slide_out_right);
        in.setDuration(ANIM_TIME * 2);
        out.setDuration(ANIM_TIME);
        in.setAnimationListener(new Animation.AnimationListener() {

            @Override
            public void onAnimationStart(Animation animation) {
                settingsList.setVisibility(View.VISIBLE);
            }

            @Override
            public void onAnimationEnd(Animation animation) {
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }
        });
        out.setAnimationListener(new Animation.AnimationListener() {

            @Override
            public void onAnimationStart(Animation animation) {
                otherList.setVisibility(View.VISIBLE);
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                otherList.setVisibility(View.GONE);
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }
        });
        settingsList.startAnimation(in);
        otherList.startAnimation(out);
    } else if (!settings && otherList.getVisibility() != View.VISIBLE) {
        // animate the other list showing and settings list hiding
        Animation in = AnimationUtils.loadAnimation(this, android.R.anim.fade_in);
        Animation out = AnimationUtils.loadAnimation(this, R.anim.slide_out_left);
        in.setDuration(ANIM_TIME * 2);
        out.setDuration(ANIM_TIME);
        in.setAnimationListener(new Animation.AnimationListener() {

            @Override
            public void onAnimationStart(Animation animation) {
                otherList.setVisibility(View.VISIBLE);
            }

            @Override
            public void onAnimationEnd(Animation animation) {
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }
        });
        out.setAnimationListener(new Animation.AnimationListener() {

            @Override
            public void onAnimationStart(Animation animation) {
                settingsList.setVisibility(View.VISIBLE);
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                settingsList.setVisibility(View.GONE);
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }
        });
        settingsList.startAnimation(out);
        otherList.startAnimation(in);
    }
}
Also used : Animation(android.view.animation.Animation)

Example 92 with Animation

use of android.view.animation.Animation in project glitch-hq-android by tinyspeck.

the class HomeScreen method dismissSidebar.

public void dismissSidebar() {
    // Get display width
    Display display = getWindowManager().getDefaultDisplay();
    int width = display.getWidth();
    // Create the dismiss animation
    Animation animation = new TranslateAnimation(width, 0, 0, 0);
    animation.setDuration(m_sidebarAnimationDuration);
    animation.setAnimationListener(new AnimationListener() {

        public void onAnimationEnd(Animation animation) {
            // Get display width
            Display display = getWindowManager().getDefaultDisplay();
            // Move back to normal position and fill the whole display
            // width-wise
            // m_stack.layout(-27, 0, display.getWidth(),
            // m_stack.getHeight());
            HomeScreen.this.m_showingSidebar = false;
        }

        public void onAnimationRepeat(Animation animation) {
        }

        public void onAnimationStart(Animation animation) {
        }
    });
    animation.setFillAfter(true);
    // Run the dismiss animation
    m_stack.startAnimation(animation);
    m_stack.getParent().bringChildToFront(m_stack);
}
Also used : TranslateAnimation(android.view.animation.TranslateAnimation) Animation(android.view.animation.Animation) TranslateAnimation(android.view.animation.TranslateAnimation) AnimationListener(android.view.animation.Animation.AnimationListener) Display(android.view.Display)

Example 93 with Animation

use of android.view.animation.Animation in project platform_frameworks_base by android.

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 94 with Animation

use of android.view.animation.Animation in project platform_frameworks_base by android.

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 95 with Animation

use of android.view.animation.Animation in project platform_frameworks_base by android.

the class WindowStateAnimator method setMoveAnimation.

void setMoveAnimation(int left, int top) {
    final Animation a = AnimationUtils.loadAnimation(mContext, com.android.internal.R.anim.window_move_from_decor);
    setAnimation(a);
    mAnimDx = mWin.mLastFrame.left - left;
    mAnimDy = mWin.mLastFrame.top - top;
    mAnimateMove = true;
}
Also used : AppWindowAnimator.sDummyAnimation(com.android.server.wm.AppWindowAnimator.sDummyAnimation) Animation(android.view.animation.Animation)

Aggregations

Animation (android.view.animation.Animation)943 AlphaAnimation (android.view.animation.AlphaAnimation)241 TranslateAnimation (android.view.animation.TranslateAnimation)190 ScaleAnimation (android.view.animation.ScaleAnimation)146 Transformation (android.view.animation.Transformation)114 View (android.view.View)104 AnimationListener (android.view.animation.Animation.AnimationListener)98 AnimationSet (android.view.animation.AnimationSet)94 RotateAnimation (android.view.animation.RotateAnimation)63 ImageView (android.widget.ImageView)48 TextView (android.widget.TextView)47 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)43 Point (android.graphics.Point)40 WindowAnimation_activityCloseEnterAnimation (com.android.internal.R.styleable.WindowAnimation_activityCloseEnterAnimation)35 WindowAnimation_activityCloseExitAnimation (com.android.internal.R.styleable.WindowAnimation_activityCloseExitAnimation)35 WindowAnimation_activityOpenEnterAnimation (com.android.internal.R.styleable.WindowAnimation_activityOpenEnterAnimation)35 WindowAnimation_activityOpenExitAnimation (com.android.internal.R.styleable.WindowAnimation_activityOpenExitAnimation)35 WindowAnimation_taskCloseEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskCloseEnterAnimation)35 WindowAnimation_taskCloseExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskCloseExitAnimation)35 WindowAnimation_taskOpenEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskOpenEnterAnimation)35