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(float factor) 

Source Link

Document

Constructor

Usage

From source file:tech.salroid.filmy.fragment.FullReadFragment.java

@Nullable
@Override/* w  w  w.  j a  va 2 s  . co m*/
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.read_full_layout, container, false);
    ButterKnife.bind(this, view);

    crossButton.setOnClickListener(this);

    // To run the animation as soon as the view is layout in the view hierarchy we add this
    // listener and remove it
    // as soon as it runs to prevent multiple animations if the view changes bounds
    view.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop,
                int oldRight, int oldBottom) {
            v.removeOnLayoutChangeListener(this);

            int cx = getArguments().getInt("cx");
            int cy = getArguments().getInt("cy");

            // get the hypothenuse so the radius is from one corner to the other
            int radius = (int) Math.hypot(right, bottom);

            Animator reveal;

            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
                reveal = ViewAnimationUtils.createCircularReveal(v, cx, cy, 0, radius);
                reveal.setInterpolator(new DecelerateInterpolator(2f));
                reveal.setDuration(1000);
                reveal.start();
            }

        }
    });

    return view;
}

From source file:com.kuloud.android.unity.ui.widget.steprefresh.PullToRefreshView.java

public PullToRefreshView(Context context, AttributeSet attrs) {
    super(context, attrs);

    mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR);
    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    mTotalDragDistance = UIUtils.dpToPxInt(context, DRAG_MAX_DISTANCE);

    mRefreshView = new ImageView(context);

    setRefreshStyle();/*from w  w  w.ja va  2 s . com*/

    addView(mRefreshView);

    setWillNotDraw(false);
    ViewCompat.setChildrenDrawingOrderEnabled(this, true);
}

From source file:com.runmit.sweedee.view.flippablestackview.StackPageTransformer.java

/**
 * Used to construct the basic method for visual transformation in
 * <code>FlippableStackView</code>.
 *
 * @param numberOfStacked//from   w w  w  .j a v  a  2 s  .com
 *            Number of pages stacked under the current page.
 * @param topStackedScale
 *            Scale of the top stacked page. Must be a value from (0,
 *            <code>currentPageScale</code>].
 * @param overlapFactor
 *            Defines the usage of available space for the overlapping by
 *            stacked pages. Must be a value from [0, 1]. Value 1 means that
 *            the whole available space (obtained due to the scaling with
 *            <code>currentPageScale</code>) will be used for the purpose of
 *            displaying stacked views. Value 0 means that no space will be
 *            used for this purpose (in other words - no stacked views will
 *            be visible).
 * @param gravity
 *            Specifies the alignment of the stack (vertically) withing
 *            <code>View</code> bounds.
 */
public StackPageTransformer(int numberOfStacked, float topStackedScale, float overlapFactor) {
    mNumberOfStacked = numberOfStacked;
    mAlphaFactor = 1.0f / (mNumberOfStacked + 1);
    mZeroPositionScale = 1.0f;
    mStackedScaleFactor = (1 - topStackedScale) / mNumberOfStacked;
    mOverlapFactor = overlapFactor;

    mScaleInterpolator = new DecelerateInterpolator(1.3f);
    mRotationInterpolator = new AccelerateInterpolator(0.6f);
    mValueInterpolator = new ValueInterpolator(0, 1, 0, mZeroPositionScale);
}

From source file:me.drakeet.meizhi.ui.GankActivity.java

@Override
protected void hideOrShowToolbar() {
    View toolbar = findViewById(R.id.toolbar_with_indicator);
    assert toolbar != null;
    toolbar.animate().translationY(mIsHidden ? 0 : -mToolbar.getHeight())
            .setInterpolator(new DecelerateInterpolator(2)).start();
    mIsHidden = !mIsHidden;/*from  w w w  .ja  v a2  s. c  om*/
    if (mIsHidden) {
        mViewPager.setTag(mViewPager.getPaddingTop());
        mViewPager.setPadding(0, 0, 0, 0);
    } else {
        mViewPager.setPadding(0, (int) mViewPager.getTag(), 0, 0);
        mViewPager.setTag(null);
    }
}

From source file:tech.salroid.filmy.fragment.AllTrailerFragment.java

@Nullable
@Override// w  w w .  j a va 2 s .c  om
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {

    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity());
    nightMode = sp.getBoolean("dark", false);

    View view = inflater.inflate(R.layout.all_trailer_layout, container, false);
    ButterKnife.bind(this, view);

    if (!nightMode)
        allThemeLogic();
    else {
        nightModeLogic();
    }

    crossButton.setOnClickListener(this);

    // To run the animation as soon as the view is layout in the view hierarchy we add this
    // listener and remove it
    // as soon as it runs to prevent multiple animations if the view changes bounds
    view.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop,
                int oldRight, int oldBottom) {
            v.removeOnLayoutChangeListener(this);

            int cx = getArguments().getInt("cx");
            int cy = getArguments().getInt("cy");

            // get the hypothenuse so the radius is from one corner to the other
            int radius = (int) Math.hypot(right, bottom);

            Animator reveal;

            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
                reveal = ViewAnimationUtils.createCircularReveal(v, cx, cy, 0, radius);
                reveal.setInterpolator(new DecelerateInterpolator(2f));
                reveal.setDuration(1000);
                reveal.start();
            }

        }
    });

    init(view);

    return view;
}

From source file:id.zelory.tanipedia.activity.JawabActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_jawab);
    Toolbar toolbar = (Toolbar) findViewById(R.id.anim_toolbar);
    setSupportActionBar(toolbar);//from  w ww  .j  a  va 2  s  .co m
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
    collapsingToolbar.setTitle("Tanya Tani");

    soal = getIntent().getParcelableExtra("soal");
    try {
        idSoal = URLEncoder.encode(soal.getId(), "UTF-8");
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    Animation animation = AnimationUtils.loadAnimation(this, R.anim.simple_grow);
    fabMargin = getResources().getDimensionPixelSize(R.dimen.fab_margin);

    recyclerView = (RecyclerView) findViewById(R.id.scrollableview);
    recyclerView.setHasFixedSize(true);
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
    recyclerView.setLayoutManager(linearLayoutManager);

    recyclerView.addOnScrollListener(new MyRecyclerScroll() {
        @Override
        public void show() {
            fab.animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)).start();
        }

        @Override
        public void hide() {
            fab.animate().translationY(fab.getHeight() + fabMargin)
                    .setInterpolator(new AccelerateInterpolator(2)).start();
        }
    });

    fab = (FrameLayout) findViewById(R.id.myfab_main);
    fabBtn = (ImageButton) findViewById(R.id.myfab_main_btn);
    View fabShadow = findViewById(R.id.myfab_shadow);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        fabShadow.setVisibility(View.GONE);
        fabBtn.setBackground(getDrawable(R.drawable.ripple_accent));
    }

    fab.startAnimation(animation);

    fabBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            new MaterialDialog.Builder(JawabActivity.this).title("TaniPedia").content("Kirim Jawaban")
                    .inputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_CLASS_TEXT)
                    .input("Ketik jawaban anda disini!", null, false, new MaterialDialog.InputCallback() {
                        @Override
                        public void onInput(MaterialDialog dialog, CharSequence input) {
                            try {
                                jawaban = URLEncoder.encode(input.toString(), "UTF-8");
                                new KirimJawaban().execute();
                            } catch (UnsupportedEncodingException e) {
                                Snackbar.make(fabBtn, "Terjadi kesalahan, silahkan coba lagi!",
                                        Snackbar.LENGTH_LONG).show();
                                e.printStackTrace();
                            }
                        }
                    }).positiveColorRes(R.color.primary_dark).positiveText("Kirim")
                    .cancelListener(new DialogInterface.OnCancelListener() {
                        @Override
                        public void onCancel(DialogInterface dialog) {

                        }
                    }).negativeColorRes(R.color.primary_dark).negativeText("Batal").show();
        }
    });

    fabButton = (FabButton) findViewById(R.id.determinate);
    fabButton.showProgress(true);
    new DownloadData().execute();
    fabButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            fabButton.showProgress(true);
            new DownloadData().execute();
        }
    });
}

From source file:android.improving.utils.views.cardsview.StackPageTransformer.java

/**
 * Used to construct the basic method for visual transformation in <code>FlippableStackView</code>.
 *
 * @param numberOfStacked  Number of pages stacked under the current page.
 * @param orientation      Orientation of the stack.
 * @param currentPageScale Scale of the current page. Must be a value from (0, 1].
 * @param topStackedScale  Scale of the top stacked page. Must be a value from
 *                         (0, <code>currentPageScale</code>].
 * @param overlapFactor    Defines the usage of available space for the overlapping by stacked
 *                         pages. Must be a value from [0, 1]. Value 1 means that the whole
 *                         available space (obtained due to the scaling with
 *                         <code>currentPageScale</code>) will be used for the purpose of displaying
 *                         stacked views. Value 0 means that no space will be used for this purpose
 *                         (in other words - no stacked views will be visible).
 * @param gravity          Specifies the alignment of the stack (vertically) withing <code>View</code>
 *                         bounds.// ww  w  . j ava  2  s.co  m
 */
public StackPageTransformer(int numberOfStacked, Orientation orientation, float currentPageScale,
        float topStackedScale, float overlapFactor, Gravity gravity) {
    validateValues(currentPageScale, topStackedScale, overlapFactor);

    mNumberOfStacked = numberOfStacked;
    mAlphaFactor = 1.0f / (mNumberOfStacked + 1);
    mZeroPositionScale = currentPageScale;
    mStackedScaleFactor = (currentPageScale - topStackedScale) / mNumberOfStacked;
    mOverlapFactor = overlapFactor;
    mOrientation = orientation;
    mGravity = gravity;

    mScaleInterpolator = new DecelerateInterpolator(1.3f);
    mRotationInterpolator = new AccelerateInterpolator(0.6f);
    mValueInterpolator = new ValueInterpolator(0, 1, 0, mZeroPositionScale);
}

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 ww .  j  a  v  a2  s.  c om*/
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.savvasdalkitsis.betwixt.Interpolators.java

/**
 * <strong>ANDROID INTERPOLATOR</strong><br/><br/>
 * An interpolator where the rate of change starts out quickly and and then decelerates.
 * @param factor Degree to which the animation should be eased. Setting factor to 1.0f produces
 *               an upside-down y=x^2 parabola. Increasing factor above 1.0f makes exaggerates
 *               the ease-out effect (i.e., it starts even faster and ends evens slower)
 *//*from  w w w .  j a v  a 2s .c o m*/
@NonNull
public static Interpolator decelerate(int factor) {
    return new DecelerateInterpolator(factor);
}

From source file:com.dat.towerofhanoi.draggablerecyclerview.BoardView.java

@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    Resources res = getResources();
    boolean isPortrait = res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
    if (isPortrait) {
        mColumnWidth = (int) (res.getDisplayMetrics().widthPixels * 0.87);
    } else {/*  ww  w.j av  a 2  s.c  om*/
        mColumnWidth = (int) (res.getDisplayMetrics().density * 320);
    }

    mGestureDetector = new GestureDetector(getContext(), new GestureListener());
    mScroller = new Scroller(getContext(), new DecelerateInterpolator(1.1f));
    mAutoScroller = new AutoScroller(getContext(), this);
    mAutoScroller.setAutoScrollMode(snapToColumnWhenDragging() ? AutoScroller.AutoScrollMode.COLUMN
            : AutoScroller.AutoScrollMode.POSITION);
    mDragItem = new DragItem(getContext());

    mRootLayout = new FrameLayout(getContext());
    mRootLayout.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));

    mColumnLayout = new LinearLayout(getContext());
    mColumnLayout.setOrientation(LinearLayout.HORIZONTAL);
    mColumnLayout.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
    mColumnLayout.setMotionEventSplittingEnabled(false);

    mRootLayout.addView(mColumnLayout);
    mRootLayout.addView(mDragItem.getDragItemView());
    addView(mRootLayout);
}