List of usage examples for android.view.animation DecelerateInterpolator DecelerateInterpolator
public DecelerateInterpolator(float factor)
From source file:com.andrada.sitracker.ui.fragment.PublicationInfoFragment.java
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) @Override//w ww . j a v a 2 s .co m public void onScrollChanged(int deltaX, int deltaY) { final BaseActivity activity = (BaseActivity) getActivity(); if (activity == null) { return; } // Reposition the header bar -- it's normally anchored to the top of the content, // but locks to the top of the screen on scroll int scrollY = mScrollView.getScrollY(); if (!rateShowcaseShown && mRatingVisible && delayedScrollCheck) { //Check for bottom scroll //Showcase if bottom View view = mScrollView.getChildAt(mScrollView.getChildCount() - 1); int diff = (view.getBottom() - (mScrollView.getHeight() + mScrollView.getScrollY())); if (diff <= 0) { attemptToShowShowcaseForRatings(); } } newTop = Math.max(mPhotoHeightPixels, scrollY + mHeaderTopClearance); if (UIUtils.hasHoneycombMR1()) { mHeaderBox.setTranslationY(newTop); mReadPubButton.setTranslationY(newTop + mHeaderHeightPixels - mReadPubButtonHeightPixels / 2); mHeaderBackgroundBox.setPivotY(mHeaderHeightPixels); } else { ViewHelper.setTranslationY(mHeaderBox, newTop); //TODO get rid of this on next release with API 14 ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) mReadPubButton.getLayoutParams(); if (mlp.topMargin != Math.round(newTop + mHeaderHeightPixels - mReadPubButtonHeightPixels / 2)) { mlp.topMargin = Math.round(newTop + mHeaderHeightPixels - mReadPubButtonHeightPixels / 2); mReadPubButton.setLayoutParams(mlp); } ViewHelper.setPivotY(mHeaderBackgroundBox, mHeaderHeightPixels); } int gapFillDistance = (int) (mHeaderTopClearance * GAP_FILL_DISTANCE_MULTIPLIER); boolean showGapFill = !mHasPhoto || (scrollY > (mPhotoHeightPixels - gapFillDistance)); float desiredHeaderScaleY = showGapFill ? ((mHeaderHeightPixels + gapFillDistance + 1) * 1f / mHeaderHeightPixels) : 1f; if (!mHasPhoto) { if (UIUtils.hasHoneycombMR1()) { mHeaderBackgroundBox.setScaleY(desiredHeaderScaleY); } else { ViewHelper.setScaleY(mHeaderBackgroundBox, desiredHeaderScaleY); } } else if (mGapFillShown != showGapFill) { if (UIUtils.hasICS()) { mHeaderBackgroundBox.animate().scaleY(desiredHeaderScaleY) .setInterpolator(new DecelerateInterpolator(2f)).setDuration(250).start(); } else { //TODO get rid of this on next release with API 14 animate(mHeaderBackgroundBox).scaleY(desiredHeaderScaleY) .setInterpolator(new DecelerateInterpolator(2f)).setDuration(250); } } mGapFillShown = showGapFill; mHeaderShadow.setVisibility(View.VISIBLE); if (mHeaderTopClearance != 0) { // Fill the gap between status bar and header bar with color float gapFillProgress = Math.min(Math.max(UIUtils.getProgress(scrollY, mPhotoHeightPixels - mHeaderTopClearance * 2, mPhotoHeightPixels - mHeaderTopClearance), 0), 1); if (UIUtils.hasHoneycombMR1()) { mHeaderShadow.setAlpha(gapFillProgress); } else { ViewHelper.setAlpha(mHeaderShadow, gapFillProgress); } } // Move background photo (parallax effect) if (UIUtils.hasHoneycombMR1()) { mPhotoViewContainer.setTranslationY(scrollY * 0.3f); } else { //TODO get rid of this on next release with API 14 ViewHelper.setTranslationY(mPhotoViewContainer, scrollY * 0.3f); } }
From source file:com.htc.dotdesign.ToolBoxService.java
private void initAnimation() { mLeftIn = new TranslateAnimation(Animation.RELATIVE_TO_SELF, (float) -1.0, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0); mLeftIn.setDuration(mAnimationDuration); mLeftIn.setInterpolator(new DecelerateInterpolator(mAnimationFactor)); mLeftIn.setRepeatCount(0);/* w w w .j ava 2s .com*/ mLeftIn.setAnimationListener(new AnimationListener() { @Override public void onAnimationEnd(Animation arg0) { mIsToolBarOpen = true; mbIsAnimationPlaying = false; } @Override public void onAnimationRepeat(Animation arg0) { } @Override public void onAnimationStart(Animation arg0) { } }); mLeftOut = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, (float) -1.0, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0); mLeftOut.setDuration(mAnimationDuration); mLeftOut.setInterpolator(new DecelerateInterpolator(mAnimationFactor)); mLeftOut.setRepeatCount(0); mLeftOut.setAnimationListener(new AnimationListener() { @Override public void onAnimationEnd(Animation arg0) { mToolBar.setVisibility(View.GONE); mToolBarParent.setVisibility(View.INVISIBLE); mIsToolBarOpen = false; mbIsAnimationPlaying = false; } @Override public void onAnimationRepeat(Animation arg0) { } @Override public void onAnimationStart(Animation arg0) { } }); mRightIn = new TranslateAnimation(Animation.RELATIVE_TO_SELF, (float) 1.0, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0); mRightIn.setDuration(mAnimationDuration); mRightIn.setInterpolator(new DecelerateInterpolator(mAnimationFactor)); mRightIn.setRepeatCount(0); mRightIn.setAnimationListener(new AnimationListener() { @Override public void onAnimationEnd(Animation arg0) { mIsToolBarOpen = true; mbIsAnimationPlaying = false; } @Override public void onAnimationRepeat(Animation arg0) { } @Override public void onAnimationStart(Animation arg0) { } }); mRightOut = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, (float) 1.0, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0); mRightOut.setDuration(mAnimationDuration); mRightOut.setInterpolator(new DecelerateInterpolator(mAnimationFactor)); mRightOut.setRepeatCount(0); mRightOut.setAnimationListener(new AnimationListener() { @Override public void onAnimationEnd(Animation arg0) { mToolBar.setVisibility(View.GONE); mToolBarParent.setVisibility(View.INVISIBLE); mIsToolBarOpen = false; mbIsAnimationPlaying = false; } @Override public void onAnimationRepeat(Animation arg0) { } @Override public void onAnimationStart(Animation arg0) { } }); }
From source file:com.juick.android.ThreadFragment.java
private void closeNavigationMenu() { navigationMenuShown = false;/*from w w w . jav a 2s. co m*/ for (int i = 0; i < flyingItems.length; i++) { final FlyingItem item = flyingItems[i]; item.setVisibility(View.VISIBLE); item.ani = new TranslateAnimation(Animation.ABSOLUTE, 0, Animation.ABSOLUTE, -item.designedX + item.widget.getWidth() * 1.5f, Animation.ABSOLUTE, 0, Animation.ABSOLUTE, -item.designedY); item.ani.setDuration(500); item.ani.setInterpolator(new AccelerateInterpolator(1)); item.ani.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { //To change body of implemented methods use File | Settings | File Templates. } @Override public void onAnimationEnd(Animation animation) { item.setVisibility(View.GONE); item.widget.clearAnimation(); item.widget.disableReposition = false; item.widget.layout(item.originalHitRect.left, item.originalHitRect.top, item.originalHitRect.right, item.originalHitRect.bottom); if (item == flyingItems[0]) { TranslateAnimation aniIn = new TranslateAnimation(Animation.ABSOLUTE, 600, Animation.ABSOLUTE, initNavMenuTranslationX, Animation.ABSOLUTE, 0, Animation.ABSOLUTE, 0); aniIn.setInterpolator(new DecelerateInterpolator(1)); item.ani.setDuration(500); aniIn.setFillAfter(true); navMenu.startAnimation(aniIn); } } @Override public void onAnimationRepeat(Animation animation) { //To change body of implemented methods use File | Settings | File Templates. } }); item.ani.setFillAfter(true); item.widget.startAnimation(item.ani); } }
From source file:cw.kop.autobackground.sources.SourceListFragment.java
private void startEditFragment(final View view, final int position) { sourceList.setOnItemClickListener(null); sourceList.setEnabled(false);//from w w w .ja v a 2 s . c o m listAdapter.saveData(); Source dataItem = listAdapter.getItem(position); final SourceInfoFragment sourceInfoFragment = new SourceInfoFragment(); sourceInfoFragment.setImageDrawable(((ImageView) view.findViewById(R.id.source_image)).getDrawable()); Bundle arguments = new Bundle(); arguments.putInt("position", position); arguments.putString("type", dataItem.getType()); arguments.putString("title", dataItem.getTitle()); arguments.putString("data", dataItem.getData()); arguments.putInt("num", dataItem.getNum()); arguments.putBoolean("use", dataItem.isUse()); arguments.putBoolean("preview", dataItem.isPreview()); String imageFileName = dataItem.getImageFile().getAbsolutePath(); if (imageFileName != null && imageFileName.length() > 0) { arguments.putString("image", imageFileName); } else { arguments.putString("image", ""); } arguments.putBoolean("use_time", dataItem.isUseTime()); arguments.putString("time", dataItem.getTime()); sourceInfoFragment.setArguments(arguments); final RelativeLayout sourceContainer = (RelativeLayout) view.findViewById(R.id.source_container); final CardView sourceCard = (CardView) view.findViewById(R.id.source_card); final View imageOverlay = view.findViewById(R.id.source_image_overlay); final EditText sourceTitle = (EditText) view.findViewById(R.id.source_title); final ImageView deleteButton = (ImageView) view.findViewById(R.id.source_delete_button); final ImageView viewButton = (ImageView) view.findViewById(R.id.source_view_image_button); final ImageView editButton = (ImageView) view.findViewById(R.id.source_edit_button); final LinearLayout sourceExpandContainer = (LinearLayout) view.findViewById(R.id.source_expand_container); final float cardStartShadow = sourceCard.getPaddingLeft(); final float viewStartHeight = sourceContainer.getHeight(); final float viewStartY = view.getY(); final int viewStartPadding = view.getPaddingLeft(); final float textStartX = sourceTitle.getX(); final float textStartY = sourceTitle.getY(); final float textTranslationY = sourceTitle.getHeight(); /*+ TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics());*/ Animation animation = new Animation() { private boolean needsFragment = true; @Override protected void applyTransformation(float interpolatedTime, Transformation t) { if (needsFragment && interpolatedTime >= 1) { needsFragment = false; getFragmentManager().beginTransaction() .add(R.id.content_frame, sourceInfoFragment, "source_info_fragment") .addToBackStack(null).setTransition(FragmentTransaction.TRANSIT_NONE).commit(); } int newPadding = Math.round(viewStartPadding * (1 - interpolatedTime)); int newShadowPadding = (int) (cardStartShadow * (1.0f - interpolatedTime)); sourceCard.setShadowPadding(newShadowPadding, 0, newShadowPadding, 0); ((LinearLayout.LayoutParams) sourceCard.getLayoutParams()).topMargin = newShadowPadding; ((LinearLayout.LayoutParams) sourceCard.getLayoutParams()).bottomMargin = newShadowPadding; ((LinearLayout.LayoutParams) sourceCard.getLayoutParams()).leftMargin = newShadowPadding; ((LinearLayout.LayoutParams) sourceCard.getLayoutParams()).rightMargin = newShadowPadding; view.setPadding(newPadding, 0, newPadding, 0); view.setY(viewStartY - interpolatedTime * viewStartY); ViewGroup.LayoutParams params = sourceContainer.getLayoutParams(); params.height = (int) (viewStartHeight + (screenHeight - viewStartHeight) * interpolatedTime); sourceContainer.setLayoutParams(params); sourceTitle.setY(textStartY + interpolatedTime * textTranslationY); sourceTitle.setX(textStartX + viewStartPadding - newPadding); deleteButton.setAlpha(1.0f - interpolatedTime); viewButton.setAlpha(1.0f - interpolatedTime); editButton.setAlpha(1.0f - interpolatedTime); sourceExpandContainer.setAlpha(1.0f - interpolatedTime); } @Override public boolean willChangeBounds() { return true; } }; animation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { if (needsListReset) { Parcelable state = sourceList.onSaveInstanceState(); sourceList.setAdapter(null); sourceList.setAdapter(listAdapter); sourceList.onRestoreInstanceState(state); sourceList.setOnItemClickListener(SourceListFragment.this); sourceList.setEnabled(true); needsListReset = false; } } @Override public void onAnimationRepeat(Animation animation) { } }); ValueAnimator cardColorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), AppSettings.getDialogColor(appContext), getResources().getColor(AppSettings.getBackgroundColorResource())); cardColorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { sourceContainer.setBackgroundColor((Integer) animation.getAnimatedValue()); } }); ValueAnimator titleColorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), sourceTitle.getCurrentTextColor(), getResources().getColor(R.color.BLUE_OPAQUE)); titleColorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { sourceTitle.setTextColor((Integer) animation.getAnimatedValue()); } }); ValueAnimator titleShadowAlphaAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), AppSettings.getColorFilterInt(appContext), getResources().getColor(android.R.color.transparent)); titleShadowAlphaAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { sourceTitle.setShadowLayer(4, 0, 0, (Integer) animation.getAnimatedValue()); } }); ValueAnimator imageOverlayAlphaAnimation = ValueAnimator.ofFloat(imageOverlay.getAlpha(), 0f); imageOverlayAlphaAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { imageOverlay.setAlpha((Float) animation.getAnimatedValue()); } }); int transitionTime = INFO_ANIMATION_TIME; DecelerateInterpolator decelerateInterpolator = new DecelerateInterpolator(1.5f); animation.setDuration(transitionTime); cardColorAnimation.setDuration(transitionTime); titleColorAnimation.setDuration(transitionTime); titleShadowAlphaAnimation.setDuration(transitionTime); animation.setInterpolator(decelerateInterpolator); cardColorAnimation.setInterpolator(decelerateInterpolator); titleColorAnimation.setInterpolator(decelerateInterpolator); titleShadowAlphaAnimation.setInterpolator(decelerateInterpolator); if (imageOverlay.getAlpha() > 0) { imageOverlayAlphaAnimation.start(); } handler.postDelayed(new Runnable() { @Override public void run() { if (needsListReset) { Parcelable state = sourceList.onSaveInstanceState(); sourceList.setAdapter(null); sourceList.setAdapter(listAdapter); sourceList.onRestoreInstanceState(state); sourceList.setOnItemClickListener(SourceListFragment.this); sourceList.setEnabled(true); needsListReset = false; } } }, (long) (transitionTime * 1.1f)); needsListReset = true; view.startAnimation(animation); cardColorAnimation.start(); titleColorAnimation.start(); titleShadowAlphaAnimation.start(); }
From source file:com.juick.android.ThreadFragment.java
private void openNavigationMenu(float currentTranslation) { try {// w ww. j av a 2s .c o m navigationMenuShown = true; for (final FlyingItem item : flyingItems) { item.setVisibility(View.VISIBLE); item.ani = new TranslateAnimation(Animation.ABSOLUTE, 300, Animation.ABSOLUTE, item.designedX, Animation.ABSOLUTE, 0, Animation.ABSOLUTE, item.designedY); item.ani.setInterpolator(new OvershootInterpolator(2)); item.ani.setDuration(500); item.ani.setFillAfter(true); item.ani.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { //To change body of implemented methods use File | Settings | File Templates. } @Override public void onAnimationEnd(Animation animation) { // this code is very ugly because it's all android 2.3 animations. item.widget.getHitRect(item.originalHitRect); item.widget.clearAnimation(); item.widget.layout(item.originalHitRect.left + (int) item.widget.initialTranslationX, item.originalHitRect.top + (int) item.widget.initialTranslationY, item.originalHitRect.right + (int) item.widget.initialTranslationX, item.originalHitRect.bottom + (int) item.widget.initialTranslationY); item.widget.disableReposition = true; } @Override public void onAnimationRepeat(Animation animation) { //To change body of implemented methods use File | Settings | File Templates. } }); item.widget.startAnimation(item.ani); } TranslateAnimation aniOut = new TranslateAnimation(Animation.ABSOLUTE, currentTranslation, Animation.ABSOLUTE, -1.2f * getActivity().getWindowManager().getDefaultDisplay().getWidth(), Animation.ABSOLUTE, 0, Animation.ABSOLUTE, 0); aniOut.setInterpolator(new DecelerateInterpolator(1)); aniOut.setDuration(700); aniOut.setFillAfter(true); navMenu.startAnimation(aniOut); getListView().performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); } catch (Throwable e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } }
From source file:com.android.leanlauncher.Workspace.java
Animator getChangeStateAnimation(final State state, boolean animated, int delay, ArrayList<View> layerViews) { if (mState == state) { return null; }/*w ww .j av a 2 s. co m*/ AnimatorSet anim = animated ? LauncherAnimUtils.createAnimatorSet() : null; // We only want a single instance of a workspace animation to be running at once, so // we cancel any incomplete transition. if (mStateAnimator != null) { mStateAnimator.cancel(); } mStateAnimator = anim; final State oldState = mState; final boolean oldStateIsNormal = (oldState == State.NORMAL); final boolean oldStateIsOverview = (oldState == State.OVERVIEW); setState(state); final boolean stateIsNormal = (state == State.NORMAL); final boolean stateIsSpringLoaded = (state == State.SPRING_LOADED); final boolean stateIsNormalHidden = (state == State.NORMAL_HIDDEN); final boolean stateIsOverviewHidden = (state == State.OVERVIEW_HIDDEN); final boolean stateIsOverview = (state == State.OVERVIEW); float finalBackgroundAlpha = (stateIsSpringLoaded || stateIsOverview) ? 1.0f : 0f; float finalOverviewPanelAlpha = stateIsOverview ? 1f : 0f; float finalWorkspaceTranslationY = stateIsOverview || stateIsOverviewHidden ? getOverviewModeTranslationY() : 0; boolean workspaceToAllApps = (oldStateIsNormal && stateIsNormalHidden); boolean overviewToAllApps = (oldStateIsOverview && stateIsOverviewHidden); boolean allAppsToWorkspace = (stateIsNormalHidden && stateIsNormal); boolean workspaceToOverview = (oldStateIsNormal && stateIsOverview); boolean overviewToWorkspace = (oldStateIsOverview && stateIsNormal); mNewScale = 1.0f; if (state != State.NORMAL) { if (stateIsSpringLoaded) { mNewScale = mSpringLoadedShrinkFactor; } else if (stateIsOverview || stateIsOverviewHidden) { mNewScale = mOverviewModeShrinkFactor; } } final int duration; if (workspaceToAllApps || overviewToAllApps) { duration = HIDE_WORKSPACE_DURATION; //getResources().getInteger(R.integer.config_workspaceUnshrinkTime); } else if (workspaceToOverview || overviewToWorkspace) { duration = getResources().getInteger(R.integer.config_overviewTransitionTime); } else { duration = getResources().getInteger(R.integer.config_appsCustomizeWorkspaceShrinkTime); } final CellLayout cl = mWorkspace; float initialAlpha = cl.getShortcutsAndWidgets().getAlpha(); float finalAlpha; if (stateIsNormalHidden || stateIsOverviewHidden) { finalAlpha = 0f; } else { finalAlpha = 1f; } // If we are animating to/from the small state, then hide the side pages and fade the // current page in if (!mIsSwitchingState) { if (workspaceToAllApps || allAppsToWorkspace) { if (allAppsToWorkspace) { initialAlpha = 0f; } cl.setShortcutAndWidgetAlpha(initialAlpha); } } float oldAlpha = initialAlpha; float newAlpha = finalAlpha; if (animated) { mOldBackgroundAlpha = cl.getBackgroundAlpha(); mNewBackgroundAlpha = finalBackgroundAlpha; } else { cl.setBackgroundAlpha(finalBackgroundAlpha); cl.setShortcutAndWidgetAlpha(finalAlpha); } final View overviewPanel = mLauncher.getOverviewPanel(); if (animated) { LauncherViewPropertyAnimator scale = new LauncherViewPropertyAnimator(this); scale.scaleX(mNewScale).scaleY(mNewScale).translationY(finalWorkspaceTranslationY).setDuration(duration) .setInterpolator(mZoomInInterpolator); anim.play(scale); float currentAlpha = cl.getShortcutsAndWidgets().getAlpha(); if (oldAlpha == 0 && newAlpha == 0) { cl.setBackgroundAlpha(mNewBackgroundAlpha); cl.setShortcutAndWidgetAlpha(newAlpha); } else { if (layerViews != null) { layerViews.add(cl); } if (oldAlpha != newAlpha || currentAlpha != newAlpha) { LauncherViewPropertyAnimator alphaAnim = new LauncherViewPropertyAnimator( cl.getShortcutsAndWidgets()); alphaAnim.alpha(newAlpha).setDuration(duration).setInterpolator(mZoomInInterpolator); anim.play(alphaAnim); } if (mOldBackgroundAlpha != 0 || mNewBackgroundAlpha != 0) { ValueAnimator bgAnim = LauncherAnimUtils.ofFloat(cl, 0f, 1f); bgAnim.setInterpolator(mZoomInInterpolator); bgAnim.setDuration(duration); bgAnim.addUpdateListener(new LauncherAnimatorUpdateListener() { public void onAnimationUpdate(float a, float b) { cl.setBackgroundAlpha(a * mOldBackgroundAlpha + b * mNewBackgroundAlpha); } }); anim.play(bgAnim); } } Animator overviewPanelAlpha = new LauncherViewPropertyAnimator(overviewPanel) .alpha(finalOverviewPanelAlpha).withLayer(); overviewPanelAlpha.addListener(new AlphaUpdateListener(overviewPanel)); // For animation optimations, we may need to provide the Launcher transition // with a set of views on which to force build layers in certain scenarios. overviewPanel.setLayerType(View.LAYER_TYPE_HARDWARE, null); if (layerViews != null) { layerViews.add(overviewPanel); } if (workspaceToOverview) { overviewPanelAlpha.setInterpolator(null); } else if (overviewToWorkspace) { overviewPanelAlpha.setInterpolator(new DecelerateInterpolator(2)); } overviewPanelAlpha.setDuration(duration); anim.play(overviewPanelAlpha); anim.setStartDelay(delay); anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mStateAnimator = null; } }); } else { overviewPanel.setAlpha(finalOverviewPanelAlpha); AlphaUpdateListener.updateVisibility(overviewPanel); setScaleX(mNewScale); setScaleY(mNewScale); setTranslationY(finalWorkspaceTranslationY); } if (stateIsNormal) { animateBackgroundGradient(0f, animated); } else { animateBackgroundGradient(getResources().getInteger(R.integer.config_workspaceScrimAlpha) / 100f, animated); } return anim; }
From source file:com.android.launcher2.Workspace.java
private void animateBackgroundGradient(float finalAlpha, boolean animated) { if (mBackground == null) return;/*from w w w .j a v a 2s . co m*/ if (mBackgroundFadeInAnimation != null) { mBackgroundFadeInAnimation.cancel(); mBackgroundFadeInAnimation = null; } if (mBackgroundFadeOutAnimation != null) { mBackgroundFadeOutAnimation.cancel(); mBackgroundFadeOutAnimation = null; } float startAlpha = getBackgroundAlpha(); if (finalAlpha != startAlpha) { if (animated) { mBackgroundFadeOutAnimation = LauncherAnimUtils.ofFloat(startAlpha, finalAlpha); mBackgroundFadeOutAnimation.addUpdateListener(new AnimatorUpdateListener() { public void onAnimationUpdate(ValueAnimator animation) { setBackgroundAlpha(((Float) animation.getAnimatedValue()).floatValue()); } }); mBackgroundFadeOutAnimation.setInterpolator(new DecelerateInterpolator(1.5f)); mBackgroundFadeOutAnimation.setDuration(BACKGROUND_FADE_OUT_DURATION); mBackgroundFadeOutAnimation.start(); } else { setBackgroundAlpha(finalAlpha); } } }
From source file:cc.flydev.launcher.Workspace.java
private void animateBackgroundGradient(float finalAlpha, boolean animated) { if (mBackground == null) return;/* w ww.j a v a 2 s .c o m*/ if (mBackgroundFadeInAnimation != null) { mBackgroundFadeInAnimation.cancel(); mBackgroundFadeInAnimation = null; } if (mBackgroundFadeOutAnimation != null) { mBackgroundFadeOutAnimation.cancel(); mBackgroundFadeOutAnimation = null; } float startAlpha = getBackgroundAlpha(); if (finalAlpha != startAlpha) { if (animated) { mBackgroundFadeOutAnimation = LauncherAnimUtils.ofFloat(this, startAlpha, finalAlpha); mBackgroundFadeOutAnimation.addUpdateListener(new AnimatorUpdateListener() { public void onAnimationUpdate(ValueAnimator animation) { setBackgroundAlpha(((Float) animation.getAnimatedValue()).floatValue()); } }); mBackgroundFadeOutAnimation.setInterpolator(new DecelerateInterpolator(1.5f)); mBackgroundFadeOutAnimation.setDuration(BACKGROUND_FADE_OUT_DURATION); mBackgroundFadeOutAnimation.start(); } else { setBackgroundAlpha(finalAlpha); } } }
From source file:com.harry.refresh.SwipyRefreshLayout.java
/** * Constructor that is called when inflating SwipeRefreshLayout from XML. *//from ww w . java2s . c o m * @param context * @param attrs */ public SwipyRefreshLayout(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 TypedArray a2 = context.obtainStyledAttributes(attrs, R.styleable.SwipyRefreshLayout); SwipeRefreshLayoutDirection direction = SwipeRefreshLayoutDirection .getFromInt(a2.getInt(R.styleable.SwipyRefreshLayout_direction, 0)); if (direction != SwipeRefreshLayoutDirection.BOTH) { mDirection = direction; mBothDirection = false; } else { mDirection = SwipeRefreshLayoutDirection.TOP; mBothDirection = true; } a2.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; }
From source file:com.amaze.carbonfilemanager.activities.MainActivity.java
public void openZip(String path) { findViewById(R.id.lin).animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)).start(); FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); fragmentTransaction.setCustomAnimations(R.anim.slide_in_top, R.anim.slide_in_bottom); Fragment zipFragment = new ZipViewer(); Bundle bundle = new Bundle(); bundle.putString("path", path); zipFragment.setArguments(bundle);// w w w .j a v a2 s . c om fragmentTransaction.add(R.id.content_frame, zipFragment); fragmentTransaction.commitAllowingStateLoss(); }