List of usage examples for android.support.v4.view ViewPropertyAnimatorListener ViewPropertyAnimatorListener
ViewPropertyAnimatorListener
From source file:com.events.events.features.welcome.SelectCityFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_select_city, container, false); ButterKnife.bind(this, view); ArrayAdapter<String> cityAdapter = new ArrayAdapter<>(getActivity(), R.layout.spinner_item); cityAdapter.addAll(getResources().getStringArray(R.array.cities)); mSelectCitySpinner.setAdapter(cityAdapter); Drawable.ConstantState constantState = mSelectCitySpinner.getBackground().getConstantState(); if (constantState != null) { Drawable spinnerDrawable = constantState.newDrawable(); spinnerDrawable.setColorFilter(ContextCompat.getColor(getActivity(), android.R.color.white), PorterDuff.Mode.SRC_ATOP); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { mSelectCitySpinner.setBackground(spinnerDrawable); } else {//from w w w . ja v a 2 s . c om //noinspection deprecation mSelectCitySpinner.setBackgroundDrawable(spinnerDrawable); } } mSelectCitySpinner.setTitle(getActivity().getResources().getString(R.string.select_city_spinner_title)); mSelectCitySpinner .setPositiveButton(getActivity().getResources().getString(R.string.select_city_spinner_close)); mContinueButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AnimUtils.animteViewsOut(new ViewPropertyAnimatorListener() { @Override public void onAnimationStart(View view) { } @Override public void onAnimationEnd(View view) { ((WelcomeActivity) getActivity()).nextSlide(); } @Override public void onAnimationCancel(View view) { } }, mContinueButton, mSelectCitySpinner, mSelectCityTitle, mSelectCityImage); } }); AnimUtils.alphaZero(mSelectCityImage, mSelectCitySpinner, mSelectCityTitle, mContinueButton); return view; }
From source file:com.skydoves.elasticviewsexample.ElasticVIews.ElasticLayout.java
@Override public boolean dispatchTouchEvent(MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { if (listener != null) { if (view.getScaleX() == 1) { for (int i = 0; i < this.getChildCount(); i++) { ViewCompat.animate(this.getChildAt(i)).setDuration(duration).scaleX(scale).scaleY(scale) .setInterpolator(new CycleInterpolator(0.5f)) .setListener(new ViewPropertyAnimatorListener() { @Override public void onAnimationStart(final View view) { }// w w w . ja v a 2s . c o m @Override public void onAnimationEnd(final View v) { onClick(); } @Override public void onAnimationCancel(final View view) { } }).withLayer().start(); } ViewCompat.animate(view).setDuration(duration).scaleX(scale).scaleY(scale) .setInterpolator(new CycleInterpolator(0.5f)) .setListener(new ViewPropertyAnimatorListener() { @Override public void onAnimationStart(final View view) { } @Override public void onAnimationEnd(final View v) { onClick(); } @Override public void onAnimationCancel(final View view) { } }).withLayer().start(); } } } return super.dispatchTouchEvent(event); }
From source file:net.nym.napply.library.behavior.BottomScrollShowHideBehavior.java
private void hide(final View child) { if (child == null) { return;/*from w w w .ja v a 2 s . c om*/ } final float translationY = child.getTranslationY(); //show -> hide if (translationY < 0 || isAnimate) { return; } ViewPropertyAnimatorCompat animator = ViewCompat.animate(child); animator.translationY(child.getHeight()).setDuration(500).setInterpolator(new DecelerateInterpolator()) .setListener(new ViewPropertyAnimatorListener() { @Override public void onAnimationStart(View view) { isAnimate = true; } @Override public void onAnimationEnd(View view) { child.setVisibility(View.GONE); isAnimate = false; } @Override public void onAnimationCancel(View view) { show(child); } }).start(); }
From source file:net.nym.napply.library.behavior.HeadScrollShowHideBehavior.java
private void hide(final View child) { if (child == null) { return;/*w ww . j ava2s.c om*/ } final float translationY = child.getTranslationY(); //show -> hide if (translationY < 0 || isAnimate) { return; } ViewPropertyAnimatorCompat animator = ViewCompat.animate(child); animator.translationY(-child.getHeight()).setDuration(500).setInterpolator(new DecelerateInterpolator()) .setListener(new ViewPropertyAnimatorListener() { @Override public void onAnimationStart(View view) { isAnimate = true; } @Override public void onAnimationEnd(View view) { child.setVisibility(View.GONE); isAnimate = false; } @Override public void onAnimationCancel(View view) { show(child); } }).start(); }
From source file:cn.zhangls.android.weibo.animation.FABehavior.java
private void animateOut(final FloatingActionButton fab) { ViewCompat.animate(fab).setListener(new ViewPropertyAnimatorListener() { @Override//from w w w . ja va 2 s. c o m public void onAnimationStart(View view) { mIsAnimating = true; fab.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(View view) { mIsAnimating = false; fab.setVisibility(View.INVISIBLE); } @Override public void onAnimationCancel(View view) { mIsAnimating = false; fab.setVisibility(View.VISIBLE); } }).setInterpolator(new AccelerateInterpolator()).setDuration(300).translationY(fab.getHeight()).start(); }
From source file:com.github.shareme.gwsmaterialuikit.library.advancerv.draggable.BaseDraggableItemDecorator.java
protected void moveToDefaultPosition(View targetView, boolean animate) { final int curTranslationX = (int) (ViewCompat.getTranslationX(targetView)); final int curTranslationY = (int) (ViewCompat.getTranslationY(targetView)); final int halfItemWidth = targetView.getWidth() / 2; final int halfItemHeight = targetView.getHeight() / 2; final float translationProportionX = (halfItemWidth > 0) ? Math.abs((float) curTranslationX / halfItemWidth) : 0;//from ww w . j a v a 2 s .c om final float translationProportionY = (halfItemHeight > 0) ? Math.abs((float) curTranslationY / halfItemHeight) : 0; final float tx = 1.0f - Math.min(translationProportionX, 1.0f); final float ty = 1.0f - Math.min(translationProportionY, 1.0f); final int animDurationX = (int) (mReturnToDefaultPositionDuration * (1.0f - (tx * tx)) + 0.5f); final int animDurationY = (int) (mReturnToDefaultPositionDuration * (1.0f - (ty * ty)) + 0.5f); final int animDuration = Math.max(animDurationX, animDurationY); final int maxAbsTranslation = Math.max(Math.abs(curTranslationX), Math.abs(curTranslationY)); if (supportsViewPropertyAnimation() && animate && (animDuration > RETURN_TO_DEFAULT_POS_ANIMATE_THRESHOLD_MSEC) && (maxAbsTranslation > mReturnToDefaultPositionAnimateThreshold)) { final ViewPropertyAnimatorCompat animator = ViewCompat.animate(targetView); animator.cancel(); animator.setDuration(animDuration); animator.setInterpolator(mReturnToDefaultPositionInterpolator); animator.translationX(0.0f); animator.translationY(0.0f); animator.setListener(new ViewPropertyAnimatorListener() { @Override public void onAnimationStart(View view) { } @Override public void onAnimationEnd(View view) { animator.setListener(null); ViewCompat.setTranslationX(view, 0); ViewCompat.setTranslationY(view, 0); // invalidate explicitly to refresh other decorations if (view.getParent() instanceof RecyclerView) { ViewCompat.postInvalidateOnAnimation((RecyclerView) view.getParent()); } } @Override public void onAnimationCancel(View view) { } }); animator.start(); } else { ViewCompat.setTranslationX(targetView, 0); ViewCompat.setTranslationY(targetView, 0); } }
From source file:com.goforer.base.ui.adapter.BaseAdapter.java
/** * Set animation ViewHolder's item if need be. * * @param viewHolder the ViewHolder to set animation ViewHolder's item *///from w w w . ja v a 2 s .c o m public void setAnimateViewIfNecessary(final RecyclerView.ViewHolder viewHolder) { final int position = viewHolder.getAdapterPosition(); if (position <= mLastAnimatedPosition) return; final View itemView = viewHolder.itemView; ViewCompat.setPivotX(itemView, 0); ViewCompat.setPivotY(itemView, 0); ViewCompat.setTranslationY(itemView, VIEW_VERTICAL_POSITION); ViewCompat.postOnAnimation(itemView, new Runnable() { @Override public void run() { ViewPropertyAnimatorCompat translation = ViewCompat.animate(itemView).translationY(ANIMATED_VALUE); ViewPropertyAnimatorCompatSet set = new ViewPropertyAnimatorCompatSet(); set.play(translation); DecelerateInterpolator interpolator = new DecelerateInterpolator(ANIMATION_DEGREE); set.setInterpolator(interpolator).setDuration(ANIMATION_DURATION) .setListener(new ViewPropertyAnimatorListener() { @Override public void onAnimationStart(View view) { } @Override public void onAnimationEnd(View view) { mLastAnimatedPosition = position; } @Override public void onAnimationCancel(View view) { } }).start(); } }); }
From source file:com.skydoves.elasticviewsexample.ElasticVIews.ElasticButton.java
@Override public boolean dispatchTouchEvent(MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { if (listener != null) { if (view.getScaleX() == 1) { ViewCompat.animate(view).setDuration(duration).scaleX(scale).scaleY(scale) .setInterpolator(new CycleInterpolator(0.5f)) .setListener(new ViewPropertyAnimatorListener() { @Override public void onAnimationStart(final View view) { }//from ww w . jav a 2 s . c om @Override public void onAnimationEnd(final View v) { onClick(); } @Override public void onAnimationCancel(final View view) { } }).withLayer().start(); } } } return super.dispatchTouchEvent(event); }
From source file:com.landenlabs.all_UiDemo.Util.BottomAppBarLayoutBehavior.java
private void animateOut(final AppBarLayout appBarLayout) { ViewCompat.animate(appBarLayout).translationY(0F).alpha(0.0F).setInterpolator(INTERPOLATOR).withLayer() .setListener(new ViewPropertyAnimatorListener() { public void onAnimationStart(View view) { BottomAppBarLayoutBehavior.this.mIsAnimatingOut = true; }/*ww w. jav a 2 s .co m*/ public void onAnimationCancel(View view) { BottomAppBarLayoutBehavior.this.mIsAnimatingOut = false; } public void onAnimationEnd(View view) { BottomAppBarLayoutBehavior.this.mIsAnimatingOut = false; view.setVisibility(View.GONE); } }).start(); }
From source file:com.skydoves.elasticviewsexample.ElasticVIews.ElasticCheckButton.java
@Override public boolean dispatchTouchEvent(MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { if (listener != null) { if (view.getScaleX() == 1) { ViewCompat.animate(view).setDuration(duration).scaleX(scale).scaleY(scale) .setInterpolator(new CycleInterpolator(0.5f)) .setListener(new ViewPropertyAnimatorListener() { @Override public void onAnimationStart(final View view) { }/*from ww w . ja v a2s. c o m*/ @Override public void onAnimationEnd(final View v) { checked = !checked; onClick(); } @Override public void onAnimationCancel(final View view) { } }).withLayer().start(); } } } return super.dispatchTouchEvent(event); }