Search in sources :

Example 81 with Rect

use of android.graphics.Rect in project actor-platform by actorapp.

the class AvatarPlaceholderDrawable method draw.

@Override
public void draw(Canvas canvas) {
    Rect bounds = getBounds();
    CIRCLE_PAINT.setColor(color);
    canvas.drawCircle(bounds.centerX(), bounds.centerY(), bounds.width() / 2, CIRCLE_PAINT);
    if (TEXT_SIZE != selfTextSize) {
        TEXT_PAINT.setTextSize(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, selfTextSize, ctx.getResources().getDisplayMetrics()));
        TEXT_SIZE = selfTextSize;
    }
    canvas.drawText(title, textX, textY, (TEXT_PAINT));
}
Also used : Rect(android.graphics.Rect)

Example 82 with Rect

use of android.graphics.Rect in project actor-platform by actorapp.

the class CoverOverlayDrawable method draw.

@Override
public void draw(Canvas canvas) {
    Rect rect = getBounds();
    bottomShadow.setBounds(rect.left, rect.bottom - Screen.dp(64), rect.right, rect.bottom);
    bottomShadow.draw(canvas);
}
Also used : Rect(android.graphics.Rect)

Example 83 with Rect

use of android.graphics.Rect in project actor-platform by actorapp.

the class BaseKeyboard method getViewInset.

public static int getViewInset(View view, int statusBarHeight) {
    if (view == null || view.getRootView() == null) {
        return 0;
    }
    view = view.getRootView();
    if (Build.VERSION.SDK_INT < 21 || view.getHeight() == Screen.getHeight() || view.getHeight() == Screen.getHeight() - statusBarHeight) {
        return 0;
    }
    try {
        Field mAttachInfoField = View.class.getDeclaredField("mAttachInfo");
        mAttachInfoField.setAccessible(true);
        Object mAttachInfo = mAttachInfoField.get(view);
        if (mAttachInfo != null) {
            Field mStableInsetsField = mAttachInfo.getClass().getDeclaredField("mStableInsets");
            mStableInsetsField.setAccessible(true);
            Rect insets = (Rect) mStableInsetsField.get(mAttachInfo);
            return insets.bottom;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return 0;
}
Also used : Field(java.lang.reflect.Field) Rect(android.graphics.Rect)

Example 84 with Rect

use of android.graphics.Rect in project Reader by TheKeeperOfPie.

the class CustomItemTouchHelper method scrollIfNecessary.

/**
     * If user drags the view to the edge, trigger a scroll if necessary.
     */
private boolean scrollIfNecessary() {
    if (mSelected == null) {
        mDragScrollStartTimeInMs = Long.MIN_VALUE;
        return false;
    }
    final long now = System.currentTimeMillis();
    final long scrollDuration = mDragScrollStartTimeInMs == Long.MIN_VALUE ? 0 : now - mDragScrollStartTimeInMs;
    RecyclerView.LayoutManager lm = mRecyclerView.getLayoutManager();
    if (mTmpRect == null) {
        mTmpRect = new Rect();
    }
    int scrollX = 0;
    int scrollY = 0;
    lm.calculateItemDecorationsForChild(mSelected.itemView, mTmpRect);
    if (lm.canScrollHorizontally()) {
        int curX = (int) (mSelectedStartX + mDx);
        final int leftDiff = curX - mTmpRect.left - mRecyclerView.getPaddingLeft();
        if (mDx < 0 && leftDiff < 0) {
            scrollX = leftDiff;
        } else if (mDx > 0) {
            final int rightDiff = curX + mSelected.itemView.getWidth() + mTmpRect.right - (mRecyclerView.getWidth() - mRecyclerView.getPaddingRight());
            if (rightDiff > 0) {
                scrollX = rightDiff;
            }
        }
    }
    if (lm.canScrollVertically()) {
        int curY = (int) (mSelectedStartY + mDy);
        final int topDiff = curY - mTmpRect.top - mRecyclerView.getPaddingTop();
        if (mDy < 0 && topDiff < 0) {
            scrollY = topDiff;
        } else if (mDy > 0) {
            final int bottomDiff = curY + mSelected.itemView.getHeight() + mTmpRect.bottom - (mRecyclerView.getHeight() - mRecyclerView.getPaddingBottom());
            if (bottomDiff > 0) {
                scrollY = bottomDiff;
            }
        }
    }
    if (scrollX != 0) {
        scrollX = mCallback.interpolateOutOfBoundsScroll(mRecyclerView, mSelected.itemView.getWidth(), scrollX, mRecyclerView.getWidth(), scrollDuration);
    }
    if (scrollY != 0) {
        scrollY = mCallback.interpolateOutOfBoundsScroll(mRecyclerView, mSelected.itemView.getHeight(), scrollY, mRecyclerView.getHeight(), scrollDuration);
    }
    if (scrollX != 0 || scrollY != 0) {
        if (mDragScrollStartTimeInMs == Long.MIN_VALUE) {
            mDragScrollStartTimeInMs = now;
        }
        mRecyclerView.scrollBy(scrollX, scrollY);
        return true;
    }
    mDragScrollStartTimeInMs = Long.MIN_VALUE;
    return false;
}
Also used : Rect(android.graphics.Rect) RecyclerView(android.support.v7.widget.RecyclerView) Paint(android.graphics.Paint)

Example 85 with Rect

use of android.graphics.Rect in project SuperSLiM by TonicArtos.

the class LayoutManager method layoutHeaderTowardsStart.

/**
     * Layout header towards start edge.
     *
     * @param header      Header to be laid out.
     * @param leadingEdge Leading edge to align sticky headers against.
     * @param markerLine  Bottom edge of the header.
     * @param sd          Section data.
     * @param state       Layout state.
     * @return Top of the section including the header.
     */
private int layoutHeaderTowardsStart(View header, int leadingEdge, int markerLine, int offset, int sectionBottom, SectionData sd, LayoutState state) {
    Rect r = setHeaderRectSides(mRect, sd, state);
    if (sd.headerParams.isHeaderInline() && !sd.headerParams.isHeaderOverlay()) {
        r.bottom = markerLine;
        r.top = r.bottom - sd.headerHeight;
    } else if (offset <= 0) {
        r.top = markerLine + offset;
        r.bottom = r.top + sd.headerHeight;
    } else {
        r.bottom = leadingEdge;
        r.top = r.bottom - sd.headerHeight;
    }
    if (sd.headerParams.isHeaderSticky() && r.top < leadingEdge && sd.firstPosition != state.getRecyclerState().getTargetScrollPosition()) {
        r.top = leadingEdge;
        r.bottom = r.top + sd.headerHeight;
        if (sd.headerParams.isHeaderInline() && !sd.headerParams.isHeaderOverlay()) {
            markerLine -= sd.headerHeight;
        }
    }
    if (r.bottom > sectionBottom) {
        r.bottom = sectionBottom;
        r.top = r.bottom - sd.headerHeight;
    }
    layoutDecorated(header, r.left, r.top, r.right, r.bottom);
    return Math.min(r.top, markerLine);
}
Also used : Rect(android.graphics.Rect)

Aggregations

Rect (android.graphics.Rect)4805 Paint (android.graphics.Paint)1052 View (android.view.View)687 Point (android.graphics.Point)563 Bitmap (android.graphics.Bitmap)467 Canvas (android.graphics.Canvas)372 RectF (android.graphics.RectF)266 Drawable (android.graphics.drawable.Drawable)241 Matrix (android.graphics.Matrix)125 ViewGroup (android.view.ViewGroup)121 ArrayList (java.util.ArrayList)121 TextView (android.widget.TextView)119 SuppressLint (android.annotation.SuppressLint)116 Resources (android.content.res.Resources)112 TextPaint (android.text.TextPaint)110 PorterDuffXfermode (android.graphics.PorterDuffXfermode)105 ImageView (android.widget.ImageView)97 BitmapDrawable (android.graphics.drawable.BitmapDrawable)95 SmallTest (android.test.suitebuilder.annotation.SmallTest)94 RemoteException (android.os.RemoteException)93