Example usage for android.animation Animator start

List of usage examples for android.animation Animator start

Introduction

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

Prototype

public void start() 

Source Link

Document

Starts this animation.

Usage

From source file:android.app.FragmentManager.java

public void hideFragment(Fragment fragment, int transition, int transitionStyle) {
    if (DEBUG)/*from   w w w  .ja  v a2  s  .co m*/
        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:com.android.leanlauncher.Workspace.java

private void enableOverviewMode(boolean enable, boolean animated) {
    State finalState = Workspace.State.OVERVIEW;
    if (!enable) {
        finalState = Workspace.State.NORMAL;
    }//w  w  w .  ja  v a 2  s  .  c  o m

    Animator workspaceAnim = getChangeStateAnimation(finalState, animated, 0);
    if (workspaceAnim != null) {
        onTransitionPrepare();
        workspaceAnim.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator arg0) {
                onTransitionEnd();
            }
        });
        workspaceAnim.start();
    }
}

From source file:android.app.FragmentManager.java

public void hideFragment(Fragment fragment, int transition, int transitionStyle) {
    if (DEBUG)/*from  www  .  j  a va 2s .com*/
        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);
    }
}

From source file:android.transitions.everywhere.Transition.java

/**
 * This is a utility method used by subclasses to handle standard parts of
 * setting up and running an Animator: it sets the {@link #getDuration()
 * duration} and the {@link #getStartDelay() startDelay}, starts the
 * animation, and, when the animator ends, calls {@link #end()}.
 *
 * @param animator The Animator to be run during this transition.
 * @hide/*from ww w .  j a va2s  .  c om*/
 */
protected void animate(Animator animator) {
    // TODO: maybe pass auto-end as a boolean parameter?
    if (animator == null) {
        end();
    } else {
        if (getDuration() >= 0) {
            animator.setDuration(getDuration());
        }
        if (getStartDelay() >= 0) {
            animator.setStartDelay(getStartDelay() + animator.getStartDelay());
        }
        if (getInterpolator() != null) {
            animator.setInterpolator(getInterpolator());
        }
        animator.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                end();
                animation.removeListener(this);
            }
        });
        animator.start();
    }
}

From source file:org.awesomeapp.messenger.ui.ConversationView.java

private void toggleAttachMenu() {
    if (mViewAttach.getVisibility() == View.INVISIBLE) {

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

            // get the center for the clipping circle
            int cx = mViewAttach.getLeft();
            int cy = mViewAttach.getHeight();

            // get the final radius for the clipping circle
            float finalRadius = (float) Math.hypot(cx, cy);

            // create the animator for this view (the start radius is zero)
            Animator anim = ViewAnimationUtils.createCircularReveal(mViewAttach, cx, cy, 0, finalRadius);

            // make the view visible and start the animation

            mViewAttach.setVisibility(View.VISIBLE);
            anim.start();
        } else {//from  w ww .j  a va2s.  co m
            mViewAttach.setVisibility(View.VISIBLE);

        }

        // Check if no view has focus:
        View view = mActivity.getCurrentFocus();
        if (view != null) {
            InputMethodManager imm = (InputMethodManager) mActivity
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
        }
    } else {

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

            // get the center for the clipping circle
            int cx = mViewAttach.getLeft();
            int cy = mViewAttach.getHeight();

            // get the initial radius for the clipping circle
            float initialRadius = (float) Math.hypot(cx, cy);

            // create the animation (the final radius is zero)
            Animator anim = ViewAnimationUtils.createCircularReveal(mViewAttach, cx, cy, initialRadius, 0);

            // make the view invisible when the animation is done
            anim.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    super.onAnimationEnd(animation);
                    mViewAttach.setVisibility(View.INVISIBLE);
                }
            });

            // start the animation
            anim.start();

        } else {
            mViewAttach.setVisibility(View.INVISIBLE);
        }

    }

    if (mStickerBox != null)
        mStickerBox.setVisibility(View.GONE);
}

From source file:com.igniva.filemanager.activities.MainActivity.java

/**
 * hide search view with a circular reveal animation
 *//*from  w ww .j  a  v a  2  s.c o m*/
public void hideSearchView() {

    final int END_RADIUS = 16;
    int startRadius = Math.max(searchViewLayout.getWidth(), searchViewLayout.getHeight());
    Animator animator;
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
        animator = ViewAnimationUtils.createCircularReveal(searchViewLayout, searchCoords[0] + 32,
                searchCoords[1] - 16, startRadius, END_RADIUS);
    } else {
        // TODO: ViewAnimationUtils.createCircularReveal
        animator = new ObjectAnimator().ofFloat(searchViewLayout, "alpha", 1f, 0f);
    }

    // removing background fade view
    utils.revealShow(mFabBackground, false);
    animator.setInterpolator(new AccelerateDecelerateInterpolator());
    animator.setDuration(600);
    animator.start();
    animator.addListener(new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animation) {

        }

        @Override
        public void onAnimationEnd(Animator animation) {

            searchViewLayout.setVisibility(View.GONE);
            isSearchViewEnabled = false;
            InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
            inputMethodManager.hideSoftInputFromWindow(searchViewEditText.getWindowToken(),
                    InputMethodManager.HIDE_IMPLICIT_ONLY);
        }

        @Override
        public void onAnimationCancel(Animator animation) {

        }

        @Override
        public void onAnimationRepeat(Animator animation) {

        }
    });
}

From source file:com.igniva.filemanager.activities.MainActivity.java

/**
 * show search view with a circular reveal animation
 *//*from   ww w.j  a v a2s.c  o  m*/
void revealSearchView() {

    final int START_RADIUS = 16;
    int endRadius = Math.max(toolbar.getWidth(), toolbar.getHeight());

    Animator animator;
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
        animator = ViewAnimationUtils.createCircularReveal(searchViewLayout, searchCoords[0] + 32,
                searchCoords[1] - 16, START_RADIUS, endRadius);
    } else {
        // TODO:ViewAnimationUtils.createCircularReveal
        animator = new ObjectAnimator().ofFloat(searchViewLayout, "alpha", 0f, 1f);
    }

    utils.revealShow(mFabBackground, true);

    animator.setInterpolator(new AccelerateDecelerateInterpolator());
    animator.setDuration(600);
    searchViewLayout.setVisibility(View.VISIBLE);
    animator.start();
    animator.addListener(new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animation) {

        }

        @Override
        public void onAnimationEnd(Animator animation) {

            searchViewEditText.requestFocus();
            InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.showSoftInput(searchViewEditText, InputMethodManager.SHOW_IMPLICIT);
            isSearchViewEnabled = true;
        }

        @Override
        public void onAnimationCancel(Animator animation) {

        }

        @Override
        public void onAnimationRepeat(Animator animation) {

        }
    });

}

From source file:org.numixproject.hermes.activity.ConversationActivity.java

private void showConversationLayout() {
    // get the final radius for the clipping circle
    int finalRadius = Math.max(roomsLayout.getWidth(), roomsLayout.getHeight());
    final FrameLayout colorLayout = (FrameLayout) findViewById(R.id.colorLayout);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

        // create the animator for this view (the start radius is zero)
        Animator colorAnim;
        colorAnim = ViewAnimationUtils.createCircularReveal(colorLayout, (int) roomsLayout.getLeft(),
                (int) roomsLayout.getTop(), 0, finalRadius);
        final AlphaAnimation fadeAnim = new AlphaAnimation(1.0f, 0.0f);
        fadeAnim.setDuration(250);/* w w w .  ja va2s .c  om*/
        fadeAnim.setInterpolator(new AccelerateInterpolator());
        fadeAnim.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
                conversationLayout.setVisibility(View.VISIBLE);
            }

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

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });

        colorAnim.setInterpolator(new AccelerateInterpolator());
        colorAnim.addListener(new android.animation.Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(android.animation.Animator animation) {
            }

            @Override
            public void onAnimationRepeat(android.animation.Animator animation) {
            }

            @Override
            public void onAnimationEnd(android.animation.Animator animation) {
                colorLayout.startAnimation(fadeAnim);
            }

            @Override
            public void onAnimationCancel(android.animation.Animator animation) {
            }
        });

        colorLayout.setVisibility(View.VISIBLE);
        colorAnim.start();

    } else {
        conversationLayout.setVisibility(View.VISIBLE);
        conversationLayout.setAlpha(0.f);
        conversationLayout.setScaleX(0.f);
        conversationLayout.setScaleY(0.f);
        conversationLayout.animate().alpha(1.f).scaleX(1.f).scaleY(1.f).setDuration(300).start();
    }
}

From source file:com.amaze.carbonfilemanager.activities.MainActivity.java

/**
 * hide search view with a circular reveal animation
 */// w  w  w .  jav  a 2s.co m
public void hideSearchView() {
    final int END_RADIUS = 16;
    int startRadius = Math.max(searchViewLayout.getWidth(), searchViewLayout.getHeight());
    Animator animator;
    if (SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
        animator = ViewAnimationUtils.createCircularReveal(searchViewLayout, searchCoords[0] + 32,
                searchCoords[1] - 16, startRadius, END_RADIUS);
    } else {
        // TODO: ViewAnimationUtils.createCircularReveal
        animator = ObjectAnimator.ofFloat(searchViewLayout, "alpha", 1f, 0f);
    }

    // removing background fade view
    utils.revealShow(fabBgView, false);
    animator.setInterpolator(new AccelerateDecelerateInterpolator());
    animator.setDuration(600);
    animator.start();
    animator.addListener(new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animation) {
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            searchViewLayout.setVisibility(View.GONE);
            isSearchViewEnabled = false;
            InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
            inputMethodManager.hideSoftInputFromWindow(searchViewEditText.getWindowToken(),
                    InputMethodManager.HIDE_IMPLICIT_ONLY);
        }

        @Override
        public void onAnimationCancel(Animator animation) {
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        }
    });
}

From source file:com.amaze.carbonfilemanager.activities.MainActivity.java

/**
 * show search view with a circular reveal animation
 *///from   w w w  .  ja  va2 s  .  c om
void revealSearchView() {
    final int START_RADIUS = 16;
    int endRadius = Math.max(toolbar.getWidth(), toolbar.getHeight());

    Animator animator;
    if (SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
        animator = ViewAnimationUtils.createCircularReveal(searchViewLayout, searchCoords[0] + 32,
                searchCoords[1] - 16, START_RADIUS, endRadius);
    } else {
        // TODO:ViewAnimationUtils.createCircularReveal
        animator = ObjectAnimator.ofFloat(searchViewLayout, "alpha", 0f, 1f);
    }

    utils.revealShow(fabBgView, true);

    animator.setInterpolator(new AccelerateDecelerateInterpolator());
    animator.setDuration(600);
    searchViewLayout.setVisibility(View.VISIBLE);
    animator.start();
    animator.addListener(new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animation) {
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            searchViewEditText.requestFocus();
            InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.showSoftInput(searchViewEditText, InputMethodManager.SHOW_IMPLICIT);
            isSearchViewEnabled = true;
        }

        @Override
        public void onAnimationCancel(Animator animation) {
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        }
    });
}