Example usage for android.animation AnimatorListenerAdapter AnimatorListenerAdapter

List of usage examples for android.animation AnimatorListenerAdapter AnimatorListenerAdapter

Introduction

In this page you can find the example usage for android.animation AnimatorListenerAdapter AnimatorListenerAdapter.

Prototype

AnimatorListenerAdapter

Source Link

Usage

From source file:android.app.FragmentManager.java

void moveToState(Fragment f, int newState, int transit, int transitionStyle, boolean keepActive) {
    if (DEBUG && false)
        Log.v(TAG, "moveToState: " + f + " oldState=" + f.mState + " newState=" + newState + " mRemoving="
                + f.mRemoving + " Callers=" + Debug.getCallers(5));

    // Fragments that are not currently added will sit in the onCreate() state.
    if ((!f.mAdded || f.mDetached) && newState > Fragment.CREATED) {
        newState = Fragment.CREATED;/*from w w  w.j a  va2 s  .  c  o  m*/
    }
    if (f.mRemoving && newState > f.mState) {
        // While removing a fragment, we can't change it to a higher state.
        newState = f.mState;
    }
    // Defer start if requested; don't allow it to move to STARTED or higher
    // if it's not already started.
    if (f.mDeferStart && f.mState < Fragment.STARTED && newState > Fragment.STOPPED) {
        newState = Fragment.STOPPED;
    }
    if (f.mState < newState) {
        // For fragments that are created from a layout, when restoring from
        // state we don't want to allow them to be created until they are
        // being reloaded from the layout.
        if (f.mFromLayout && !f.mInLayout) {
            return;
        }
        if (f.mAnimatingAway != null) {
            // The fragment is currently being animated...  but!  Now we
            // want to move our state back up.  Give up on waiting for the
            // animation, move to whatever the final state should be once
            // the animation is done, and then we can proceed from there.
            f.mAnimatingAway = null;
            moveToState(f, f.mStateAfterAnimating, 0, 0, true);
        }
        switch (f.mState) {
        case Fragment.INITIALIZING:
            if (DEBUG)
                Log.v(TAG, "moveto CREATED: " + f);
            if (f.mSavedFragmentState != null) {
                f.mSavedViewState = f.mSavedFragmentState
                        .getSparseParcelableArray(FragmentManagerImpl.VIEW_STATE_TAG);
                f.mTarget = getFragment(f.mSavedFragmentState, FragmentManagerImpl.TARGET_STATE_TAG);
                if (f.mTarget != null) {
                    f.mTargetRequestCode = f.mSavedFragmentState
                            .getInt(FragmentManagerImpl.TARGET_REQUEST_CODE_STATE_TAG, 0);
                }
                f.mUserVisibleHint = f.mSavedFragmentState.getBoolean(FragmentManagerImpl.USER_VISIBLE_HINT_TAG,
                        true);
                if (!f.mUserVisibleHint) {
                    f.mDeferStart = true;
                    if (newState > Fragment.STOPPED) {
                        newState = Fragment.STOPPED;
                    }
                }
            }
            f.mActivity = mActivity;
            f.mParentFragment = mParent;
            f.mFragmentManager = mParent != null ? mParent.mChildFragmentManager : mActivity.mFragments;
            f.mCalled = false;
            f.onAttach(mActivity);
            if (!f.mCalled) {
                throw new SuperNotCalledException(
                        "Fragment " + f + " did not call through to super.onAttach()");
            }
            if (f.mParentFragment == null) {
                mActivity.onAttachFragment(f);
            }

            if (!f.mRetaining) {
                f.performCreate(f.mSavedFragmentState);
            }
            f.mRetaining = false;
            if (f.mFromLayout) {
                // For fragments that are part of the content view
                // layout, we need to instantiate the view immediately
                // and the inflater will take care of adding it.
                f.mView = f.performCreateView(f.getLayoutInflater(f.mSavedFragmentState), null,
                        f.mSavedFragmentState);
                if (f.mView != null) {
                    f.mView.setSaveFromParentEnabled(false);
                    if (f.mHidden)
                        f.mView.setVisibility(View.GONE);
                    f.onViewCreated(f.mView, f.mSavedFragmentState);
                }
            }
        case Fragment.CREATED:
            if (newState > Fragment.CREATED) {
                if (DEBUG)
                    Log.v(TAG, "moveto ACTIVITY_CREATED: " + f);
                if (!f.mFromLayout) {
                    ViewGroup container = null;
                    if (f.mContainerId != 0) {
                        container = (ViewGroup) mContainer.findViewById(f.mContainerId);
                        if (container == null && !f.mRestored) {
                            throwException(new IllegalArgumentException(
                                    "No view found for id 0x" + Integer.toHexString(f.mContainerId) + " ("
                                            + f.getResources().getResourceName(f.mContainerId)
                                            + ") for fragment " + f));
                        }
                    }
                    f.mContainer = container;
                    f.mView = f.performCreateView(f.getLayoutInflater(f.mSavedFragmentState), container,
                            f.mSavedFragmentState);
                    if (f.mView != null) {
                        f.mView.setSaveFromParentEnabled(false);
                        if (container != null) {
                            Animator anim = loadAnimator(f, transit, true, transitionStyle);
                            if (anim != null) {
                                anim.setTarget(f.mView);
                                anim.start();
                            }
                            container.addView(f.mView);
                        }
                        if (f.mHidden)
                            f.mView.setVisibility(View.GONE);
                        f.onViewCreated(f.mView, f.mSavedFragmentState);
                    }
                }

                f.performActivityCreated(f.mSavedFragmentState);
                if (f.mView != null) {
                    f.restoreViewState(f.mSavedFragmentState);
                }
                f.mSavedFragmentState = null;
            }
        case Fragment.ACTIVITY_CREATED:
        case Fragment.STOPPED:
            if (newState > Fragment.STOPPED) {
                if (DEBUG)
                    Log.v(TAG, "moveto STARTED: " + f);
                f.performStart();
            }
        case Fragment.STARTED:
            if (newState > Fragment.STARTED) {
                if (DEBUG)
                    Log.v(TAG, "moveto RESUMED: " + f);
                f.mResumed = true;
                f.performResume();
                // Get rid of this in case we saved it and never needed it.
                f.mSavedFragmentState = null;
                f.mSavedViewState = null;
            }
        }
    } else if (f.mState > newState) {
        switch (f.mState) {
        case Fragment.RESUMED:
            if (newState < Fragment.RESUMED) {
                if (DEBUG)
                    Log.v(TAG, "movefrom RESUMED: " + f);
                f.performPause();
                f.mResumed = false;
            }
        case Fragment.STARTED:
            if (newState < Fragment.STARTED) {
                if (DEBUG)
                    Log.v(TAG, "movefrom STARTED: " + f);
                f.performStop();
            }
        case Fragment.STOPPED:
        case Fragment.ACTIVITY_CREATED:
            if (newState < Fragment.ACTIVITY_CREATED) {
                if (DEBUG)
                    Log.v(TAG, "movefrom ACTIVITY_CREATED: " + f);
                if (f.mView != null) {
                    // Need to save the current view state if not
                    // done already.
                    if (!mActivity.isFinishing() && f.mSavedViewState == null) {
                        saveFragmentViewState(f);
                    }
                }
                f.performDestroyView();
                if (f.mView != null && f.mContainer != null) {
                    Animator anim = null;
                    if (mCurState > Fragment.INITIALIZING && !mDestroyed) {
                        anim = loadAnimator(f, transit, false, transitionStyle);
                    }
                    if (anim != null) {
                        final ViewGroup container = f.mContainer;
                        final View view = f.mView;
                        final Fragment fragment = f;
                        container.startViewTransition(view);
                        f.mAnimatingAway = anim;
                        f.mStateAfterAnimating = newState;
                        anim.addListener(new AnimatorListenerAdapter() {
                            @Override
                            public void onAnimationEnd(Animator anim) {
                                container.endViewTransition(view);
                                if (fragment.mAnimatingAway != null) {
                                    fragment.mAnimatingAway = null;
                                    moveToState(fragment, fragment.mStateAfterAnimating, 0, 0, false);
                                }
                            }
                        });
                        anim.setTarget(f.mView);
                        anim.start();

                    }
                    f.mContainer.removeView(f.mView);
                }
                f.mContainer = null;
                f.mView = null;
            }
        case Fragment.CREATED:
            if (newState < Fragment.CREATED) {
                if (mDestroyed) {
                    if (f.mAnimatingAway != null) {
                        // The fragment's containing activity is
                        // being destroyed, but this fragment is
                        // currently animating away.  Stop the
                        // animation right now -- it is not needed,
                        // and we can't wait any more on destroying
                        // the fragment.
                        Animator anim = f.mAnimatingAway;
                        f.mAnimatingAway = null;
                        anim.cancel();
                    }
                }
                if (f.mAnimatingAway != null) {
                    // We are waiting for the fragment's view to finish
                    // animating away.  Just make a note of the state
                    // the fragment now should move to once the animation
                    // is done.
                    f.mStateAfterAnimating = newState;
                    newState = Fragment.CREATED;
                } else {
                    if (DEBUG)
                        Log.v(TAG, "movefrom CREATED: " + f);
                    if (!f.mRetaining) {
                        f.performDestroy();
                    }

                    f.mCalled = false;
                    f.onDetach();
                    if (!f.mCalled) {
                        throw new SuperNotCalledException(
                                "Fragment " + f + " did not call through to super.onDetach()");
                    }
                    if (!keepActive) {
                        if (!f.mRetaining) {
                            makeInactive(f);
                        } else {
                            f.mActivity = null;
                            f.mParentFragment = null;
                            f.mFragmentManager = null;
                            f.mChildFragmentManager = null;
                        }
                    }
                }
            }
        }
    }

    f.mState = newState;
}

From source file:com.android.launcher3.CellLayout.java

public boolean animateChildToPosition(final View child, int cellX, int cellY, int duration, int delay,
        boolean permanent, boolean adjustOccupied) {
    ShortcutAndWidgetContainer clc = getShortcutsAndWidgets();
    boolean[][] occupied = mOccupied;
    if (!permanent) {
        occupied = mTmpOccupied;//from  w  w w. j  a  v  a2  s.  c  o m
    }

    if (clc.indexOfChild(child) != -1) {
        final LayoutParams lp = (LayoutParams) child.getLayoutParams();
        final ItemInfo info = (ItemInfo) child.getTag();

        // We cancel any existing animations
        if (mReorderAnimators.containsKey(lp)) {
            mReorderAnimators.get(lp).cancel();
            mReorderAnimators.remove(lp);
        }

        final int oldX = lp.x;
        final int oldY = lp.y;
        if (adjustOccupied) {
            occupied[lp.cellX][lp.cellY] = false;
            occupied[cellX][cellY] = true;
        }
        lp.isLockedToGrid = true;
        if (permanent) {
            lp.cellX = info.cellX = cellX;
            lp.cellY = info.cellY = cellY;
        } else {
            lp.tmpCellX = cellX;
            lp.tmpCellY = cellY;
        }
        clc.setupLp(lp);
        lp.isLockedToGrid = false;
        final int newX = lp.x;
        final int newY = lp.y;

        lp.x = oldX;
        lp.y = oldY;

        // Exit early if we're not actually moving the view
        if (oldX == newX && oldY == newY) {
            lp.isLockedToGrid = true;
            return true;
        }

        ValueAnimator va = LauncherAnimUtils.ofFloat(child, 0f, 1f);
        va.setDuration(duration);
        mReorderAnimators.put(lp, va);

        va.addUpdateListener(new AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                float r = ((Float) animation.getAnimatedValue()).floatValue();
                lp.x = (int) ((1 - r) * oldX + r * newX);
                lp.y = (int) ((1 - r) * oldY + r * newY);
                child.requestLayout();
            }
        });
        va.addListener(new AnimatorListenerAdapter() {
            boolean cancelled = false;

            public void onAnimationEnd(Animator animation) {
                // If the animation was cancelled, it means that another animation
                // has interrupted this one, and we don't want to lock the item into
                // place just yet.
                if (!cancelled) {
                    lp.isLockedToGrid = true;
                    child.requestLayout();
                }
                if (mReorderAnimators.containsKey(lp)) {
                    mReorderAnimators.remove(lp);
                }
            }

            public void onAnimationCancel(Animator animation) {
                cancelled = true;
            }
        });
        va.setStartDelay(delay);
        va.start();
        return true;
    }
    return false;
}

From source file:com.marlonjones.voidlauncher.CellLayout.java

public boolean animateChildToPosition(final View child, int cellX, int cellY, int duration, int delay,
        boolean permanent, boolean adjustOccupied) {
    ShortcutAndWidgetContainer clc = getShortcutsAndWidgets();

    if (clc.indexOfChild(child) != -1) {
        final LayoutParams lp = (LayoutParams) child.getLayoutParams();
        final ItemInfo info = (ItemInfo) child.getTag();

        // We cancel any existing animations
        if (mReorderAnimators.containsKey(lp)) {
            mReorderAnimators.get(lp).cancel();
            mReorderAnimators.remove(lp);
        }//from   ww w.  j  a  va  2 s .co m

        final int oldX = lp.x;
        final int oldY = lp.y;
        if (adjustOccupied) {
            GridOccupancy occupied = permanent ? mOccupied : mTmpOccupied;
            occupied.markCells(lp.cellX, lp.cellY, lp.cellHSpan, lp.cellVSpan, false);
            occupied.markCells(cellX, cellY, lp.cellHSpan, lp.cellVSpan, true);
        }
        lp.isLockedToGrid = true;
        if (permanent) {
            lp.cellX = info.cellX = cellX;
            lp.cellY = info.cellY = cellY;
        } else {
            lp.tmpCellX = cellX;
            lp.tmpCellY = cellY;
        }
        clc.setupLp(lp);
        lp.isLockedToGrid = false;
        final int newX = lp.x;
        final int newY = lp.y;

        lp.x = oldX;
        lp.y = oldY;

        // Exit early if we're not actually moving the view
        if (oldX == newX && oldY == newY) {
            lp.isLockedToGrid = true;
            return true;
        }

        ValueAnimator va = LauncherAnimUtils.ofFloat(child, 0f, 1f);
        va.setDuration(duration);
        mReorderAnimators.put(lp, va);

        va.addUpdateListener(new AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                float r = ((Float) animation.getAnimatedValue()).floatValue();
                lp.x = (int) ((1 - r) * oldX + r * newX);
                lp.y = (int) ((1 - r) * oldY + r * newY);
                child.requestLayout();
            }
        });
        va.addListener(new AnimatorListenerAdapter() {
            boolean cancelled = false;

            public void onAnimationEnd(Animator animation) {
                // If the animation was cancelled, it means that another animation
                // has interrupted this one, and we don't want to lock the item into
                // place just yet.
                if (!cancelled) {
                    lp.isLockedToGrid = true;
                    child.requestLayout();
                }
                if (mReorderAnimators.containsKey(lp)) {
                    mReorderAnimators.remove(lp);
                }
            }

            public void onAnimationCancel(Animator animation) {
                cancelled = true;
            }
        });
        va.setStartDelay(delay);
        va.start();
        return true;
    }
    return false;
}

From source file:com.aliyun.homeshell.Folder.java

public void animateOpen() {
    positionAndSizeAsIcon();//from  w w w  . j  a  va2s  .c  o  m
    if (!(getParent() instanceof DragLayer))
        return;
    centerAboutIcon();
    PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 1);
    PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 1.0f);
    PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 1.0f);
    final ObjectAnimator oa = LauncherAnimUtils.ofPropertyValuesHolder(this, alpha, scaleX, scaleY);

    oa.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationStart(Animator animation) {
            sendCustomAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED,
                    String.format(getContext().getString(R.string.folder_opened), mContent.getCountX(),
                            mContent.getCountY()));
            mState = STATE_ANIMATING;
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            mState = STATE_OPEN;
            setLayerType(LAYER_TYPE_NONE, null);

            /* YUNOS BEGIN */
            // ##date:2013/11/27 ##author:zhangqiang.zq
            // remove cling
            /*
             * Cling cling = mLauncher.showFirstRunFoldersCling(); if (cling
             * != null) { cling.bringToFront(); }
             */
            /* YUNOS END */
            setFocusOnFirstChild();
            setAlpha(1);
            setScaleX(1);
            setScaleY(1);
            /*YUNOS BEGIN*/
            //##date:2014/06/10 ##author:guoshuai.lgs ##BugID:
            //support the folder feature in mainmenu
            if (mInfo.isMainmenuFolder() && (LauncherApplication.isMainmenuMode())) {
                mLauncher.getAppsCustomizeTabHost().setVisibility(View.INVISIBLE);
            }
            /*YUNOS END*/
        }
    });
    oa.setDuration(mExpandDuration);
    setLayerType(LAYER_TYPE_HARDWARE, null);
    oa.start();
}

From source file:com.android.leanlauncher.Workspace.java

Animator getChangeStateAnimation(final State state, boolean animated, int delay, ArrayList<View> layerViews) {
    if (mState == state) {
        return null;
    }/*  w ww . ja  v  a2  s . c om*/

    AnimatorSet anim = animated ? LauncherAnimUtils.createAnimatorSet() : null;

    // We only want a single instance of a workspace animation to be running at once, so
    // we cancel any incomplete transition.
    if (mStateAnimator != null) {
        mStateAnimator.cancel();
    }
    mStateAnimator = anim;

    final State oldState = mState;
    final boolean oldStateIsNormal = (oldState == State.NORMAL);
    final boolean oldStateIsOverview = (oldState == State.OVERVIEW);
    setState(state);
    final boolean stateIsNormal = (state == State.NORMAL);
    final boolean stateIsSpringLoaded = (state == State.SPRING_LOADED);
    final boolean stateIsNormalHidden = (state == State.NORMAL_HIDDEN);
    final boolean stateIsOverviewHidden = (state == State.OVERVIEW_HIDDEN);
    final boolean stateIsOverview = (state == State.OVERVIEW);
    float finalBackgroundAlpha = (stateIsSpringLoaded || stateIsOverview) ? 1.0f : 0f;
    float finalOverviewPanelAlpha = stateIsOverview ? 1f : 0f;
    float finalWorkspaceTranslationY = stateIsOverview || stateIsOverviewHidden ? getOverviewModeTranslationY()
            : 0;

    boolean workspaceToAllApps = (oldStateIsNormal && stateIsNormalHidden);
    boolean overviewToAllApps = (oldStateIsOverview && stateIsOverviewHidden);
    boolean allAppsToWorkspace = (stateIsNormalHidden && stateIsNormal);
    boolean workspaceToOverview = (oldStateIsNormal && stateIsOverview);
    boolean overviewToWorkspace = (oldStateIsOverview && stateIsNormal);

    mNewScale = 1.0f;

    if (state != State.NORMAL) {
        if (stateIsSpringLoaded) {
            mNewScale = mSpringLoadedShrinkFactor;
        } else if (stateIsOverview || stateIsOverviewHidden) {
            mNewScale = mOverviewModeShrinkFactor;
        }
    }

    final int duration;
    if (workspaceToAllApps || overviewToAllApps) {
        duration = HIDE_WORKSPACE_DURATION; //getResources().getInteger(R.integer.config_workspaceUnshrinkTime);
    } else if (workspaceToOverview || overviewToWorkspace) {
        duration = getResources().getInteger(R.integer.config_overviewTransitionTime);
    } else {
        duration = getResources().getInteger(R.integer.config_appsCustomizeWorkspaceShrinkTime);
    }

    final CellLayout cl = mWorkspace;
    float initialAlpha = cl.getShortcutsAndWidgets().getAlpha();
    float finalAlpha;
    if (stateIsNormalHidden || stateIsOverviewHidden) {
        finalAlpha = 0f;
    } else {
        finalAlpha = 1f;
    }

    // If we are animating to/from the small state, then hide the side pages and fade the
    // current page in
    if (!mIsSwitchingState) {
        if (workspaceToAllApps || allAppsToWorkspace) {
            if (allAppsToWorkspace) {
                initialAlpha = 0f;
            }
            cl.setShortcutAndWidgetAlpha(initialAlpha);
        }
    }

    float oldAlpha = initialAlpha;
    float newAlpha = finalAlpha;
    if (animated) {
        mOldBackgroundAlpha = cl.getBackgroundAlpha();
        mNewBackgroundAlpha = finalBackgroundAlpha;
    } else {
        cl.setBackgroundAlpha(finalBackgroundAlpha);
        cl.setShortcutAndWidgetAlpha(finalAlpha);
    }

    final View overviewPanel = mLauncher.getOverviewPanel();
    if (animated) {
        LauncherViewPropertyAnimator scale = new LauncherViewPropertyAnimator(this);
        scale.scaleX(mNewScale).scaleY(mNewScale).translationY(finalWorkspaceTranslationY).setDuration(duration)
                .setInterpolator(mZoomInInterpolator);
        anim.play(scale);
        float currentAlpha = cl.getShortcutsAndWidgets().getAlpha();
        if (oldAlpha == 0 && newAlpha == 0) {
            cl.setBackgroundAlpha(mNewBackgroundAlpha);
            cl.setShortcutAndWidgetAlpha(newAlpha);
        } else {
            if (layerViews != null) {
                layerViews.add(cl);
            }
            if (oldAlpha != newAlpha || currentAlpha != newAlpha) {
                LauncherViewPropertyAnimator alphaAnim = new LauncherViewPropertyAnimator(
                        cl.getShortcutsAndWidgets());
                alphaAnim.alpha(newAlpha).setDuration(duration).setInterpolator(mZoomInInterpolator);
                anim.play(alphaAnim);
            }
            if (mOldBackgroundAlpha != 0 || mNewBackgroundAlpha != 0) {
                ValueAnimator bgAnim = LauncherAnimUtils.ofFloat(cl, 0f, 1f);
                bgAnim.setInterpolator(mZoomInInterpolator);
                bgAnim.setDuration(duration);
                bgAnim.addUpdateListener(new LauncherAnimatorUpdateListener() {
                    public void onAnimationUpdate(float a, float b) {
                        cl.setBackgroundAlpha(a * mOldBackgroundAlpha + b * mNewBackgroundAlpha);
                    }
                });
                anim.play(bgAnim);
            }
        }

        Animator overviewPanelAlpha = new LauncherViewPropertyAnimator(overviewPanel)
                .alpha(finalOverviewPanelAlpha).withLayer();
        overviewPanelAlpha.addListener(new AlphaUpdateListener(overviewPanel));

        // For animation optimations, we may need to provide the Launcher transition
        // with a set of views on which to force build layers in certain scenarios.
        overviewPanel.setLayerType(View.LAYER_TYPE_HARDWARE, null);
        if (layerViews != null) {
            layerViews.add(overviewPanel);
        }

        if (workspaceToOverview) {
            overviewPanelAlpha.setInterpolator(null);
        } else if (overviewToWorkspace) {
            overviewPanelAlpha.setInterpolator(new DecelerateInterpolator(2));
        }

        overviewPanelAlpha.setDuration(duration);

        anim.play(overviewPanelAlpha);
        anim.setStartDelay(delay);
        anim.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                mStateAnimator = null;
            }
        });
    } else {
        overviewPanel.setAlpha(finalOverviewPanelAlpha);
        AlphaUpdateListener.updateVisibility(overviewPanel);
        setScaleX(mNewScale);
        setScaleY(mNewScale);
        setTranslationY(finalWorkspaceTranslationY);
    }

    if (stateIsNormal) {
        animateBackgroundGradient(0f, animated);
    } else {
        animateBackgroundGradient(getResources().getInteger(R.integer.config_workspaceScrimAlpha) / 100f,
                animated);
    }
    return anim;
}

From source file:com.android.calendar.EventInfoFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    if (savedInstanceState != null) {
        mIsDialog = savedInstanceState.getBoolean(BUNDLE_KEY_IS_DIALOG, false);
        mWindowStyle = savedInstanceState.getInt(BUNDLE_KEY_WINDOW_STYLE, DIALOG_WINDOW_STYLE);
        mDeleteDialogVisible = savedInstanceState.getBoolean(BUNDLE_KEY_DELETE_DIALOG_VISIBLE, false);
        mDeleteDialogChoice = savedInstanceState.getInt(BUNDLE_KEY_DELETE_DIALOG_CHOICE, -1);
        mCalendarColor = savedInstanceState.getInt(BUNDLE_KEY_CALENDAR_COLOR);
        mCalendarColorInitialized = savedInstanceState.getBoolean(BUNDLE_KEY_CALENDAR_COLOR_INIT);
        mOriginalColor = savedInstanceState.getInt(BUNDLE_KEY_ORIGINAL_COLOR);
        mOriginalColorInitialized = savedInstanceState.getBoolean(BUNDLE_KEY_ORIGINAL_COLOR_INIT);
        mCurrentColor = savedInstanceState.getInt(BUNDLE_KEY_CURRENT_COLOR);
        mCurrentColorInitialized = savedInstanceState.getBoolean(BUNDLE_KEY_CURRENT_COLOR_INIT);
        mCurrentColorKey = savedInstanceState.getInt(BUNDLE_KEY_CURRENT_COLOR_KEY);

        mTentativeUserSetResponse = savedInstanceState.getInt(BUNDLE_KEY_TENTATIVE_USER_RESPONSE,
                Attendees.ATTENDEE_STATUS_NONE);
        if (mTentativeUserSetResponse != Attendees.ATTENDEE_STATUS_NONE && mEditResponseHelper != null) {
            // If the edit response helper dialog is open, we'll need to
            // know if either of the choices were selected.
            mEditResponseHelper.setWhichEvents(savedInstanceState.getInt(BUNDLE_KEY_RESPONSE_WHICH_EVENTS, -1));
        }//from w ww.  ja v  a 2  s.com
        mUserSetResponse = savedInstanceState.getInt(BUNDLE_KEY_USER_SET_ATTENDEE_RESPONSE,
                Attendees.ATTENDEE_STATUS_NONE);
        if (mUserSetResponse != Attendees.ATTENDEE_STATUS_NONE) {
            // If the response was set by the user before a configuration
            // change, we'll need to know which choice was selected.
            mWhichEvents = savedInstanceState.getInt(BUNDLE_KEY_RESPONSE_WHICH_EVENTS, -1);
        }

        mReminders = Utils.readRemindersFromBundle(savedInstanceState);
    }

    if (mWindowStyle == DIALOG_WINDOW_STYLE) {
        mView = inflater.inflate(R.layout.event_info_dialog, container, false);
    } else {
        mView = inflater.inflate(R.layout.event_info, container, false);
    }
    mScrollView = (ScrollView) mView.findViewById(R.id.event_info_scroll_view);
    mLoadingMsgView = mView.findViewById(R.id.event_info_loading_msg);
    mErrorMsgView = mView.findViewById(R.id.event_info_error_msg);
    mTitle = (TextView) mView.findViewById(R.id.title);
    mWhenDateTime = (TextView) mView.findViewById(R.id.when_datetime);
    mWhere = (TextView) mView.findViewById(R.id.where);
    mDesc = (ExpandableTextView) mView.findViewById(R.id.description);
    mHeadlines = mView.findViewById(R.id.event_info_headline);
    mLongAttendees = (AttendeesView) mView.findViewById(R.id.long_attendee_list);

    mResponseRadioGroup = (RadioGroup) mView.findViewById(R.id.response_value);

    if (mUri == null) {
        // restore event ID from bundle
        mEventId = savedInstanceState.getLong(BUNDLE_KEY_EVENT_ID);
        mUri = ContentUris.withAppendedId(Events.CONTENT_URI, mEventId);
        mStartMillis = savedInstanceState.getLong(BUNDLE_KEY_START_MILLIS);
        mEndMillis = savedInstanceState.getLong(BUNDLE_KEY_END_MILLIS);
    }

    mAnimateAlpha = ObjectAnimator.ofFloat(mScrollView, "Alpha", 0, 1);
    mAnimateAlpha.setDuration(FADE_IN_TIME);
    mAnimateAlpha.addListener(new AnimatorListenerAdapter() {
        int defLayerType;

        @Override
        public void onAnimationStart(Animator animation) {
            // Use hardware layer for better performance during animation
            defLayerType = mScrollView.getLayerType();
            mScrollView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
            // Ensure that the loading message is gone before showing the
            // event info
            mLoadingMsgView.removeCallbacks(mLoadingMsgAlphaUpdater);
            mLoadingMsgView.setVisibility(View.GONE);
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            mScrollView.setLayerType(defLayerType, null);
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            mScrollView.setLayerType(defLayerType, null);
            // Do not cross fade after the first time
            mNoCrossFade = true;
        }
    });

    mLoadingMsgView.setAlpha(0);
    mScrollView.setAlpha(0);
    mErrorMsgView.setVisibility(View.INVISIBLE);
    mLoadingMsgView.postDelayed(mLoadingMsgAlphaUpdater, LOADING_MSG_DELAY);

    // start loading the data

    mHandler.startQuery(TOKEN_QUERY_EVENT, null, mUri, EVENT_PROJECTION, null, null, null);

    View b = mView.findViewById(R.id.delete);
    b.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!mCanModifyCalendar) {
                return;
            }
            mDeleteHelper = new DeleteEventHelper(mContext, mActivity,
                    !mIsDialog && !mIsTabletConfig /* exitWhenDone */);
            mDeleteHelper.setDeleteNotificationListener(EventInfoFragment.this);
            mDeleteHelper.setOnDismissListener(createDeleteOnDismissListener());
            mDeleteDialogVisible = true;
            mDeleteHelper.delete(mStartMillis, mEndMillis, mEventId, -1, onDeleteRunnable);
        }
    });

    b = mView.findViewById(R.id.change_color);
    b.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!mCanModifyCalendar) {
                return;
            }
            showEventColorPickerDialog();
        }
    });

    // Hide Edit/Delete buttons if in full screen mode on a phone
    if (!mIsDialog && !mIsTabletConfig || mWindowStyle == EventInfoFragment.FULL_WINDOW_STYLE) {
        mView.findViewById(R.id.event_info_buttons_container).setVisibility(View.GONE);
    }

    // Create a listener for the email guests button
    emailAttendeesButton = (Button) mView.findViewById(R.id.email_attendees_button);
    if (emailAttendeesButton != null) {
        emailAttendeesButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                emailAttendees();
            }
        });
    }

    // Create a listener for the add reminder button
    View reminderAddButton = mView.findViewById(R.id.reminder_add);
    View.OnClickListener addReminderOnClickListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            addReminder();
            mUserModifiedReminders = true;
        }
    };
    reminderAddButton.setOnClickListener(addReminderOnClickListener);

    // Set reminders variables

    SharedPreferences prefs = GeneralPreferences.getSharedPreferences(mActivity);
    String defaultReminderString = prefs.getString(GeneralPreferences.KEY_DEFAULT_REMINDER,
            GeneralPreferences.NO_REMINDER_STRING);
    mDefaultReminderMinutes = Integer.parseInt(defaultReminderString);
    prepareReminders();

    return mView;
}

From source file:com.ferdi2005.secondgram.AndroidUtilities.java

public static void shakeView(final View view, final float x, final int num) {
    if (num == 6) {
        view.setTranslationX(0);/*ww  w  . j  ava  2 s  .  com*/
        return;
    }
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(ObjectAnimator.ofFloat(view, "translationX", AndroidUtilities.dp(x)));
    animatorSet.setDuration(50);
    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            shakeView(view, num == 5 ? 0 : -x, num + 1);
        }
    });
    animatorSet.start();
}

From source file:com.gigabytedevelopersinc.app.calculator.Calculator.java

private void dismissCling(final Cling cling, final String flag, int duration) {
    setPagingEnabled(true);/* w w w .ja  v  a2s. co  m*/
    clingActive = false;

    if (cling != null) {
        cling.dismiss();
        if (getActionBar() != null) {
            getActionBar().show();
        }
        getActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#FFFFFF")));
        ObjectAnimator anim = ObjectAnimator.ofFloat(cling, "alpha", 0f);
        anim.setDuration(duration);
        anim.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                cling.setVisibility(View.GONE);
                cling.cleanup();
                CalculatorSettings.saveKey(getContext(), flag, true);
            }
        });
        anim.start();
    }
}

From source file:android.app.FragmentManager.java

public void hideFragment(Fragment fragment, int transition, int transitionStyle) {
    if (DEBUG)/*  w  w  w  .  java2  s.  c om*/
        Log.v(TAG, "hide: " + fragment);
    if (!fragment.mHidden) {
        fragment.mHidden = true;
        if (fragment.mView != null) {
            Animator anim = loadAnimator(fragment, transition, true, transitionStyle);
            if (anim != null) {
                anim.setTarget(fragment.mView);
                // Delay the actual hide operation until the animation finishes, otherwise
                // the fragment will just immediately disappear
                final Fragment finalFragment = fragment;
                anim.addListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        if (finalFragment.mView != null) {
                            finalFragment.mView.setVisibility(View.GONE);
                        }
                    }
                });
                anim.start();
            } else {
                fragment.mView.setVisibility(View.GONE);
            }
        }
        if (fragment.mAdded && fragment.mHasMenu && fragment.mMenuVisible) {
            mNeedMenuInvalidate = true;
        }
        fragment.onHiddenChanged(true);
    }
}

From source file:android.app.FragmentManager.java

public void hideFragment(Fragment fragment, int transition, int transitionStyle) {
    if (DEBUG)/*from   w  ww.ja v  a 2  s.co  m*/
        Log.v(TAG, "hide: " + fragment);
    if (!fragment.mHidden) {
        fragment.mHidden = true;
        if (fragment.mView != null) {
            Animator anim = loadAnimator(fragment, transition, false, transitionStyle);
            if (anim != null) {
                anim.setTarget(fragment.mView);
                // Delay the actual hide operation until the animation finishes, otherwise
                // the fragment will just immediately disappear
                final Fragment finalFragment = fragment;
                anim.addListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        if (finalFragment.mView != null) {
                            finalFragment.mView.setVisibility(View.GONE);
                        }
                    }
                });
                anim.start();
            } else {
                fragment.mView.setVisibility(View.GONE);
            }
        }
        if (fragment.mAdded && fragment.mHasMenu && fragment.mMenuVisible) {
            mNeedMenuInvalidate = true;
        }
        fragment.onHiddenChanged(true);
    }
}