Search in sources :

Example 36 with Rect

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

the class UiUtils method getStatusBarHeight.

/**
     * Get height of status bar
     * @param activity
     * @return
     */
public static int getStatusBarHeight(Activity activity) {
    Rect frame = new Rect();
    activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);
    return frame.top;
}
Also used : Rect(android.graphics.Rect)

Example 37 with Rect

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

the class HeaderPositionCalculator method itemIsObscuredByHeader.

/**
     * Determines if an item is obscured by a header
     *
     * @param parent
     * @param item        to determine if obscured by header
     * @param header      that might be obscuring the item
     * @param orientation of the {@link RecyclerView}
     * @return true if the item view is obscured by the header view
     */
private boolean itemIsObscuredByHeader(RecyclerView parent, View item, View header, int orientation) {
    RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) item.getLayoutParams();
    Rect headerMargins = mDimensionCalculator.getMargins(header);
    int adapterPosition = parent.getChildAdapterPosition(item);
    if (adapterPosition == RecyclerView.NO_POSITION || mHeaderProvider.getHeader(parent, adapterPosition) != header) {
        // Handles an edge case where a trailing header is smaller than the current sticky header.
        return false;
    }
    if (orientation == LinearLayoutManager.VERTICAL) {
        int itemTop = item.getTop() - layoutParams.topMargin;
        int headerBottom = header.getBottom() + headerMargins.bottom + headerMargins.top;
        if (itemTop > headerBottom) {
            return false;
        }
    } else {
        int itemLeft = item.getLeft() - layoutParams.leftMargin;
        int headerRight = header.getRight() + headerMargins.right + headerMargins.left;
        if (itemLeft > headerRight) {
            return false;
        }
    }
    return true;
}
Also used : Rect(android.graphics.Rect) RecyclerView(android.support.v7.widget.RecyclerView)

Example 38 with Rect

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

the class HeaderPositionCalculator method getHeaderBounds.

public Rect getHeaderBounds(RecyclerView recyclerView, View header, View firstView, boolean firstHeader) {
    int orientation = mOrientationProvider.getOrientation(recyclerView);
    Rect bounds = getDefaultHeaderOffset(recyclerView, header, firstView, orientation);
    if (firstHeader && isStickyHeaderBeingPushedOffscreen(recyclerView, header)) {
        View viewAfterNextHeader = getFirstViewUnobscuredByHeader(recyclerView, header);
        int firstViewUnderHeaderPosition = recyclerView.getChildAdapterPosition(viewAfterNextHeader);
        View secondHeader = mHeaderProvider.getHeader(recyclerView, firstViewUnderHeaderPosition);
        translateHeaderWithNextHeader(recyclerView, mOrientationProvider.getOrientation(recyclerView), bounds, header, viewAfterNextHeader, secondHeader);
    }
    return bounds;
}
Also used : Rect(android.graphics.Rect) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 39 with Rect

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

the class HeaderRenderer method drawHeader.

/**
   * Draws a header to a canvas, offsetting by some x and y amount
   *
   * @param recyclerView the parent recycler view for drawing the header into
   * @param canvas       the canvas on which to draw the header
   * @param header       the view to draw as the header
   * @param offset       a Rect used to define the x/y offset of the header. Specify x/y offset by setting
   *                     the {@link Rect#left} and {@link Rect#top} properties, respectively.
   */
public void drawHeader(RecyclerView recyclerView, Canvas canvas, View header, Rect offset) {
    canvas.save();
    if (recyclerView.getLayoutManager().getClipToPadding()) {
        // Clip drawing of headers to the padding of the RecyclerView. Avoids drawing in the padding
        Rect clipRect = getClipRectForHeader(recyclerView, header);
        canvas.clipRect(clipRect);
    }
    canvas.translate(offset.left, offset.top);
    header.draw(canvas);
    canvas.restore();
}
Also used : Rect(android.graphics.Rect)

Example 40 with Rect

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

the class SwipeLayout method computeBottomLayoutAreaViaSurface.

private Rect computeBottomLayoutAreaViaSurface(ShowMode mode, Rect surfaceArea) {
    Rect rect = surfaceArea;
    View bottomView = getCurrentBottomView();
    int bl = rect.left, bt = rect.top, br = rect.right, bb = rect.bottom;
    if (mode == ShowMode.PullOut) {
        if (mCurrentDragEdge == DragEdge.Left)
            bl = rect.left - mDragDistance;
        else if (mCurrentDragEdge == DragEdge.Right)
            bl = rect.right;
        else if (mCurrentDragEdge == DragEdge.Top)
            bt = rect.top - mDragDistance;
        else
            bt = rect.bottom;
        if (mCurrentDragEdge == DragEdge.Left || mCurrentDragEdge == DragEdge.Right) {
            bb = rect.bottom;
            br = bl + (bottomView == null ? 0 : bottomView.getMeasuredWidth());
        } else {
            bb = bt + (bottomView == null ? 0 : bottomView.getMeasuredHeight());
            br = rect.right;
        }
    } else if (mode == ShowMode.LayDown) {
        if (mCurrentDragEdge == DragEdge.Left)
            br = bl + mDragDistance;
        else if (mCurrentDragEdge == DragEdge.Right)
            bl = br - mDragDistance;
        else if (mCurrentDragEdge == DragEdge.Top)
            bb = bt + mDragDistance;
        else
            bt = bb - mDragDistance;
    }
    return new Rect(bl, bt, br, bb);
}
Also used : Rect(android.graphics.Rect) View(android.view.View) AdapterView(android.widget.AdapterView) AbsListView(android.widget.AbsListView)

Aggregations

Rect (android.graphics.Rect)3823 Paint (android.graphics.Paint)791 View (android.view.View)533 Point (android.graphics.Point)470 Bitmap (android.graphics.Bitmap)333 Canvas (android.graphics.Canvas)255 Drawable (android.graphics.drawable.Drawable)203 RectF (android.graphics.RectF)176 Resources (android.content.res.Resources)101 Matrix (android.graphics.Matrix)99 SmallTest (android.test.suitebuilder.annotation.SmallTest)94 TextPaint (android.text.TextPaint)94 RemoteException (android.os.RemoteException)93 ViewGroup (android.view.ViewGroup)89 TextView (android.widget.TextView)87 ArrayList (java.util.ArrayList)87 AccessibilityNodeInfo (android.view.accessibility.AccessibilityNodeInfo)84 BitmapDrawable (android.graphics.drawable.BitmapDrawable)82 SuppressLint (android.annotation.SuppressLint)77 ImageView (android.widget.ImageView)70