List of usage examples for android.view.animation DecelerateInterpolator DecelerateInterpolator
public DecelerateInterpolator(float factor)
From source file:com.cyj.ui.component.listview.CusSwipeRefreshLayout.java
public CusSwipeRefreshLayout(Context context, AttributeSet attrs) { super(context, attrs); mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); mMediumAnimationDuration = getResources().getInteger(android.R.integer.config_mediumAnimTime); setWillNotDraw(false);//from w w w . j a v a 2 s .co m mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR); final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS); setEnabled(a.getBoolean(0, true)); a.recycle(); }
From source file:com.zandbee.floatingtitlebar.FloatingTitleBarActivity.java
@Override public void onScrollChanged(int deltaX, int deltaY) { final int scrollY = scrollView.getScrollY(); /** title is going up and has not yet collided with a toolbar */ if (getLocationYonScreen(bodyLayout) <= (toolbarHeight + titleViewHeight)) { titleLayout.setTranslationY(scrollY); quasiFab.setTranslationY(scrollY + toolbarHeight + titleViewHeight - quasiFabCenterHeight); // TODO try without delta if (!titleInUpperPosition //&& deltaY > 0 ) {//from w ww. j a va2 s .c om titleInUpperPosition = true; final ObjectAnimator animPd = ObjectAnimator.ofFloat(titleBackDrawable, "progress", titleBackDrawable.max - titleViewHeight, 0f); animPd.setInterpolator(new DecelerateInterpolator(2f)); animPd.setDuration(200).start(); } } /** title is going down */ if (titleInUpperPosition && getLocationYonScreen(titleView) > toolbarHeight // + getLocationYonScreen(toolbar) && deltaY < 0) { titleInUpperPosition = false; final ObjectAnimator animPd = ObjectAnimator.ofFloat(titleBackDrawable, "progress", 0f, titleBackDrawable.max - titleViewHeight); animPd.setInterpolator(new AccelerateDecelerateInterpolator()); animPd.setDuration(250).start(); } imageView.setTranslationY(scrollY * 0.5f); }
From source file:com.aviary.android.feather.sdk.widget.AviaryWorkspace.java
private void initWorkspace(Context context, AttributeSet attrs, int defStyle) { Theme theme = context.getTheme();//from w ww.j a va 2 s.co m TypedArray a = theme.obtainStyledAttributes(attrs, R.styleable.AviaryWorkspace, defStyle, 0); mDefaultScreen = a.getInt(R.styleable.AviaryWorkspace_aviary_defaultScreen, 0); int overscrollMode = a.getInt(R.styleable.AviaryWorkspace_aviary_overscroll, 0); a.recycle(); setHapticFeedbackEnabled(false); mScrollInterpolator = new DecelerateInterpolator(1.0f); mScroller = new Scroller(context, mScrollInterpolator); mPreviousScreen = INVALID_SCREEN; final ViewConfiguration configuration = ViewConfiguration.get(getContext()); mTouchSlop = configuration.getScaledTouchSlop(); mMaximumVelocity = configuration.getScaledMaximumFlingVelocity(); mPaddingTop = getPaddingTop(); mPaddingBottom = getPaddingBottom(); mPaddingLeft = getPaddingLeft(); mPaddingRight = getPaddingRight(); setOverScroll(overscrollMode); }
From source file:org.duncavage.swipetorefresh.widget.SwipeRefreshLayout.java
/** * Constructor that is called when inflating SwipeRefreshLayout from XML. * @param context//from w ww . j a v a 2s. c o m * @param attrs */ public SwipeRefreshLayout(Context context, AttributeSet attrs) { super(context, attrs); mActionBarSwipeIndicator = new ActionBarSwipeIndicator(context); mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); mMediumAnimationDuration = getResources().getInteger(android.R.integer.config_mediumAnimTime); setWillNotDraw(false); mProgressBar = new SwipeProgressBar(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.nikhilnayak.games.octoshootar.ui.fragments.GameModeFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final Resources res = getResources(); final View v = inflater.inflate(R.layout.fragment_details, container, false); if (getArguments().containsKey(EXTRA_GAME_MODE)) { mGameMode = getArguments().getParcelable(EXTRA_GAME_MODE); }/* ww w. ja va 2s. c o m*/ String[] ranks = res.getStringArray(R.array.ranks_array_full); String[] grades = res.getStringArray(R.array.ranks_array_letter); final TextView rankTitle = (TextView) v.findViewById(R.id.details_rank); final TextView rankLetter = (TextView) v.findViewById(R.id.details_rank_letter); final ProgressBar progression = (ProgressBar) v.findViewById(R.id.details_progess_bar); final TextView progressText = (TextView) v.findViewById(R.id.details_progression); final TextView title = (TextView) v.findViewById(R.id.details_title); final int rank = mPlayerProfile.getRankByGameMode(mGameMode); final int progress = 100 - (int) ((((float) (ranks.length - 1) - rank) / (float) (ranks.length - 1)) * 100); final TextView admiral = (TextView) v.findViewById(R.id.admiral_description); final TextView sergeant = (TextView) v.findViewById(R.id.sergeant_description); final TextView corporal = (TextView) v.findViewById(R.id.corporal_description); final TextView soldier = (TextView) v.findViewById(R.id.soldier_description); final TextView deserter = (TextView) v.findViewById(R.id.deserter_description); final TextView longDescription = (TextView) v.findViewById(R.id.details_description); final int descriptionId = mGameMode.getLongDescription(); rankTitle.setText(ranks[rank]); rankLetter.setText(grades[rank]); progression.setProgress(progress); progressText.setText(String.valueOf(progress) + " %"); title.setText(mGameMode.getTitle()); admiral.setText(mGameMode.getAdmiralRankRule(res)); sergeant.setText(mGameMode.getSergeantRankRule(res)); corporal.setText(mGameMode.getCorporalRankRule(res)); soldier.setText(mGameMode.getSoldierRankRule(res)); deserter.setText(mGameMode.getDeserterRankRule(res)); if (descriptionId != -1) longDescription.setText(descriptionId); if (mListener != null) { //show button play final View start = v.findViewById(R.id.details_play); start.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mListener.onPlayRequest(mGameMode); } }); start.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { start.getViewTreeObserver().removeOnPreDrawListener(this); int offset = v.getHeight() - start.getTop(); start.setTranslationY(offset); start.setVisibility(View.VISIBLE); start.animate().translationY(0) .setDuration(getResources().getInteger(R.integer.animation_duration_short)) .setInterpolator(new DecelerateInterpolator(2)).start(); return false; } }); v.findViewById(R.id.fragment_detail_important_title).setVisibility(View.VISIBLE); v.findViewById(R.id.fragment_detail_important_content).setVisibility(View.VISIBLE); } return v; }
From source file:com.hakerjack.experiments.CustomSwipeRefreshLayout.java
/** * Constructor that is called when inflating DoublePlaySwipeRefreshLayout from XML. * * @param context//from w w w . j a v a 2 s . c o m * @param attrs */ public CustomSwipeRefreshLayout(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); final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS); setEnabled(a.getBoolean(0, true)); a.recycle(); final DisplayMetrics metrics = getResources().getDisplayMetrics(); mSpinnerWidth = (int) (SPINNER_DIAMETER * metrics.density); mSpinnerHeight = (int) (SPINNER_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_SPINNER_TARGET * metrics.density; mTotalDragDistance = mSpinnerFinalOffset; mHideSpinnerDistance = HIDE_SPINNER_DISTANCE * metrics.density; }
From source file:com.sohu.xzd.widget.SwipeRefresh.java
/** * Constructor that is called when inflating SwipeRefreshLayout from XML. *//*w w w .j a va 2 s .c om*/ public SwipeRefresh(Context context, AttributeSet attrs) { super(context, attrs); mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); setWillNotDraw(false); mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR); final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS); setEnabled(a.getBoolean(0, true)); a.recycle(); final DisplayMetrics metrics = getResources().getDisplayMetrics(); 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; mTotalDragDistance = mSpinnerFinalOffset; }
From source file:com.lastsoft.plog.PlaysFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View rootView = inflater.inflate(R.layout.fragment_plays, container, false); rootView.setTag(TAG);/*from ww w . jav a 2 s . c o m*/ // BEGIN_INCLUDE(initializeRecyclerView) mRecyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerView); mRecyclerView.setBackgroundColor(getResources().getColor(R.color.cardview_initial_background)); RecyclerFastScroller fastScroller = (RecyclerFastScroller) rootView.findViewById(R.id.fastscroller); // Connect the recycler to the scroller (to let the scroller scroll the list) fastScroller.attachRecyclerView(mRecyclerView); addPlay = (FloatingActionButton) rootView.findViewById(R.id.add_play); if (fromDrawer && playListType != 2) { addPlay.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int viewXY[] = new int[2]; v.getLocationOnScreen(viewXY); /*if (mListener != null) { mListener.onFragmentInteraction("add_play", viewXY[0], viewXY[1]); }*/ ((MainActivity) mActivity).usedFAB = true; ((MainActivity) mActivity).openGames("", true, 0, getString(R.string.title_games), MainActivity.CurrentYear); } }); } else { addPlay.setVisibility(View.GONE); } fabMargin = getResources().getDimensionPixelSize(R.dimen.fab_margin); mRecyclerView.addOnScrollListener(new MyRecyclerScroll() { @Override public void show() { addPlay.animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)).start(); } @Override public void hide() { addPlay.animate().translationY(addPlay.getHeight() + fabMargin) .setInterpolator(new AccelerateInterpolator(2)).start(); } }); // Connect the scroller to the recycler (to let the recycler scroll the scroller's handle) //mRecyclerView.addOnScrollListener(fastScroller.getOnScrollListener()); // 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 PlayAdapter(mActivity, this); /*if (((MainActivity)mActivity).mPlayAdapter != null) { mAdapter = ((MainActivity) mActivity).mPlayAdapter; }else{*/ mAdapter = ((MainActivity) mActivity).initPlayAdapter(mSearchQuery, fromDrawer, playListType, currentYear); //} // Set CustomAdapter as the adapter for RecyclerView. mRecyclerView.setAdapter(mAdapter); // END_INCLUDE(initializeRecyclerView) if (mSearch != null) { mSearch.setHint( getString(R.string.filter) + mAdapter.getItemCount() + getString(R.string.filter_plays)); } /*boolean pauseOnScroll = true; // or true boolean pauseOnFling = true; // or false NewPauseOnScrollListener listener = new NewPauseOnScrollListener(ImageLoader.getInstance(), pauseOnScroll, pauseOnFling); mRecyclerView.addOnScrollListener(listener);*/ if (!fromDrawer) { RelativeLayout playsLayout = (RelativeLayout) rootView.findViewById(R.id.playsLayout); 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) { PlaysFragment myFragC1 = (PlaysFragment) getFragmentManager().findFragmentByTag("plays"); FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.remove(myFragC1); transaction.commitAllowingStateLoss(); getFragmentManager().executePendingTransactions(); mActivity.onBackPressed(); } @Override public void onDragStateChanged(int i) { } }); CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) playsLayout.getLayoutParams(); params.setBehavior(behavior); } if (mSearch != null) { mSearch.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) { // When user changed the Text if (mActivity != null) { mSearchQuery = cs.toString(); //initDataset(); //mAdapter = new GameAdapter(PlaysFragment.this, mActivity,mSearchQuery); mAdapter = ((MainActivity) mActivity).initPlayAdapter(mSearchQuery, fromDrawer, playListType, currentYear); // Set CustomAdapter as the adapter for RecyclerView. mRecyclerView.setAdapter(mAdapter); } } @Override public void afterTextChanged(Editable editable) { } @Override public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } }); mCancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (!mSearch.getText().toString().equals("")) { mSearchQuery = ""; ((MainActivity) mActivity).initPlayAdapter(mSearchQuery, fromDrawer, playListType, currentYear); mSearch.setText(mSearchQuery); //mActivity.onBackPressed(); } InputMethodManager inputManager = (InputMethodManager) mActivity .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(mActivity.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); mSearch.clearFocus(); mRecyclerView.requestFocus(); refreshDataset(); } }); } return rootView; }
From source file:ugia.io.androidbeautytreatment.view.NoisySwipeRefreshLayout.java
/** * Constructor that is called when inflating SwipeRefreshLayout from XML. * * @param context//from w ww .j av a 2 s .c o m * @param attrs */ public NoisySwipeRefreshLayout(Context context, AttributeSet attrs) { super(context, attrs); mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); mMediumAnimationDuration = getResources().getInteger(android.R.integer.config_mediumAnimTime); setWillNotDraw(false); final DisplayMetrics metrics = getResources().getDisplayMetrics(); 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 TypedArray va = context.obtainStyledAttributes(attrs, R.styleable.SuperSwipeRefreshLayout); mProgressBarOffsetTop = a.getDimensionPixelSize(R.styleable.SuperSwipeRefreshLayout_topOffset, 0); mProgressBarHeight = a.getDimensionPixelSize(R.styleable.SuperSwipeRefreshLayout_progressBarHeight, (int) (metrics.density * PROGRESS_BAR_HEIGHT)); va.recycle(); }
From source file:com.aiga.events.android.views.NoScrollSwipeRefreshLayout.java
/** * Constructor that is called when inflating SwipeRefreshLayout from XML. * /*w w w . ja v a 2s. co m*/ * @param context * @param attrs */ public NoScrollSwipeRefreshLayout(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); 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(); }