public class ViewUtilitiesImpl extends Object
Modifier and Type | Method and Description |
---|---|
static String |
axisToString(int axis) |
static void |
checkViewHierarchy(View v) |
static int |
findLowerViewIndex(View view,
int offset,
boolean lowerAdjacent)
The semantics is the same like
findViewIndex()
but if there are any empty views at the offset (e.g. |
static int |
findUpperViewIndex(View view,
int offset,
boolean excludeAtOffset)
The semantics is the same like
findViewIndex()
but if there are any empty views at the offset (e.g. |
static int |
findViewIndex(View view,
int offset)
Find the child view index that best represents the given offset.
|
static int |
findViewIndexBounded(View view,
int offset)
Find child index representing the given offset
or -1 if the offset is not represented by any child view
i.e.
|
static Rectangle |
maybeNew(Rectangle r,
int x,
int y,
int width,
int height)
Return existing rectangle or create new one.
|
static Rectangle |
maybeNew(Rectangle origRect,
Rectangle testRect)
Return existing rectangle or create new one.
|
public static int findViewIndexBounded(View view, int offset)
view
- view having children to be inspected.offset
- the position >= 0.
offset < view.getStartOffset()
|| offset >= view.getEndOffset()
|| getViewCount() == 0
.public static int findViewIndex(View view, int offset)
Element.getElementIndex(int)
semantics.view
- view having children to be inspected.offset
- the position >= 0offset < getView(0).getStartOffset()
.
getViewCount() - 1
if offset >= getView(viewCount - 1).getEndOffset()
.
getViewCount() == 0
.public static int findLowerViewIndex(View view, int offset, boolean lowerAdjacent)
findViewIndex()
but if there are any empty views at the offset (e.g. because
of removal) then they are skipped and the first empty view
is returned.view
- view having children to be inspected.offset
- the position >= 0lowerAdjacent
- if set to true
and the returned child view would start right at offset
then return the non-empty left adjacent view (which ends
at the offset
). This may be useful e.g. in case
of removal when the view was affected by removal (view's end was removed)
but now after removal it seems that it naturally ends at offset
.public static int findUpperViewIndex(View view, int offset, boolean excludeAtOffset)
findViewIndex()
but if there are any empty views at the offset (e.g. because
of removal) then they are skipped and the first non-empty view
starting at the offset is returned.view
- view having children to be inspected.offset
- the position >= 0excludeAtOffset
- if set to true
and the returned non-empty child view would start right at offset
then return the left adjacent view (which ends
at the offset
). This may be useful e.g. in case
of insertion to not replace a view that starts right at the offset
and was not in fact affected by insertion.public static Rectangle maybeNew(Rectangle r, int x, int y, int width, int height)
r
- rectangle which is checked to correspond to next parameters.x
- x coordinate of returned rectangle.y
- y coordinate of returned rectangle.width
- width of returned rectangle.height
- height of returned rectangle.r
passed to this method
in case it corresponds to all the other parameters.
Newly created rectangle instance otherwise.public static Rectangle maybeNew(Rectangle origRect, Rectangle testRect)
origRect
- rectangle which is checked to correspond to tested rect.testRect
- rectangle being tested for equality to origRect.origRect
passed to this method
in case it corresponds to testRect
.
Newly created rectangle instance (being equal to testRect) otherwise.public static String axisToString(int axis)
public static void checkViewHierarchy(View v)