public Transition GenerateNextTransition(RectF drawableBounds, RectF viewport) { bool firstTransition = _mLastGenTrans == null; bool drawableBoundsChanged = true; bool viewportRatioChanged = true; RectF srcRect = null; RectF dstRect = null; if (!firstTransition) { dstRect = _mLastGenTrans.GetDestinyRect(); drawableBoundsChanged = !drawableBounds.Equals(_mLastDrawableBounds); viewportRatioChanged = !MathUtils.HaveSameAspectRatio(dstRect, viewport); } if (dstRect == null || drawableBoundsChanged || viewportRatioChanged) { srcRect = GenerateRandomRect(drawableBounds, viewport); } else { /* Sets the destiny rect of the last transition as the source one if the current drawable has the same dimensions as the one of the last transition. */ srcRect = dstRect; } dstRect = GenerateRandomRect(drawableBounds, viewport); _mLastGenTrans = new Transition(srcRect, dstRect, _mTransitionDuration, _mTransitionIInterpolator); _mLastDrawableBounds = drawableBounds; return _mLastGenTrans; }
/** * Fires an end event on {@link #mTransitionListener}; * @param transition the transition that just ended. */ private void FireTransitionEnd(Transition transition) { if (_mTransitionListener != null && transition != null) { _mTransitionListener.OnTransitionEnd(transition); } }
/** * Generates and starts a transition. */ private void StartNewTransition() { if (!HasBounds()) { return; // Can't start transition if the drawable has no bounds. } _mCurrentTrans = _mTransGen.GenerateNextTransition(_mDrawableRect, _mViewportRect); _mElapsedTime = 0; _mLastFrameTime = JavaSystem.CurrentTimeMillis(); FireTransitionStart(_mCurrentTrans); }