Example usage for android.view.animation AccelerateInterpolator AccelerateInterpolator

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

Introduction

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

Prototype

public AccelerateInterpolator(float factor) 

Source Link

Document

Constructor

Usage

From source file:com.cheng.animationstudy.customview.googleimitatecode.DiySwipeRefreshLayout.java

/**
 * Constructor that is called when inflating SwipeRefreshLayout from XML.
 * @param context//from  w  w w  .j ava 2s  .  com
 * @param attrs
 */
public DiySwipeRefreshLayout(Context context, AttributeSet attrs) {
    super(context, attrs);

    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();

    mMediumAnimationDuration = getResources().getInteger(android.R.integer.config_mediumAnimTime);

    setWillNotDraw(false);
    mProgressBar = new DiySwipeProgressBar(this);
    mProgressBarBottom = new DiySwipeProgressBar(this);
    final DisplayMetrics metrics = getResources().getDisplayMetrics();
    mProgressBarHeight = (int) (metrics.density * PROGRESS_BAR_HEIGHT);
    mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR);
    mAccelerateInterpolator = new AccelerateInterpolator(ACCELERATE_INTERPOLATION_FACTOR);

    final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS);
    setEnabled(a.getBoolean(0, true));
    a.recycle();
}

From source file:com.example.googleplay.view.SwipeRefreshLayout.java

/**
 * Constructor that is called when inflating SwipeRefreshLayout from XML.
 * @param context/*from   w w w . j  a v  a  2 s  .co m*/
 * @param attrs
 */
public SwipeRefreshLayout(Context context, AttributeSet attrs) {
    super(context, attrs);

    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();

    mMediumAnimationDuration = getResources().getInteger(android.R.integer.config_mediumAnimTime);

    setWillNotDraw(false);
    mProgressBar = new SwipeProgressBar(this);
    mProgressBarBottom = new SwipeProgressBar(this);
    final DisplayMetrics metrics = getResources().getDisplayMetrics();
    mProgressBarHeight = (int) (metrics.density * PROGRESS_BAR_HEIGHT);
    System.out.println("mProgressBarHeight" + mProgressBarHeight);
    mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR);
    mAccelerateInterpolator = new AccelerateInterpolator(ACCELERATE_INTERPOLATION_FACTOR);

    final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS);
    setEnabled(a.getBoolean(0, true));
    a.recycle();
}

From source file:me.albinmathew.celluloid.ui.activities.MoviesActivity.java

@Override
public void hideControls() {
    mFilterPanelLinearLayout.animate().translationY(mFilterPanelLinearLayout.getHeight())
            .setInterpolator(new AccelerateInterpolator(2));
}

From source file:com.example.adminstrator.pullrefresh.SwipeRefreshLayout.java

/**
 * Constructor that is called when inflating SwipeRefreshLayout from XML.
 * @param context/*  w ww .ja  v a2 s.c  o m*/
 * @param attrs
 */
public SwipeRefreshLayout(Context context, AttributeSet attrs) {
    super(context, attrs);

    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();

    mMediumAnimationDuration = getResources().getInteger(android.R.integer.config_mediumAnimTime);

    setWillNotDraw(false);
    mProgressBar = new RefreshProgressBar(getContext(), 0);
    mProgressBar.setTipText("", "?", "");
    mProgressBarBottom = new RefreshProgressBar(getContext(), 1);
    mProgressBarBottom.setTipText("", "?", "");
    final DisplayMetrics metrics = getResources().getDisplayMetrics();
    mProgressBarHeight = (int) (metrics.density * PROGRESS_BAR_HEIGHT);
    mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR);
    mAccelerateInterpolator = new AccelerateInterpolator(ACCELERATE_INTERPOLATION_FACTOR);

    final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS);
    setEnabled(a.getBoolean(0, true));
    a.recycle();
    this.addView(mProgressBar, 0);
    this.addView(mProgressBarBottom, 0);
}

From source file:com.lastsoft.plog.GamesFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View rootView = inflater.inflate(R.layout.fragment_games, container, false);

    rootView.setTag(TAG);/*from   w ww  .  j av  a  2  s .  c  o  m*/

    // BEGIN_INCLUDE(initializeRecyclerView)
    mCoordinatorLayout = (CoordinatorLayout) rootView.findViewById(R.id.coordinatorLayout);
    mRecyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerView);
    mRecyclerView.setBackgroundColor(getResources().getColor(R.color.cardview_initial_background));
    pullToRefreshView = (SwipeRefreshLayout) rootView.findViewById(R.id.pull_to_refresh_listview);
    pullToRefreshView.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            initDataset(true);
        }
    });

    RecyclerFastScroller fastScroller = (RecyclerFastScroller) rootView.findViewById(R.id.fastscroller);
    fastScroller.attachRecyclerView(mRecyclerView);
    //fastScroller = (VerticalRecyclerViewFastScroller) rootView.findViewById(R.id.fastscroller);

    // Connect the recycler to the scroller (to let the scroller scroll the list)
    //fastScroller.setRecyclerView(mRecyclerView, pullToRefreshView);

    // Connect the scroller to the recycler (to let the recycler scroll the scroller's handle)
    //mRecyclerView.setOnScrollListener(fastScroller.getOnScrollListener());

    addPlayer = (FloatingActionButton) rootView.findViewById(R.id.add_game);
    if (fromDrawer && playListType != 2) {
        //fastScroller.setRecyclerView(mRecyclerView, pullToRefreshView);
        mRecyclerView.setOnScrollListener(new OnScrollListener() {
            @Override
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                super.onScrolled(recyclerView, dx, dy);
                boolean enable = false;
                boolean firstItemVisiblePull = recyclerView.getChildPosition(recyclerView.getChildAt(0)) == 0;
                boolean topOfFirstItemVisiblePull = recyclerView.getChildAt(0).getTop() == recyclerView
                        .getChildAt(0).getTop();
                ;
                enable = firstItemVisiblePull && topOfFirstItemVisiblePull;
                pullToRefreshView.setEnabled(enable);
            }
        });
        addPlayer.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                int viewXY[] = new int[2];
                v.getLocationOnScreen(viewXY);
                if (mListener != null) {
                    mListener.onFragmentInteraction("add_game", viewXY[0], viewXY[1]);
                }
            }
        });
    } else {
        if (!fromDrawer) {
            RelativeLayout gamesLayout = (RelativeLayout) rootView.findViewById(R.id.gamesLayout);
            final SwipeDismissBehavior<LinearLayout> behavior = new SwipeDismissBehavior();
            behavior.setSwipeDirection(SwipeDismissBehavior.SWIPE_DIRECTION_START_TO_END);
            behavior.setStartAlphaSwipeDistance(1.0f);
            behavior.setSensitivity(0.15f);
            behavior.setListener(new SwipeDismissBehavior.OnDismissListener() {
                @Override
                public void onDismiss(final View view) {
                    GamesFragment myFragC1 = (GamesFragment) getFragmentManager().findFragmentByTag("games");
                    FragmentTransaction transaction = getFragmentManager().beginTransaction();
                    transaction.remove(myFragC1);
                    transaction.commitAllowingStateLoss();
                    getFragmentManager().executePendingTransactions();
                    mActivity.onBackPressed();
                }

                @Override
                public void onDragStateChanged(int i) {

                }
            });

            CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) gamesLayout
                    .getLayoutParams();
            params.setBehavior(behavior);

        }
        //fastScroller.setRecyclerView(mRecyclerView, null);
        pullToRefreshView.setEnabled(false);
        addPlayer.setVisibility(View.GONE);
    }

    mProgress = (LinearLayout) rootView.findViewById(R.id.progressContainer);
    mText = (TextView) rootView.findViewById(R.id.LoadingText);

    // LinearLayoutManager is used here, this will layout the elements in a similar fashion
    // to the way ListView would layout elements. The RecyclerView.LayoutManager defines how
    // elements are laid out.
    mLayoutManager = new LinearLayoutManager(mActivity);

    mCurrentLayoutManagerType = LayoutManagerType.LINEAR_LAYOUT_MANAGER;

    if (savedInstanceState != null) {
        // Restore saved layout manager type.
        mCurrentLayoutManagerType = (LayoutManagerType) savedInstanceState.getSerializable(KEY_LAYOUT_MANAGER);
    }
    setRecyclerViewLayoutManager(mCurrentLayoutManagerType);

    //mAdapter = new CustomAdapter(mDataset, mDataset_Thumb);
    mAdapter = new GameAdapter(this, mActivity, mSearchQuery, fromDrawer, playListType, sortType, fragmentName,
            currentYear);
    // Set CustomAdapter as the adapter for RecyclerView.
    mRecyclerView.setAdapter(mAdapter);

    if (mSearch != null) {
        mSearch.setHint(
                getString(R.string.filter) + mAdapter.getItemCount() + getString(R.string.filter_games));
    }

    fabMargin = getResources().getDimensionPixelSize(R.dimen.fab_margin);
    mRecyclerView.addOnScrollListener(new MyRecyclerScroll() {
        @Override
        public void show() {
            addPlayer.animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)).start();
        }

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

    if (mSearch != null) {
        mSearch.addTextChangedListener(new TextWatcher() {

            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) {
                // When user changed the Text
                mSearchQuery = cs.toString();
                //initDataset();
                mAdapter = new GameAdapter(GamesFragment.this, mActivity, mSearchQuery, fromDrawer,
                        playListType, sortType, fragmentName, currentYear);
                // Set CustomAdapter as the adapter for RecyclerView.
                mRecyclerView.setAdapter(mAdapter);

                if (mSearch != null) {
                    mSearch.setHint(getString(R.string.filter) + mAdapter.getItemCount()
                            + getString(R.string.filter_games));
                }
            }

            @Override
            public void afterTextChanged(Editable editable) {

            }

        });

        mCancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (!mSearch.getText().toString().equals("")) {
                    mSearchQuery = "";
                    mSearch.setText(mSearchQuery);
                    //mActivity.onBackPressed();
                }

                //fastScroller.scrollHider();

                InputMethodManager inputManager = (InputMethodManager) mActivity
                        .getSystemService(Context.INPUT_METHOD_SERVICE);

                inputManager.hideSoftInputFromWindow(mActivity.getCurrentFocus().getWindowToken(),
                        InputMethodManager.HIDE_NOT_ALWAYS);
                mSearch.clearFocus();
                mRecyclerView.requestFocus();

                initDataset(false);

                if (mSearch != null) {
                    mSearch.setHint(getString(R.string.filter) + mAdapter.getItemCount()
                            + getString(R.string.filter_games));
                }
            }
        });
    }

    Calendar calendar = Calendar.getInstance();
    int year = calendar.get(Calendar.YEAR);
    if (Game.findBaseGames("", sortType, year).size() == 0) {
        initDataset(false);
    } else {
        mText.setVisibility(View.GONE);
        mProgress.setVisibility(View.GONE);
        mRecyclerView.setVisibility(View.VISIBLE);
    }

    // END_INCLUDE(initializeRecyclerView)
    return rootView;
}

From source file:j2w.team.common.widget.swipeRefresh.SwipeRefreshLayout.java

/**
 * Constructor that is called when inflating SwipeRefreshLayout from XML.
 * /*from  w  w  w .ja v a2  s .c o m*/
 * @param context
 * @param attrs
 */
public SwipeRefreshLayout(Context context, AttributeSet attrs) {
    super(context, attrs);

    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();

    mMediumAnimationDuration = getResources().getInteger(android.R.integer.config_mediumAnimTime);

    setWillNotDraw(false);
    mProgressBar = new SwipeProgressBar(this);
    mProgressBarBottom = new SwipeProgressBar(this);

    TypedArray styledAttributes = context.obtainStyledAttributes(attrs, R.styleable.J2WRefreshStyle);

    int color1 = styledAttributes.getInt(R.styleable.J2WRefreshStyle_loading_color1, 0xB3000000);
    int color2 = styledAttributes.getInt(R.styleable.J2WRefreshStyle_loading_color2, 0x80000000);
    int color3 = styledAttributes.getInt(R.styleable.J2WRefreshStyle_loading_color3, 0x4d000000);
    int color4 = styledAttributes.getInt(R.styleable.J2WRefreshStyle_loading_color4, 0x1a000000);

    mProgressBar.setColorScheme(color1, color2, color3, color4);
    mProgressBarBottom.setColorScheme(color1, color2, color3, color4);

    final DisplayMetrics metrics = getResources().getDisplayMetrics();
    mProgressBarHeight = (int) (metrics.density * PROGRESS_BAR_HEIGHT);
    mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR);
    mAccelerateInterpolator = new AccelerateInterpolator(ACCELERATE_INTERPOLATION_FACTOR);

    final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS);
    setEnabled(a.getBoolean(0, true));
    a.recycle();
}

From source file:com.android.launcher3.folder.FolderIcon.java

private void onDrop(final ShortcutInfo item, DragView animateView, Rect finalRect,
        float scaleRelativeToDragLayer, int index, Runnable postAnimationRunnable) {
    item.cellX = -1;//from www . jav a  2 s.  com
    item.cellY = -1;

    // Typically, the animateView corresponds to the DragView; however, if this is being done
    // after a configuration activity (ie. for a Shortcut being dragged from AllApps) we
    // will not have a view to animate
    if (animateView != null) {
        DragLayer dragLayer = mLauncher.getDragLayer();
        Rect from = new Rect();
        dragLayer.getViewRectRelativeToSelf(animateView, from);
        Rect to = finalRect;
        if (to == null) {
            to = new Rect();
            Workspace workspace = mLauncher.getWorkspace();
            // Set cellLayout and this to it's final state to compute final animation locations
            workspace.setFinalTransitionTransform((CellLayout) getParent().getParent());
            float scaleX = getScaleX();
            float scaleY = getScaleY();
            setScaleX(1.0f);
            setScaleY(1.0f);
            scaleRelativeToDragLayer = dragLayer.getDescendantRectRelativeToSelf(this, to);
            // Finished computing final animation locations, restore current state
            setScaleX(scaleX);
            setScaleY(scaleY);
            workspace.resetTransitionTransform((CellLayout) getParent().getParent());
        }

        int[] center = new int[2];
        float scale = getLocalCenterForIndex(index, index + 1, center);
        center[0] = (int) Math.round(scaleRelativeToDragLayer * center[0]);
        center[1] = (int) Math.round(scaleRelativeToDragLayer * center[1]);

        to.offset(center[0] - animateView.getMeasuredWidth() / 2,
                center[1] - animateView.getMeasuredHeight() / 2);

        float finalAlpha = index < mPreviewLayoutRule.numItems() ? 0.5f : 0f;

        float finalScale = scale * scaleRelativeToDragLayer;
        dragLayer.animateView(animateView, from, to, finalAlpha, 1, 1, finalScale, finalScale,
                DROP_IN_ANIMATION_DURATION, new DecelerateInterpolator(2), new AccelerateInterpolator(2),
                postAnimationRunnable, DragLayer.ANIMATION_END_DISAPPEAR, null);
        addItem(item);
        mFolder.hideItem(item);

        final PreviewItemDrawingParams params = index < mDrawingParams.size() ? mDrawingParams.get(index)
                : null;
        if (params != null)
            params.hidden = true;
        postDelayed(new Runnable() {
            public void run() {
                if (params != null)
                    params.hidden = false;
                mFolder.showItem(item);
                invalidate();
            }
        }, DROP_IN_ANIMATION_DURATION);
    } else {
        addItem(item);
    }
}

From source file:com.hippo.widget.refreshlayout.RefreshLayout.java

/**
 * Constructor that is called when inflating SwipeRefreshLayout from XML.
 *
 * @param context/*w  ww. j  a  va 2 s .co m*/
 * @param attrs
 */
public RefreshLayout(Context context, AttributeSet attrs) {
    super(context, attrs);

    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();

    mMediumAnimationDuration = getResources().getInteger(android.R.integer.config_mediumAnimTime);

    setWillNotDraw(false);
    mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR);
    mAccelerateInterpolator = new AccelerateInterpolator(ACCELERATE_INTERPOLATION_FACTOR);

    final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS);
    setEnabled(a.getBoolean(0, true));
    a.recycle();

    final DisplayMetrics metrics = getResources().getDisplayMetrics();
    mCircleWidth = (int) (CIRCLE_DIAMETER * metrics.density);
    mCircleHeight = (int) (CIRCLE_DIAMETER * metrics.density);

    createProgressView();
    ViewCompat.setChildrenDrawingOrderEnabled(this, true);
    // the absolute offset has to take into account that the circle starts at an offset
    mSpinnerFinalOffset = DEFAULT_CIRCLE_TARGET * metrics.density;
    mHeaderTotalDragDistance = mSpinnerFinalOffset;

    mProgressBar = new SwipeProgressBar(this);
    mProgressBarHeight = (int) (metrics.density * PROGRESS_BAR_HEIGHT);
}

From source file:com.cyan.widget.refreshlayout.RefreshLayout.java

/**
 * Constructor that is called when inflating SwipeRefreshLayout from XML.
 *
 * @param context//from   ww  w.j a  va  2s . co m
 * @param attrs
 */
public RefreshLayout(Context context, AttributeSet attrs) {
    super(context, attrs);
    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();

    mMediumAnimationDuration = getResources().getInteger(android.R.integer.config_mediumAnimTime);

    setWillNotDraw(false);
    mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR);
    mAccelerateInterpolator = new AccelerateInterpolator(ACCELERATE_INTERPOLATION_FACTOR);

    final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS);
    setEnabled(a.getBoolean(0, true));
    a.recycle();

    final DisplayMetrics metrics = getResources().getDisplayMetrics();
    mCircleWidth = (int) (CIRCLE_DIAMETER * metrics.density);
    mCircleHeight = (int) (CIRCLE_DIAMETER * metrics.density);

    createProgressView();
    ViewCompat.setChildrenDrawingOrderEnabled(this, true);
    // the absolute offset has to take into account that the circle starts at an offset
    mSpinnerFinalOffset = DEFAULT_CIRCLE_TARGET * metrics.density;
    mHeaderTotalDragDistance = mSpinnerFinalOffset;

    mProgressBar = new SwipeProgressBar(this);
    mProgressBarHeight = (int) (metrics.density * PROGRESS_BAR_HEIGHT);

}

From source file:com.callba.phone.widget.refreshlayout.RefreshLayout.java

/**
 * Constructor that is called when inflating SwipeRefreshLayout from XML.
 *
 * @param context/*w ww .j av a 2 s .com*/
 * @param attrs
 */
public RefreshLayout(Context context, AttributeSet attrs) {
    super(context, attrs);
    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();

    mMediumAnimationDuration = getResources().getInteger(android.R.integer.config_mediumAnimTime);

    setWillNotDraw(false);
    mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR);
    mAccelerateInterpolator = new AccelerateInterpolator(ACCELERATE_INTERPOLATION_FACTOR);

    final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS);
    setEnabled(a.getBoolean(0, true));
    a.recycle();

    final DisplayMetrics metrics = getResources().getDisplayMetrics();
    mCircleWidth = (int) (CIRCLE_DIAMETER * metrics.density);
    mCircleHeight = (int) (CIRCLE_DIAMETER * metrics.density);

    createProgressView();
    ViewCompat.setChildrenDrawingOrderEnabled(this, true);
    // the absolute offset has to take into account that the community starts at an offset
    mSpinnerFinalOffset = DEFAULT_CIRCLE_TARGET * metrics.density;
    mHeaderTotalDragDistance = mSpinnerFinalOffset;

    mProgressBar = new SwipeProgressBar(this);
    mProgressBarHeight = (int) (metrics.density * PROGRESS_BAR_HEIGHT);

}