List of usage examples for android.view.animation TranslateAnimation setDuration
public void setDuration(long durationMillis)
From source file:com.watasan.infospider.fragment.PrimitiveFragment.java
/** SCRIPT ACTION AREA --------------------------------------------------> */ public void testAnimation(float destX, float destY) { this.mDestX = Factory.getAdjustedX(destX); this.mDestY = Factory.getAdjustedY(destY); // SELECT LAYER FrameLayout relate = (FrameLayout) mRootView.findViewById(R.id.FLBackLayer); // ScrollView relate = (ScrollView)mRootView.findViewById(R.id.content); // relate.setVisibility(View.VISIBLE); AnimationSet set = new AnimationSet(true); set.setAnimationListener(this); TranslateAnimation translate; float toX = this.mDestX; float fromX = this.mSrcX; float toY = this.mDestY; float fromY = this.mSrcY; translate = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, fromX, Animation.RELATIVE_TO_PARENT, toX, Animation.RELATIVE_TO_PARENT, fromY, Animation.RELATIVE_TO_PARENT, toY); translate.setDuration(Constants.Animation.IPF_START); translate.setInterpolator(new AccelerateInterpolator()); set.addAnimation(translate);//w ww . j ava 2s. c o m set.setFillBefore(true); // set.setFillBefore(false); // set.setFillAfter(false); set.setFillAfter(true); relate.startAnimation(set); }
From source file:com.aniruddhc.acemusic.player.BrowserSubGridActivity.BrowserSubGridActivity.java
/** * Slides away the GridView.//from w ww .j a v a 2s . co m */ private void slideAwayGridView() { android.view.animation.TranslateAnimation animation = new android.view.animation.TranslateAnimation( Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 2.0f); animation.setDuration(400); animation.setInterpolator(new AccelerateInterpolator(2.0f)); animation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationEnd(Animation arg0) { mGridView.setVisibility(View.INVISIBLE); BrowserSubGridActivity.super.onBackPressed(); } @Override public void onAnimationRepeat(Animation arg0) { // TODO Auto-generated method stub } @Override public void onAnimationStart(Animation arg0) { } }); mGridView.startAnimation(animation); }
From source file:com.github.shareme.gwsmaterialuikit.library.mscrollbar.MaterialScrollBar.java
private void generalSetup() { recyclerView.setVerticalScrollBarEnabled(false); // disable any existing scrollbars recyclerView.addOnScrollListener(new scrollListener()); // lets us read when the recyclerView scrolls setTouchIntercept(); // catches touches on the bar identifySwipeRefreshParents();/*from w w w . j ava 2s . com*/ //Hides the view TranslateAnimation anim = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_SELF, getHideRatio(), Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f); anim.setDuration(0); anim.setFillAfter(true); hidden = true; startAnimation(anim); }
From source file:com.github.shareme.gwsmaterialuikit.library.mscrollbar.MaterialScrollBar.java
/** * Animates the bar into view//from w w w . j a v a 2s .co m */ void fadeIn() { if (hidden && getHide() && !hiddenByUser) { hidden = false; TranslateAnimation anim = new TranslateAnimation(Animation.RELATIVE_TO_SELF, getHideRatio(), Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f); anim.setDuration(150); anim.setFillAfter(true); startAnimation(anim); handle.collapseHandle(); } }
From source file:com.github.shareme.gwsmaterialuikit.library.mscrollbar.MaterialScrollBar.java
/** * Animates the bar out of view/*ww w .j av a 2s.co m*/ */ void fadeOut() { if (!hidden) { TranslateAnimation anim = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_SELF, getHideRatio(), Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f); anim.setDuration(150); anim.setFillAfter(true); hidden = true; startAnimation(anim); postDelayed(new Runnable() { @Override public void run() { handle.expandHandle(); } }, anim.getDuration() / 3); } }
From source file:com.aniruddhc.acemusic.player.FoldersFragment.FilesFoldersFragment.java
/** * Slides in the ListView./*from ww w . j a v a2 s . co m*/ */ private void slideUpListView() { getDir(rootDir, null); TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 2.0f, Animation.RELATIVE_TO_SELF, 0.0f); animation.setDuration(600); animation.setInterpolator(new AccelerateDecelerateInterpolator()); animation.setAnimationListener(new AnimationListener() { @Override public void onAnimationEnd(Animation arg0) { } @Override public void onAnimationRepeat(Animation arg0) { // TODO Auto-generated method stub } @Override public void onAnimationStart(Animation arg0) { listView.setVisibility(View.VISIBLE); } }); listView.startAnimation(animation); }
From source file:com.linkbubble.ui.BubbleFlowView.java
public void add(View view, boolean insertNextToCenterItem) { //view.setBackgroundColor(mViews.size() % 2 == 0 ? 0xff660066 : 0xff666600); view.setOnClickListener(mViewOnClickListener); view.setOnTouchListener(mViewOnTouchListener); int centerIndex = getCenterIndex(); int insertAtIndex = insertNextToCenterItem ? centerIndex + 1 : mViews.size(); if (view.getParent() != null) { ((ViewGroup) view.getParent()).removeView(view); }/*from w w w . j ava 2 s. co m*/ FrameLayout.LayoutParams lp = new LayoutParams(mItemWidth, mItemHeight, Gravity.TOP | Gravity.LEFT); lp.leftMargin = mEdgeMargin + insertAtIndex * mItemWidth; mContent.addView(view, lp); mContent.invalidate(); if (insertNextToCenterItem) { mViews.add(centerIndex + 1, view); } else { mViews.add(view); } updatePositions(); updateScales(getScrollX()); if (insertNextToCenterItem) { TranslateAnimation slideOnAnim = new TranslateAnimation(0, 0, -mItemHeight, 0); slideOnAnim.setDuration(Constant.BUBBLE_FLOW_ANIM_TIME); slideOnAnim.setFillAfter(true); view.startAnimation(slideOnAnim); for (int i = centerIndex + 2; i < mViews.size(); i++) { View viewToShift = mViews.get(i); TranslateAnimation slideRightAnim = new TranslateAnimation(-mItemWidth, 0, 0, 0); slideRightAnim.setDuration(Constant.BUBBLE_FLOW_ANIM_TIME); slideRightAnim.setFillAfter(true); viewToShift.startAnimation(slideRightAnim); } } ViewGroup.LayoutParams contentLP = mContent.getLayoutParams(); contentLP.width = (mViews.size() * mItemWidth) + mItemWidth + (2 * mEdgeMargin); mContent.setLayoutParams(contentLP); }
From source file:com.linkbubble.ui.BubbleFlowView.java
public boolean expand(long time, final AnimationEventListener animationEventListener) { CrashTracking.log("BubbleFlowView.expand(" + time + "), mIsExpanded:" + mIsExpanded); if (mIsExpanded) { return false; }/*from w w w. j av a2 s. c om*/ mDoingCollapse = false; mStillTouchFrameCount = -1; if (DEBUG) { //Log.d(TAG, "[longpress] expand(): mStillTouchFrameCount=" + mStillTouchFrameCount); } int size = mViews.size(); int centerIndex = getCenterIndex(); if (centerIndex == -1) { // fixes #343 return false; } View centerView = mViews.get(centerIndex); boolean addedAnimationListener = false; for (int i = 0; i < size; i++) { View view = mViews.get(i); if (centerView != view) { int xOffset = (int) (centerView.getX() - ((i * mItemWidth) + mEdgeMargin)); TranslateAnimation anim = new TranslateAnimation(xOffset, 0, 0, 0); anim.setDuration(time); anim.setFillAfter(true); if (addedAnimationListener == false) { anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { if (animationEventListener != null) { animationEventListener.onAnimationEnd(BubbleFlowView.this); } } @Override public void onAnimationRepeat(Animation animation) { } }); addedAnimationListener = true; } view.startAnimation(anim); } } if (centerIndex == 0 && mViews.size() == 1) { if (animationEventListener != null) { animationEventListener.onAnimationEnd(this); } } bringTabViewToFront(centerView); mIsExpanded = true; return true; }
From source file:com.linkbubble.ui.BubbleFlowView.java
protected void remove(final int index, boolean animateOff, boolean removeFromList, final OnRemovedListener onRemovedListener) { if (index < 0 || index >= mViews.size()) { return;// w ww. jav a 2s. c o m } final View view = mViews.get(index); if (animateOff) { if (removeFromList == false) { throw new RuntimeException("removeFromList must be true if animating off"); } TranslateAnimation slideOffAnim = new TranslateAnimation(0, 0, 0, -mItemHeight); slideOffAnim.setDuration(Constant.BUBBLE_FLOW_ANIM_TIME); slideOffAnim.setFillAfter(true); slideOffAnim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { mContent.removeView(view); // Cancel the current animation on the views so the offset no longer applies for (int i = 0; i < mViews.size(); i++) { View view = mViews.get(i); Animation viewAnimation = view.getAnimation(); if (viewAnimation != null) { viewAnimation.cancel(); view.setAnimation(null); } } updatePositions(); updateScales(getScrollX()); mSlideOffAnimationPlaying = false; if (onRemovedListener != null) { onRemovedListener.onRemoved(view); } } @Override public void onAnimationRepeat(Animation animation) { } }); invalidate(); // This fixes #284 - it's a hack, but it will do for now. view.startAnimation(slideOffAnim); mSlideOffAnimationPlaying = true; mViews.remove(view); int viewsSize = mViews.size(); if (index < viewsSize) { for (int i = index; i < viewsSize; i++) { final View viewToShift = mViews.get(i); TranslateAnimationEx slideAnim = new TranslateAnimationEx(0, -mItemWidth, 0, 0, new TranslateAnimationEx.TransformationListener() { @Override public void onApplyTransform(float interpolatedTime, Transformation t, float dx, float dy) { float centerX = getScrollX() + (mWidth / 2) - (mItemWidth / 2); updateScaleForView(viewToShift, centerX, viewToShift.getX() + dx); } }); slideAnim.setDuration(Constant.BUBBLE_FLOW_ANIM_TIME); slideAnim.setFillAfter(true); viewToShift.startAnimation(slideAnim); } } else if (viewsSize > 0) { for (int i = 0; i < index; i++) { final View viewToShift = mViews.get(i); TranslateAnimationEx slideAnim = new TranslateAnimationEx(0, mItemWidth, 0, 0, new TranslateAnimationEx.TransformationListener() { @Override public void onApplyTransform(float interpolatedTime, Transformation t, float dx, float dy) { float centerX = getScrollX() + (mWidth / 2) - (mItemWidth / 2); updateScaleForView(viewToShift, centerX, viewToShift.getX() + dx); } }); slideAnim.setDuration(Constant.BUBBLE_FLOW_ANIM_TIME); slideAnim.setFillAfter(true); viewToShift.startAnimation(slideAnim); } } } else { mContent.removeView(view); if (removeFromList) { mViews.remove(view); updatePositions(); updateScales(getScrollX()); mContent.invalidate(); } if (onRemovedListener != null) { onRemovedListener.onRemoved(view); } } }
From source file:org.creativecommons.thelist.misc.MainActivity.java
public void showSnackbar() { SnackbarManager.show(//from ww w . j av a 2 s . c om //also includes duration: SHORT, LONG, INDEFINITE Snackbar.with(mContext).text("Item deleted") //text to display .actionColor(getResources().getColor(R.color.colorSecondary)) .actionLabel("undo".toUpperCase()).actionListener(new ActionClickListener() { @Override public void onActionClicked(Snackbar snackbar) { /*NOTE: item does not need to be re-added here because it is only removed when the snackbar is actually dismissed*/ //What happens when item is swiped offscreen mItemList.add(0, mLastDismissedItem); //re-add item to users list in DB mCurrentUser.addItemToUserList(mLastDismissedItem.getItemID()); mFeedAdapter.notifyDataSetChanged(); mLayoutManager.scrollToPosition(0); mFab.show(); } }) //action buttons listener .eventListener(new EventListener() { Interpolator interpolator = new MaterialInterpolator(); @Override public void onShow(Snackbar snackbar) { TranslateAnimation tsa = new TranslateAnimation(0, 0, 0, -snackbar.getHeight()); tsa.setInterpolator(interpolator); tsa.setFillAfter(true); tsa.setFillEnabled(true); tsa.setDuration(300); mFab.startAnimation(tsa); } @Override public void onShowByReplace(Snackbar snackbar) { } @Override public void onShown(Snackbar snackbar) { } @Override public void onDismiss(Snackbar snackbar) { TranslateAnimation tsa2 = new TranslateAnimation(0, 0, -snackbar.getHeight(), 0); tsa2.setInterpolator(interpolator); tsa2.setFillAfter(true); tsa2.setFillEnabled(true); tsa2.setStartOffset(100); tsa2.setDuration(300); mFab.startAnimation(tsa2); } @Override public void onDismissByReplace(Snackbar snackbar) { } @Override public void onDismissed(Snackbar snackbar) { //TODO: QA //If no more items if (mItemList.isEmpty()) { mEmptyView.setVisibility(View.VISIBLE); } //If fab is hidden (bug fix?) if (!mFab.isVisible()) { mFab.show(); } } }) //event listener , MainActivity.this); }