Example usage for android.view.animation DecelerateInterpolator DecelerateInterpolator

List of usage examples for android.view.animation DecelerateInterpolator DecelerateInterpolator

Introduction

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

Prototype

public DecelerateInterpolator() 

Source Link

Usage

From source file:net.nym.napply.library.behavior.HeadScrollShowHideBehavior.java

private void show(final View child) {
    if (child == null) {
        return;//from w  ww .j  a  va2  s  .  c  o m
    }
    final float translationY = child.getTranslationY();
    //hide -> show
    if (translationY >= 0 || isAnimate) {
        return;
    }
    ViewPropertyAnimatorCompat animator = ViewCompat.animate(child);
    animator.translationY(0).setDuration(500).setInterpolator(new DecelerateInterpolator())
            .setListener(new ViewPropertyAnimatorListener() {
                @Override
                public void onAnimationStart(View view) {
                    child.setVisibility(View.VISIBLE);
                    isAnimate = true;
                }

                @Override
                public void onAnimationEnd(View view) {
                    isAnimate = false;
                }

                @Override
                public void onAnimationCancel(View view) {
                    hide(child);
                }
            }).start();
}

From source file:arun.com.chromer.browsing.article.util.ArticleScrollListener.java

@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
    super.onScrollStateChanged(recyclerView, newState);
    final LinearLayoutManager manager = (LinearLayoutManager) recyclerView.getLayoutManager();
    int firstItem = manager.findFirstCompletelyVisibleItemPosition();
    if (newState == RecyclerView.SCROLL_STATE_IDLE && !transparentBackground && firstItem == 0
            && !isUpdatingBackground) {
        animateBackgroundColor(primaryColor, transparentColor, new DecelerateInterpolator());
        transparentBackground = true;//from   w w w  .j a  va  2  s.  com
    }
}

From source file:com.shizhefei.view.coolrefreshview.header.JellyHeader.java

public JellyHeader(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    setWillNotDraw(false);/*from   w  w w . j a  v  a  2s.c  o m*/

    defaultMinHeight = Utils.dipToPix(context, 208);

    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setStyle(Paint.Style.FILL);

    mPath = new Path();

    showLoadingAnimation = new AlphaAnimation(0, 1);
    showLoadingAnimation.setDuration(300);
    showLoadingAnimation.setInterpolator(new AccelerateInterpolator());

    hideLoadingAnimation = new AlphaAnimation(1, 0);
    hideLoadingAnimation.setDuration(300);
    hideLoadingAnimation.setInterpolator(new DecelerateInterpolator());

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        mViewOutlineProvider = new ViewOutlineProvider() {
            @TargetApi(Build.VERSION_CODES.LOLLIPOP)
            @Override
            public void getOutline(View view, Outline outline) {
                if (mPath.isConvex())
                    outline.setConvexPath(mPath);
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
                    outline.offset(0, totalDistance() - currentDistance);
                }
            }
        };
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            setElevation(Utils.dipToPix(context, 4));
        }
    }
}

From source file:com.karthikb351.vitinfo2.customwidget.ScheduleView.java

public void setAttendance(int attendance) {
    ObjectAnimator animation = ObjectAnimator.ofInt(progressAttendance, "progress", attendance);
    animation.setDuration(1500);/* www  . java 2  s  . c om*/
    animation.setInterpolator(new DecelerateInterpolator());
    animation.start();

    if (attendance >= 80) {
        progressAttendance.setReachedBarColor(ContextCompat.getColor(getContext(), R.color.text_secondary));
        progressAttendance.setProgressTextColor(ContextCompat.getColor(getContext(), R.color.text_secondary));
    } else if (attendance < 75) {
        progressAttendance
                .setReachedBarColor(ContextCompat.getColor(getContext(), android.R.color.holo_red_light));
        progressAttendance
                .setProgressTextColor(ContextCompat.getColor(getContext(), android.R.color.holo_red_light));
    } else {
        progressAttendance.setReachedBarColor(ContextCompat.getColor(getContext(), R.color.midAttend));
        progressAttendance.setProgressTextColor(ContextCompat.getColor(getContext(), R.color.midAttend));
    }
}

From source file:org.videolan.myvlc.core.gui.about.AboutMainFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.about_main, container, false);
    TextView link = (TextView) v.findViewById(R.id.main_link);
    link.setText(Html.fromHtml(this.getString(R.string.about_link)));

    String builddate = Util.readAsset("builddate.txt", "Unknown");
    String builder = Util.readAsset("builder.txt", "unknown");
    String revision = Util.readAsset("revision.txt", "unknown");

    TextView compiled = (TextView) v.findViewById(R.id.main_compiled);
    compiled.setText(builder + " (" + builddate + ")");
    TextView textview_rev = (TextView) v.findViewById(R.id.main_revision);
    textview_rev.setText(getResources().getString(R.string.revision) + " " + revision + " (" + builddate + ")");

    final ImageView logo = (ImageView) v.findViewById(R.id.logo);
    logo.setOnClickListener(new OnClickListener() {
        @Override/*w  w  w.ja  v  a2s  .c  om*/
        public void onClick(View v) {
            AnimationSet anim = new AnimationSet(true);
            RotateAnimation rotate = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 0.5f,
                    Animation.RELATIVE_TO_SELF, 0.5f);
            rotate.setDuration(800);
            rotate.setInterpolator(new DecelerateInterpolator());
            anim.addAnimation(rotate);
            logo.startAnimation(anim);
        }
    });

    return v;
}

From source file:jiajun.threelevelistview.layout.FlingLayout.java

public void init(Context context) {
    version = android.os.Build.VERSION.SDK_INT;
    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    mScroller = new Scroller(context, new DecelerateInterpolator());
    mParentHelper = new NestedScrollingParentHelper(this);
    mChildHelper = new NestedScrollingChildHelper(this);
}

From source file:com.karthikb351.vitinfo2.fragment.courses.CourseListAdapter.java

public void setAttendance(CourseViewHolder courseViewHolder, int attendance) {
    ObjectAnimator animation = ObjectAnimator.ofInt(courseViewHolder.numberProgressBar, "progress", attendance);
    animation.setDuration(1500);/*from  w  w w. j  a v a 2 s  . co m*/
    animation.setInterpolator(new DecelerateInterpolator());
    animation.start();

    if (attendance >= 80) {
        courseViewHolder.numberProgressBar
                .setReachedBarColor(ContextCompat.getColor(this.context, R.color.text_secondary));
        courseViewHolder.numberProgressBar
                .setProgressTextColor(ContextCompat.getColor(this.context, R.color.text_secondary));
    } else if (attendance < 75) {
        courseViewHolder.numberProgressBar
                .setReachedBarColor(ContextCompat.getColor(this.context, android.R.color.holo_red_light));
        courseViewHolder.numberProgressBar
                .setProgressTextColor(ContextCompat.getColor(this.context, android.R.color.holo_red_light));
    } else {
        courseViewHolder.numberProgressBar
                .setReachedBarColor(ContextCompat.getColor(this.context, R.color.midAttend));
        courseViewHolder.numberProgressBar
                .setProgressTextColor(ContextCompat.getColor(this.context, R.color.midAttend));
    }
}

From source file:net.nym.napply.library.behavior.BottomScrollShowHideBehavior.java

private void hide(final View child) {
    if (child == null) {
        return;// ww  w  .j  a v a 2s  .  co  m
    }
    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 animateIn(final FloatingActionButton fab) {
    ViewCompat.animate(fab).setListener(new ViewPropertyAnimatorListener() {
        @Override/*w  w w  . j a v a 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.VISIBLE);
        }

        @Override
        public void onAnimationCancel(View view) {
            mIsAnimating = false;
            fab.setVisibility(View.INVISIBLE);
        }
    }).setInterpolator(new DecelerateInterpolator()).setDuration(300).translationY(-fab.getHeight()).start();
}

From source file:im.ene.ribbon.AnimUtil.java

static void animate(BottomNavigationView parent, View view, final View backgroundOverlay,
        final ColorDrawable backgroundDrawable, final int newColor, long duration) {
    int centerX = (int) (ViewCompat.getX(view) + (view.getWidth() / 2));
    int centerY = parent.getPaddingTop() + view.getHeight() / 2;

    backgroundOverlay.clearAnimation();/*from   w  ww .  j  a  v a  2s.c  om*/

    final Object animator;

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Animator currentAnimator = (Animator) backgroundOverlay.getTag(R.id.ribbon_background_overlay_animator);
        if (currentAnimator != null) {
            //currentAnimator.end();
            currentAnimator.cancel();
        }

        final float startRadius = 1;
        final float finalRadius = centerX > parent.getWidth() / 2 ? centerX : parent.getWidth() - centerX;
        animator = ViewAnimationUtils.createCircularReveal(backgroundOverlay, centerX, centerY, startRadius,
                finalRadius);
        backgroundOverlay.setTag(R.id.ribbon_background_overlay_animator, animator);
    } else {
        ViewCompat.setAlpha(backgroundOverlay, 0);
        animator = ViewCompat.animate(backgroundOverlay).alpha(1);
    }

    backgroundOverlay.setBackgroundColor(newColor);
    backgroundOverlay.setVisibility(View.VISIBLE);

    if (animator instanceof ViewPropertyAnimatorCompat) {
        ((ViewPropertyAnimatorCompat) animator).setListener(new ViewPropertyAnimatorListener() {
            boolean cancelled;

            @Override
            public void onAnimationStart(final View view) {
            }

            @Override
            public void onAnimationEnd(final View view) {
                if (!cancelled) {
                    backgroundDrawable.setColor(newColor);
                    backgroundOverlay.setVisibility(View.INVISIBLE);
                    ViewCompat.setAlpha(backgroundOverlay, 1);
                }
            }

            @Override
            public void onAnimationCancel(final View view) {
                cancelled = true;
            }
        }).setDuration(duration).start();
    } else {
        Animator animator1 = (Animator) animator;
        animator1.setDuration(duration);
        animator1.setInterpolator(new DecelerateInterpolator());
        animator1.addListener(new Animator.AnimatorListener() {
            boolean cancelled;

            @Override
            public void onAnimationStart(final Animator animation) {
            }

            @Override
            public void onAnimationEnd(final Animator animation) {
                if (!cancelled) {
                    backgroundDrawable.setColor(newColor);
                    backgroundOverlay.setVisibility(View.INVISIBLE);
                    ViewCompat.setAlpha(backgroundOverlay, 1);
                }
            }

            @Override
            public void onAnimationCancel(final Animator animation) {
                cancelled = true;
            }

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

        animator1.start();
    }
}