List of usage examples for android.animation ObjectAnimator ofObject
@NonNull public static <T, V> ObjectAnimator ofObject(T target, @NonNull Property<T, V> property, @Nullable TypeConverter<PointF, V> converter, Path path)
Path
. From source file:com.srinath.hcfab.under25hack.media.MediaFragment.java
public void onFabPressed(View view) { final float startX = mFab.getX(); AnimatorPath path = new AnimatorPath(); path.moveTo(0, 0);/*from w w w. ja va2s. c o m*/ path.curveTo(-200, 200, -400, 100, -600, 50); final ObjectAnimator anim = ObjectAnimator.ofObject(this, "fabLoc", new PathEvaluator(), path.getPoints().toArray()); anim.setInterpolator(new AccelerateInterpolator()); anim.setDuration(ANIMATION_DURATION); anim.start(); anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { if (Math.abs(startX - mFab.getX()) > MINIMUN_X_DISTANCE) { if (!mRevealFlag) { mFabContainer.setY(mFabContainer.getY() + mFabSize / 2); mFab.animate().scaleXBy(SCALE_FACTOR).scaleYBy(SCALE_FACTOR).setListener(mEndRevealListener) .setDuration(ANIMATION_DURATION); mRevealFlag = true; } } } }); }
From source file:com.imczy.customactivitytransition.transition.ShareElemReturnChangePosition.java
@Override public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) { if (null == startValues || null == endValues) { return null; }//from w w w . j a v a 2s . com if (startValues.view.getId() > 0) { Rect startRect = (Rect) startValues.values.get(PROPNAME_POSITION); Rect endRect = (Rect) endValues.values.get(PROPNAME_POSITION); final View view = endValues.view; Path changePosPath = getPathMotion().getPath(startRect.centerX(), startRect.centerY(), endRect.centerX(), endRect.centerY() - endRect.height() / 2); ObjectAnimator objectAnimator = ObjectAnimator.ofObject(view, new PropPosition(PointF.class, "position", new PointF(startRect.centerX(), startRect.centerY())), null, changePosPath); objectAnimator.setInterpolator(new FastOutSlowInInterpolator()); return objectAnimator; } return null; }
From source file:com.imczy.customactivitytransition.transition.ChangePosition.java
@Override public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) { if (null == startValues || null == endValues) { return null; }//ww w. ja v a 2 s. c om if (startValues.view.getId() > 0) { Rect startRect = (Rect) startValues.values.get(PROPNAME_POSITION); Rect endRect = (Rect) endValues.values.get(PROPNAME_POSITION); final View view = endValues.view; Path changePosPath = getPathMotion().getPath(startRect.centerX(), startRect.centerY(), endRect.centerX(), endRect.centerY()); int radius = startRect.centerY() - endRect.centerY(); ObjectAnimator objectAnimator = ObjectAnimator.ofObject(view, new PropPosition(PointF.class, "position", new PointF(endRect.centerX(), endRect.centerY())), null, changePosPath); objectAnimator.setInterpolator(new FastOutSlowInInterpolator()); return objectAnimator; } return null; }
From source file:andoridhost.imczy.com.activitymaterial.custom.ReturnChangePosition.java
@Override public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) { if (null == startValues || null == endValues) { return null; }//from w w w.j a v a 2s . co m if (startValues.view.getId() > 0) { Rect startRect = (Rect) startValues.values.get(PROPNAME_POSITION); Rect endRect = (Rect) endValues.values.get(PROPNAME_POSITION); final View view = endValues.view; Log.e(TAG, "createAnimator: startRect = " + startRect + " , endRect = " + endRect); Path changePosPath = getPathMotion().getPath(startRect.centerX(), startRect.centerY(), endRect.centerX(), endRect.centerY() - endRect.height() / 2); int radius = startRect.centerY() - endRect.centerY(); Log.e(TAG, "createAnimator: startRect center x = " + startRect.centerX() + " , centerY= " + startRect.centerY()); Log.w(TAG, "createAnimator: end rect center x = " + endRect.centerX() + " , centerY= " + endRect.centerY()); ObjectAnimator objectAnimator = ObjectAnimator.ofObject(view, new PropPosition(PointF.class, "position", new PointF(startRect.centerX(), startRect.centerY())), null, changePosPath); objectAnimator.setInterpolator(new FastOutSlowInInterpolator()); return objectAnimator; } return null; }
From source file:andoridhost.imczy.com.activitymaterial.custom.ChangePosition.java
@Override public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) { if (null == startValues || null == endValues) { return null; }/*w w w.j av a 2s. c om*/ if (startValues.view.getId() > 0) { Rect startRect = (Rect) startValues.values.get(PROPNAME_POSITION); Rect endRect = (Rect) endValues.values.get(PROPNAME_POSITION); final View view = endValues.view; Log.e(TAG, "createAnimator: startRect = " + startRect + " , endRect = " + endRect); Path changePosPath = getPathMotion().getPath(startRect.centerX(), startRect.centerY(), endRect.centerX(), endRect.centerY()); int radius = startRect.centerY() - endRect.centerY(); ObjectAnimator objectAnimator = ObjectAnimator.ofObject(view, new PropPosition(PointF.class, "position", new PointF(endRect.centerX(), endRect.centerY())), null, changePosPath); objectAnimator.setInterpolator(new FastOutSlowInInterpolator()); return objectAnimator; } return null; }
From source file:com.truizlop.fabreveallayout.FABRevealLayout.java
private ObjectAnimator getFABAnimator() { CurvedAnimator curvedAnimator = getCurvedAnimator(); return ObjectAnimator.ofObject(this, "fabPosition", new CurvedPathEvaluator(), curvedAnimator.getPoints()); }
From source file:com.ffmpegtest.VideoActivity.java
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) private void swapScaleType() { FFmpegSurfaceView view = (FFmpegSurfaceView) mVideoView; FFmpegSurfaceView.ScaleType scaleType = view.getScaleType(); ScaleType newScaleType;//from w w w. j a va 2 s. c o m if (ScaleType.CENTER_INSIDE.equals(scaleType)) { newScaleType = ScaleType.CENTER_CROP; } else if (ScaleType.CENTER_CROP.equals(scaleType)) { newScaleType = ScaleType.FIT_XY; } else { newScaleType = ScaleType.CENTER_INSIDE; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { view.setScaleType(newScaleType, true); RectF dst = new RectF(); view.calculateRect(dst, newScaleType); ObjectAnimator anim = ObjectAnimator.ofObject(view, "destinationRect", new RectEvaluator(), dst); anim.setInterpolator(new AccelerateDecelerateInterpolator()); anim.start(); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { view.setScaleType(newScaleType, true); RectF dst = new RectF(); view.calculateRect(dst, newScaleType); ObjectAnimator anim = ObjectAnimator.ofObject(view, new PropertyDestinationRect(), new RectEvaluator(), dst); anim.setInterpolator(new AccelerateDecelerateInterpolator()); anim.start(); } else { view.setScaleType(newScaleType, false); } }
From source file:com.dgnt.dominionCardPicker.view.DynamicListView.java
/** * Resets all the appropriate fields to a default state while also animating * the hover cell back to its correct location. *//*www.j a v a2 s. com*/ private void touchEventsEnded() { final View mobileView = getViewForID(mMobileItemId); if (mCellIsMobile || mIsWaitingForScrollFinish) { mCellIsMobile = false; mIsWaitingForScrollFinish = false; mIsMobileScrolling = false; mActivePointerId = INVALID_POINTER_ID; // If the autoscroller has not completed scrolling, we need to wait for it to // finish in order to determine the final location of where the hover cell // should be animated to. if (mScrollState != OnScrollListener.SCROLL_STATE_IDLE) { mIsWaitingForScrollFinish = true; return; } mHoverCellCurrentBounds.offsetTo(mHoverCellOriginalBounds.left, mobileView.getTop()); ObjectAnimator hoverViewAnimator = ObjectAnimator.ofObject(mHoverCell, "bounds", sBoundEvaluator, mHoverCellCurrentBounds); hoverViewAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { invalidate(); } }); hoverViewAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { setEnabled(false); } @Override public void onAnimationEnd(Animator animation) { mAboveItemId = INVALID_ID; mMobileItemId = INVALID_ID; mBelowItemId = INVALID_ID; mobileView.setVisibility(VISIBLE); mHoverCell = null; setEnabled(true); invalidate(); } }); hoverViewAnimator.start(); } else { touchEventsCancelled(); } }
From source file:com.example.customview.DynamicListView.java
/** * Resets all the appropriate fields to a default state while also animating * the hover cell back to its correct location. *///from ww w.j ava2 s . co m private void touchEventsEnded() { final View mobileView = getViewForID(mMobileItemId); if (mCellIsMobile || mIsWaitingForScrollFinish) { mCellIsMobile = false; mIsWaitingForScrollFinish = false; mIsMobileScrolling = false; mActivePointerId = INVALID_POINTER_ID; // If the autoscroller has not completed scrolling, we need to wait for it to // finish in order to determine the final location of where the hover cell // should be animated to. if (mScrollState != OnScrollListener.SCROLL_STATE_IDLE) { mIsWaitingForScrollFinish = true; return; } mHoverCellCurrentBounds.offsetTo(mHoverCellOriginalBounds.left, mobileView.getTop()); ObjectAnimator hoverViewAnimator = ObjectAnimator.ofObject(mHoverCell, "bounds", sBoundEvaluator, mHoverCellCurrentBounds); hoverViewAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { invalidate(); } }); hoverViewAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { setEnabled(false); } @Override public void onAnimationEnd(Animator animation) { mAboveItemId = INVALID_ID; mMobileItemId = INVALID_ID; mBelowItemId = INVALID_ID; mobileView.setVisibility(VISIBLE); mHoverCell = null; setEnabled(true); invalidate(); } }); hoverViewAnimator.start(); } else { touchEventsCancelled(); } }
From source file:ucsc.hci.rankit.DynamicListView.java
/** * Resets all the appropriate fields to a default state while also animating * the hover cell back to its correct location. *//* w w w.j a va2 s .com*/ private void touchEventsEnded() { final View mobileView = getViewForID(mMobileItemId); if (mCellIsMobile || mIsWaitingForScrollFinish) { mCellIsMobile = false; mIsWaitingForScrollFinish = false; mIsMobileScrolling = false; mActivePointerId = INVALID_POINTER_ID; // If the autoscroller has not completed scrolling, we need to wait for it to // finish in order to determine the final location of where the hover cell // should be animated to. if (mScrollState != OnScrollListener.SCROLL_STATE_IDLE) { mIsWaitingForScrollFinish = true; return; } try { mHoverCellCurrentBounds.offsetTo(mHoverCellOriginalBounds.left, mobileView.getTop()); } catch (Exception e) { e.printStackTrace(); } ObjectAnimator hoverViewAnimator = ObjectAnimator.ofObject(mHoverCell, "bounds", sBoundEvaluator, mHoverCellCurrentBounds); hoverViewAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { invalidate(); } }); hoverViewAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { setEnabled(false); } @Override public void onAnimationEnd(Animator animation) { mAboveItemId = INVALID_ID; mMobileItemId = INVALID_ID; mBelowItemId = INVALID_ID; mobileView.setVisibility(VISIBLE); mHoverCell = null; setEnabled(true); invalidate(); } }); try { hoverViewAnimator.start(); } catch (Exception e) { e.printStackTrace(); } } else { touchEventsCancelled(); } }