List of usage examples for android.view.animation TranslateAnimation setFillAfter
public void setFillAfter(boolean fillAfter)
From source file:com.turingtechnologies.materialscrollbar.MaterialScrollBar.java
/** * Animates the bar out of view/*from ww w . j a va 2 s . c o m*/ */ private void fadeOut() { if (!hidden) { TranslateAnimation anim = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f); anim.setDuration(500); anim.setFillAfter(true); hidden = true; startAnimation(anim); } }
From source file:com.mappn.gfan.ui.HomeTabActivity.java
@Override public void onTabChanged(String tabId) { // ?/* w ww. j a va 2 s . c o m*/ if (TAB_APP.equals(tabId)) { Utils.trackEvent(getApplicationContext(), Constants.GROUP_4, Constants.CLICK_MANAGER_TAB); } else if (TAB_CATEGORY.equals(tabId)) { Utils.trackEvent(getApplicationContext(), Constants.GROUP_4, Constants.CLICK_CATEGORY_TAB); } else if (TAB_RANK.equals(tabId)) { Utils.trackEvent(getApplicationContext(), Constants.GROUP_4, Constants.CLICK_RANK_TAB); } else if (TAB_HOME.equals(tabId)) { Utils.trackEvent(getApplicationContext(), Constants.GROUP_4, Constants.CLICK_HOME_TAB); } final View tab = getTabHost().getCurrentTabView(); final int endX = tab.getLeft(); final TranslateAnimation animation = new TranslateAnimation(mStartX, endX, 0, 0); animation.setDuration(200); animation.setFillAfter(true); if (mMover == null) { initTabAnimationParameter(); } mMover.startAnimation(animation); mStartX = endX; }
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 ww w . ja v a2 s .c o m*/ //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 ww w . j ava 2 s. com*/ */ 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/*from w w w . j a v a 2 s .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:org.creativecommons.thelist.misc.MainActivity.java
public void showSnackbar() { SnackbarManager.show(// w ww . j a v a2 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); }
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 .ja v a 2 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
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 a v a 2 s. c o 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
protected void remove(final int index, boolean animateOff, boolean removeFromList, final OnRemovedListener onRemovedListener) { if (index < 0 || index >= mViews.size()) { return;/* w ww . j a v a 2 s. 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:com.allwinner.theatreplayer.launcher.activity.LaunchActivity.java
private void highlightCurDot(int oldIndex, int newIndex) { Log.i("jim", "oldIndex = " + oldIndex + ">>>>newIndex = " + newIndex); if (mTopTextView == null || mTopFocusLine == null || newIndex < 0 || newIndex > mPageCount - 1 || oldIndex == newIndex) {//from w w w .j a v a 2s. c om return; } mTopTextView[oldIndex].setTextColor(this.getResources().getColor(R.color.grey)); mTopTextView[newIndex].setTextColor(this.getResources().getColor(R.color.blue)); int moveDistance = mTopTextView[newIndex].getLeft() - mTopTextView[oldIndex].getLeft(); TranslateAnimation animation = new TranslateAnimation(startLeft, startLeft + moveDistance, 0, 0); startLeft += moveDistance; animation.setDuration(300); animation.setFillAfter(true); mTopFocusLine.startAnimation(animation); }