Search in sources :

Example 1 with Rect

use of android.graphics.Rect in project kickmaterial by byoutline.

the class CircleTransition method createAnimator.

@Override
public Animator createAnimator(final ViewGroup sceneRoot, TransitionValues startValues, final TransitionValues endValues) {
    if (startValues == null || endValues == null) {
        return null;
    }
    Rect startBounds = (Rect) startValues.values.get(PROPERTY_BOUNDS);
    Rect endBounds = (Rect) endValues.values.get(PROPERTY_BOUNDS);
    boolean boundsEqual = startBounds == null || endBounds == null || startBounds.equals(endBounds);
    if (boundsEqual) {
        return null;
    }
    int[] sceneRootLoc = new int[2];
    sceneRoot.getLocationInWindow(sceneRootLoc);
    int[] startLoc = (int[]) startValues.values.get(PROPERTY_POSITION);
    final View startView = getStartView(sceneRoot, startValues, sceneRootLoc, startLoc);
    final View endView = endValues.view;
    endView.setAlpha(0f);
    Path circlePath = getMovePath(endValues, startView, sceneRootLoc, startLoc, endView);
    Animator circleAnimator = ObjectAnimator.ofFloat(startView, View.TRANSLATION_X, View.TRANSLATION_Y, circlePath);
    circleAnimator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            startView.setVisibility(View.INVISIBLE);
            endView.setAlpha(1f);
            sceneRoot.getOverlay().remove(startView);
        }
    });
    AnimatorSet moveSet = new AnimatorSet();
    float scaleRatio = ((float) endView.getWidth()) / startView.getWidth();
    ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(startView, View.SCALE_X, 1, scaleRatio);
    ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(startView, View.SCALE_Y, 1, scaleRatio);
    moveSet.playTogether(circleAnimator, scaleXAnimator, scaleYAnimator);
    return moveSet;
}
Also used : Path(android.graphics.Path) Rect(android.graphics.Rect) ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ObjectAnimator(android.animation.ObjectAnimator) AnimatorSet(android.animation.AnimatorSet) View(android.view.View)

Example 2 with Rect

use of android.graphics.Rect in project UltimateAndroid by cymcsg.

the class SwipeLayout method layoutPullOut.

void layoutPullOut() {
    Rect rect = computeSurfaceLayoutArea(false);
    getSurfaceView().layout(rect.left, rect.top, rect.right, rect.bottom);
    rect = computeBottomLayoutAreaViaSurface(ShowMode.PullOut, rect);
    getBottomView().layout(rect.left, rect.top, rect.right, rect.bottom);
    bringChildToFront(getSurfaceView());
}
Also used : Rect(android.graphics.Rect)

Example 3 with Rect

use of android.graphics.Rect in project UltimateAndroid by cymcsg.

the class Lanes method getChildFrame.

public void getChildFrame(Rect outRect, int childWidth, int childHeight, LaneInfo laneInfo, Direction direction) {
    final Rect startRect = mLanes[laneInfo.startLane];
    // The anchor lane only applies when we're get child frame in the direction
    // of the forward scroll. We'll need to rethink this once we start working on
    // RTL support.
    final int anchorLane = (direction == Direction.END ? laneInfo.anchorLane : laneInfo.startLane);
    final Rect anchorRect = mLanes[anchorLane];
    if (mIsVertical) {
        outRect.left = startRect.left;
        outRect.top = (direction == Direction.END ? anchorRect.bottom : anchorRect.top - childHeight);
    } else {
        outRect.top = startRect.top;
        outRect.left = (direction == Direction.END ? anchorRect.right : anchorRect.left - childWidth);
    }
    outRect.right = outRect.left + childWidth;
    outRect.bottom = outRect.top + childHeight;
}
Also used : Rect(android.graphics.Rect)

Example 4 with Rect

use of android.graphics.Rect in project UltimateAndroid by cymcsg.

the class Lanes method pushChildFrame.

public int pushChildFrame(Rect outRect, int lane, int margin, Direction direction) {
    final int delta;
    final Rect laneRect = mLanes[lane];
    if (mIsVertical) {
        if (direction == Direction.END) {
            delta = outRect.top - laneRect.bottom;
            laneRect.bottom = outRect.bottom + margin;
        } else {
            delta = outRect.bottom - laneRect.top;
            laneRect.top = outRect.top - margin;
        }
    } else {
        if (direction == Direction.END) {
            delta = outRect.left - laneRect.right;
            laneRect.right = outRect.right + margin;
        } else {
            delta = outRect.right - laneRect.left;
            laneRect.left = outRect.left - margin;
        }
    }
    invalidateEdges();
    return delta;
}
Also used : Rect(android.graphics.Rect)

Example 5 with Rect

use of android.graphics.Rect in project UltimateAndroid by cymcsg.

the class Lanes method reset.

public void reset(int offset) {
    for (int i = 0; i < mLanes.length; i++) {
        final Rect laneRect = mLanes[i];
        laneRect.offsetTo(mIsVertical ? laneRect.left : offset, mIsVertical ? offset : laneRect.top);
        if (mIsVertical) {
            laneRect.bottom = laneRect.top;
        } else {
            laneRect.right = laneRect.left;
        }
    }
    invalidateEdges();
}
Also used : Rect(android.graphics.Rect)

Aggregations

Rect (android.graphics.Rect)4865 Paint (android.graphics.Paint)1064 View (android.view.View)692 Point (android.graphics.Point)571 Bitmap (android.graphics.Bitmap)477 Canvas (android.graphics.Canvas)376 RectF (android.graphics.RectF)271 Drawable (android.graphics.drawable.Drawable)241 Matrix (android.graphics.Matrix)126 ViewGroup (android.view.ViewGroup)125 ArrayList (java.util.ArrayList)124 SuppressLint (android.annotation.SuppressLint)119 TextView (android.widget.TextView)117 Resources (android.content.res.Resources)113 PorterDuffXfermode (android.graphics.PorterDuffXfermode)110 TextPaint (android.text.TextPaint)110 ImageView (android.widget.ImageView)97 BitmapDrawable (android.graphics.drawable.BitmapDrawable)95 SmallTest (android.test.suitebuilder.annotation.SmallTest)94 RemoteException (android.os.RemoteException)93