Example usage for android.animation ObjectAnimator ObjectAnimator

List of usage examples for android.animation ObjectAnimator ObjectAnimator

Introduction

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

Prototype

public ObjectAnimator() 

Source Link

Document

Creates a new ObjectAnimator object.

Usage

From source file:com.quanliren.quan_one.pull.swipe.SwipeRefreshLayout.java

private ValueAnimator startAlphaAnimation(final int startingAlpha, final int endingAlpha) {
    // Pre API 11, alpha is used in place of scale. Don't also use it to
    // show the trigger point.
    if (mScale && isAlphaUsedForScale()) {
        return null;
    }/*from ww w  .  j a v a2  s  .com*/
    ValueAnimator alpha = new ObjectAnimator().ofFloat(0f, 1f);
    alpha.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mProgress.setAlpha((int) (startingAlpha + ((endingAlpha - startingAlpha)
                    * Float.valueOf(animation.getAnimatedValue().toString()))));
        }
    });
    alpha.setDuration(ALPHA_ANIMATION_DURATION);
    alpha.start();
    return alpha;
}

From source file:com.quanliren.quan_one.pull.swipe.SwipeRefreshLayout.java

private void startScaleDownReturnToStartAnimation(int from, AnimatorListenerAdapter listener) {
    mFrom = from;/*from ww  w.jav a 2s. c  o  m*/
    if (isAlphaUsedForScale()) {
        mStartingScale = mProgress.getAlpha();
    } else {
        mStartingScale = ViewCompat.getScaleX(mCircleView);
    }
    mScaleDownToStartAnimation = new ObjectAnimator().ofFloat(0f, 1f).setDuration(SCALE_DOWN_DURATION);
    mScaleDownToStartAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float targetScale = (mStartingScale
                    + (-mStartingScale * Float.valueOf(animation.getAnimatedValue().toString())));
            setAnimationProgress(targetScale);
            moveToStart(Float.valueOf(animation.getAnimatedValue().toString()));
        }
    });
    if (listener != null)
        mScaleDownToStartAnimation.addListener(listener);
    mScaleDownToStartAnimation.start();
}

From source file:android.support.graphics.drawable.AnimatorInflaterCompat.java

private static ObjectAnimator loadObjectAnimator(Context context, Resources res, Theme theme,
        AttributeSet attrs, float pathErrorScale, XmlPullParser parser) throws NotFoundException {
    ObjectAnimator anim = new ObjectAnimator();

    loadAnimator(context, res, theme, attrs, anim, pathErrorScale, parser);

    return anim;//  ww w  . j  av a  2s .  co m
}

From source file:com.arlib.floatingsearchview.FloatingSearchView.java

/**
 * Shows a circular progress on top of the
 * menu action button./*from  ww  w.  j  a  va2s.  c o m*/
 *
 * <p>Call hidProgress()
 * to change back to normal and make the menu
 * action visible.</p>
 */
public void showProgress() {

    mMenuSearchOrExitButton.setVisibility(View.GONE);
    mSearchProgress.setVisibility(View.VISIBLE);
    ObjectAnimator fadeInProgress = new ObjectAnimator().ofFloat(mSearchProgress, "alpha", 0.0f, 1.0f);
    fadeInProgress.start();
}

From source file:com.arlib.floatingsearchview.FloatingSearchView.java

/**
 * Hides the progress bar after//from w w  w . java 2 s . c  om
 * a prior call to showProgress()
 */
public void hideProgress() {

    mMenuSearchOrExitButton.setVisibility(View.VISIBLE);
    mSearchProgress.setVisibility(View.GONE);
    ObjectAnimator fadeInExit = new ObjectAnimator().ofFloat(mMenuSearchOrExitButton, "alpha", 0.0f, 1.0f);
    fadeInExit.start();
}

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

/**
 * show search view with a circular reveal animation
 *///from w ww. j  av  a 2 s  .  c  om
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:com.arlib.floatingsearchview.FloatingSearchView.java

private void changeIcon(ImageView imageView, Drawable newIcon, boolean withAnim) {

    imageView.setImageDrawable(newIcon);
    if (withAnim) {
        ObjectAnimator fadeInVoiceInputOrClear = new ObjectAnimator().ofFloat(imageView, "alpha", 0.0f, 1.0f);
        fadeInVoiceInputOrClear.start();
    } else {//from   ww w.j a  v a2 s  . c om
        imageView.setAlpha(1.0f);
    }
}

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

/**
 * hide search view with a circular reveal animation
 *///w  w w.j  ava2  s .  co 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) {

        }
    });
}