Java Code Examples for android.animation.Animator#start()

The following examples show how to use android.animation.Animator#start() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MapSearchView.java    From droidkaigi2016 with Apache License 2.0 6 votes vote down vote up
public void revealOff() {
    if (binding.mapListContainer.getVisibility() != VISIBLE) return;

    View container = binding.mapListContainer;
    Animator animator = ViewAnimationUtils.createCircularReveal(
            container,
            getRevealCenterX(container),
            container.getTop(),
            (float) Math.hypot(container.getWidth(), container.getHeight()),
            0);
    animator.setInterpolator(INTERPOLATOR);
    animator.setDuration(getResources().getInteger(R.integer.view_reveal_mills));
    animator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            binding.mapListContainer.setVisibility(INVISIBLE);
            if (onVisibilityChangeListener != null) {
                onVisibilityChangeListener.onChange();
            }
        }
    });

    animator.start();
}
 
Example 2
Source File: LoginActivity.java    From Expert-Android-Programming with MIT License 6 votes vote down vote up
private void hideHint(final View view) {
    view.setPivotX(0);
    view.setPivotY(view.getHeight());

    Animator iconAnim = ObjectAnimator.ofPropertyValuesHolder(view,
            PropertyValuesHolder.ofFloat(View.ALPHA, 1f, 0f),
            PropertyValuesHolder.ofFloat(View.SCALE_Y, 1f, 0f));
    iconAnim.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            view.setVisibility(View.INVISIBLE);
        }
    });
    iconAnim.start();
}
 
Example 3
Source File: ProgressIndicatorView.java    From 920-text-editor-v2 with Apache License 2.0 5 votes vote down vote up
/**
 * make animation to start or end when target
 * view was be Visible or Gone or Invisible.
 * make animation to cancel when target view
 * be onDetachedFromWindow.
 *
 * @param animStatus
 */
public void setAnimationStatus(AnimStatus animStatus) {
    if (mAnimators == null) {
        return;
    }
    int count = mAnimators.size();
    for (int i = 0; i < count; i++) {
        Animator animator = mAnimators.get(i);
        boolean isRunning = animator.isRunning();
        switch (animStatus) {
            case START:
                if (!isRunning) {
                    animator.start();
                }
                break;
            case END:
                if (isRunning) {
                    animator.end();
                }
                break;
            case CANCEL:
                if (isRunning) {
                    animator.cancel();
                }
                break;
        }
    }
}
 
Example 4
Source File: Timber4.java    From Muzesto with GNU General Public License v3.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
void exitReveal(final View myView) {
    // previously visible view
    //final View myView = findViewById(R.id.my_view);

    // get the center for the clipping circle
    int cx = myView.getMeasuredWidth() / 2;
    int cy = myView.getMeasuredHeight() / 2;

    // get the initial radius for the clipping circle
    int initialRadius = myView.getWidth() / 2;

    // create the animation (the final radius is zero)
    Animator anim =
            ViewAnimationUtils.createCircularReveal(myView, 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);
            myView.setVisibility(View.INVISIBLE);
            horizontalRecyclerview.setVisibility(View.VISIBLE);
        }
    });

    // start the animation
    anim.start();
}
 
Example 5
Source File: BaseIndicatorController.java    From LazyRecyclerAdapter with MIT License 5 votes vote down vote up
/**
 * make animation to start or end when target
 * view was be Visible or Gone or Invisible.
 * make animation to cancel when target view
 * be onDetachedFromWindow.
 *
 * @param animStatus
 */
public void setAnimationStatus(AnimStatus animStatus) {
    if (mAnimators == null) {
        return;
    }
    int count = mAnimators.size();
    for (int i = 0; i < count; i++) {
        Animator animator = mAnimators.get(i);
        boolean isRunning = animator.isRunning();
        switch (animStatus) {
            case START:
                if (!isRunning) {
                    animator.start();
                }
                break;
            case END:
                if (isRunning) {
                    animator.end();
                }
                break;
            case CANCEL:
                if (isRunning) {
                    animator.cancel();
                }
                break;
        }
    }
}
 
Example 6
Source File: ViewUtils.java    From visual-goodies with Apache License 2.0 5 votes vote down vote up
public static void createCircularReveal(View view, int cx, int cy, int radius){
        if (Build.VERSION.SDK_INT < 21){
            animateSetViewVisibilityVisible(view);
            return;
        }else {
            view.setVisibility(View.VISIBLE);
            //Clear traces from animateSetViewVisibility*
            if (Build.VERSION.SDK_INT >= 12) {
                view.setScaleY(1);
                view.setScaleX(1);
            }
            // get the center for the clipping circle

// get the final radius for the clipping circle

            Log.e("ViewUtils", "finalRadius = " + radius);

// create the animator for this view (the start radius is zero)
            try {

                Animator anim =
                        ViewAnimationUtils.createCircularReveal(view, cx, cy, 0, radius);
// make the view visible and start the animation
                anim.start();
            }catch (IllegalStateException ex){
                ex.printStackTrace();
                view.setVisibility(View.VISIBLE);
            }
        }
    }
 
Example 7
Source File: SearchPlaceActivity.java    From Expert-Android-Programming with MIT License 5 votes vote down vote up
private void showTop(View view) {
    view.setVisibility(View.VISIBLE);
    Animator iconAnim = ObjectAnimator.ofPropertyValuesHolder(view,
            PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, -view.getHeight(), 0f));
    iconAnim.setDuration(VIEW_ANIMATION);
    iconAnim.start();


}
 
Example 8
Source File: SupportAnimatorLollipop.java    From WeGit with Apache License 2.0 5 votes vote down vote up
@Override
public void start() {
    Animator a = mNativeAnimator.get();
    if(a != null) {
        a.start();
    }
}
 
Example 9
Source File: ca.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
public void onAnimationEnd(Animator animator)
{
    StatisticFragment.o(b).setMode(StatisticFragment.j(b));
    StatisticFragment.p(b).setMode(StatisticFragment.j(b));
    Animator animator1 = StatisticFragment.b(b).animRefresh();
    animator1.setDuration(a / 2L);
    animator1.setInterpolator(new DecelerateInterpolator(1.5F));
    animator1.start();
}
 
Example 10
Source File: BaseIndeterminateProgressDrawable.java    From MaterialProgressBar with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void start() {

    if (isStarted()) {
        return;
    }

    for (Animator animator : mAnimators) {
        animator.start();
    }
    invalidateSelf();
}
 
Example 11
Source File: NumberRollView.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Sets a number to display.
 * @param animate Whether it should smoothly animate to the number.
 */
public void setNumber(int number, boolean animate) {
    if (mLastRollAnimator != null) mLastRollAnimator.cancel();

    if (animate) {
        Animator rollAnimator = ObjectAnimator.ofFloat(this, NUMBER_PROPERTY, number);
        rollAnimator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE);
        rollAnimator.start();
        mLastRollAnimator = rollAnimator;
    } else {
        setNumberRoll(number);
    }
}
 
Example 12
Source File: SupportAnimatorForLollipop.java    From Nibo with MIT License 5 votes vote down vote up
@Override
public void start() {
    Animator a = mAnimator.get();
    if(a != null) {
        a.start();
    }
}
 
Example 13
Source File: WXRenderStatement.java    From weex with Apache License 2.0 5 votes vote down vote up
void startAnimation(String ref, String animation, String callBack) {
  WXComponent component = mRegistry.get(ref);
  if (component == null || component.getRealView() == null) {
    return;
  } else {
    try {
      WXAnimationBean animationBean = WXAnimationModule.parseAnimation(animation, component.getRealView().getLayoutParams());
      if (animationBean != null) {
        Animator animator = WXAnimationModule.createAnimator(animationBean, component.getRealView());
        if (animator != null) {
          Animator.AnimatorListener animatorListener = WXAnimationModule.createAnimatorListener(mWXSDKInstance, callBack);
          Interpolator interpolator = WXAnimationModule.createTimeInterpolator(animationBean);
          if (animatorListener != null) {
            animator.addListener(animatorListener);
          }
          if (interpolator != null) {
            animator.setInterpolator(interpolator);
          }
          animator.setDuration(animationBean.duration);
          animator.start();
        }
      }
    } catch (RuntimeException e) {
      WXLogUtils.e(WXLogUtils.getStackTrace(e));
    }
  }
}
 
Example 14
Source File: SimplePathContainer.java    From Mortar-Flow-Dagger2-demo with MIT License 5 votes vote down vote up
private void runAnimation(final ViewGroup container, final View from, final View to,
                          Flow.Direction direction, final Flow.TraversalCallback callback) {
    Animator animator = createSegue(from, to, direction);
    animator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            container.removeView(from);
            callback.onTraversalCompleted();
        }
    });
    animator.start();
}
 
Example 15
Source File: ViewUtils.java    From visual-goodies with Apache License 2.0 5 votes vote down vote up
public static void createCircularRevealInverse(final View view,
                                                   int cx,
                                                   int cy,
                                                   int initialRadius,
                                                   final boolean setAsGone){
        if (Build.VERSION.SDK_INT < 21){
            if (setAsGone)
                animateSetViewVisibilityGone(view);
            else
                view.setVisibility(View.INVISIBLE);
        }else{
            view.setVisibility(View.VISIBLE);
            if (Build.VERSION.SDK_INT >= 12) {
                view.setScaleY(1);
                view.setScaleX(1);
            }

            try {
// create the animation (the final radius is zero)
                Animator anim =
                        ViewAnimationUtils.createCircularReveal(view, 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);
                        view.setVisibility(setAsGone ? View.GONE : View.INVISIBLE);
                    }
                });

// start the animation
                anim.start();
            }catch (IllegalStateException ex) {
                ex.printStackTrace();
                view.setVisibility(setAsGone ? View.GONE : View.INVISIBLE);
            }
        }
    }
 
Example 16
Source File: LoopBarView.java    From LoopBar with MIT License 5 votes vote down vote up
private void startSelectedViewInAnimation() {
    Animator animator = mSelectionInAnimator;
    animator.setTarget(mSelectorHolder.itemView);
    animator.addListener(new AbstractAnimatorListener() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            updateCategoriesOffsetBySelector();
        }
    });
    animator.start();
}
 
Example 17
Source File: CommonPropertyAnimActivity.java    From AndroidStudyDemo with GNU General Public License v2.0 5 votes vote down vote up
public void showFlipOnVertical(View v) {
    switch (v.getId()) {
        case R.id.iv_policebox:
        case R.id.iv_policeboxlight:
            if (mTestSwitch) {
                ObjectAnimator objectAnimator3 = ObjectAnimator.ofFloat(mShowAnimIV, "alpha", 1.0f, 0.25f, 0.75f, 0.15f, 0.5f, 0.0f);
                objectAnimator3.setDuration(C.Int.ANIM_DURATION * 10);
                objectAnimator3.setInterpolator(new LinearInterpolator());
                objectAnimator3.start();
            } else {
                ObjectAnimator objectAnimator3_1 = ObjectAnimator.ofFloat(mPoliceBoxIV, "alpha", 1.0f, 1.0f, 0.25f, 0.75f, 0.15f, 0.5f, 0.0f);
                ObjectAnimator objectAnimator3_2 = ObjectAnimator.ofFloat(mPoliceBoxLightIV, "alpha", 0.0f, 1.0f, 0.0f, 0.75f, 0.0f, 0.5f, 0.0f);
                AnimatorSet animatorSet3 = new AnimatorSet();
                animatorSet3.playTogether(
                        objectAnimator3_1,
                        objectAnimator3_2
                );
                animatorSet3.setDuration(C.Int.ANIM_DURATION * 5);
                animatorSet3.setInterpolator(new LinearInterpolator());
                animatorSet3.start();
            }
            mTestSwitch = !mTestSwitch;
            break;
        case R.id.btn_filponvertical:
            if (mTestSwitch) {
                Animator animator4 = AnimatorInflater.loadAnimator(this, R.animator.sda_flip_on_vertical);
                animator4.setTarget(mShowAnimIV);
                animator4.start();
            } else {
                ObjectAnimator objectAnimator4 = ObjectAnimator.ofFloat(mShowAnimIV, "rotationY", 0.0f, 360.0f);
                objectAnimator4.setDuration(C.Int.ANIM_DURATION);
                objectAnimator4.start();
            }
            mTestSwitch = !mTestSwitch;
            break;
    }
}
 
Example 18
Source File: MainActivity.java    From AndroidHeros with MIT License 4 votes vote down vote up
public void btnXML(final View view){
    Animator animator = AnimatorInflater.loadAnimator(this, R.animator.scalex);
    animator.setTarget(view);
    animator.start();
}
 
Example 19
Source File: CreditCardView.java    From CreditCardView with Apache License 2.0 4 votes vote down vote up
public void showAnimation(final View cardContainer, final View v, final int drawableId) {

        final View mRevealView = v;
        mRevealView.setBackgroundResource(drawableId);

        if (mCurrentDrawable == drawableId) {
            return;
        }

        int duration = 1000;
        int cx = mRevealView.getLeft();
        int cy = mRevealView.getTop();

        int radius = Math.max(mRevealView.getWidth(), mRevealView.getHeight()) * 4;

        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {


            SupportAnimator animator =
                    ViewAnimationUtils.createCircularReveal(mRevealView, cx, cy, 0, radius);
            animator.setInterpolator(new AccelerateDecelerateInterpolator());
            animator.setDuration(duration);

            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    cardContainer.setBackgroundResource(drawableId);
                }
            }, duration);

            mRevealView.setVisibility(View.VISIBLE);
            animator.start();
            mCurrentDrawable = drawableId;

        } else {
            Animator anim = android.view.ViewAnimationUtils.createCircularReveal(mRevealView, cx, cy, 0, radius);
            mRevealView.setVisibility(View.VISIBLE);
            anim.setDuration(duration);
            anim.start();
            anim.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    super.onAnimationEnd(animation);

                    cardContainer.setBackgroundResource(drawableId);
                }
            });

            mCurrentDrawable = drawableId;
        }
    }
 
Example 20
Source File: MainActivity.java    From Flubber with Apache License 2.0 3 votes vote down vote up
private void openEditor(CustomAnimationBody animationBody) {

        final EditorFragment editorFragment = new EditorFragment();
        final FragmentManager fragmentManager = getSupportFragmentManager();

        editorFragment.setAnimationBody(animationBody);

        final FragmentTransaction transaction =
                fragmentManager.beginTransaction()
                        .replace(R.id.editorPanelContainer, editorFragment, EditorFragment.TAG);

        binding.mainPanelContainer.setVisibility(View.INVISIBLE);

        final Animator showAnimation = getShowWithReveal(binding.editorPanelContainer);

        Flubber.with()
                .animation(FABRevealProvider.create(R.drawable.ic_done_white_24dp))
                .duration(DURATION_REVEAL)
                .autoStart(true)
                .createFor(binding.floatingActionButton);

        showAnimation.start();

        transaction.commitNow();

        binding.setEditorOpen(true);
    }