本文整理汇总了Java中android.graphics.Rect.intersect方法的典型用法代码示例。如果您正苦于以下问题:Java Rect.intersect方法的具体用法?Java Rect.intersect怎么用?Java Rect.intersect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.Rect
的用法示例。
在下文中一共展示了Rect.intersect方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getVisibleBoundsInScreen
import android.graphics.Rect; //导入方法依赖的package包/类
/**
* Returns the node's bounds clipped to the size of the display
*
* @param node
* @param width pixel width of the display
* @param height pixel height of the display
* @return null if node is null, else a Rect containing visible bounds
*/
public static Rect getVisibleBoundsInScreen(AccessibilityNodeInfo node, int width, int height) {
if (node == null) {
return null;
}
// targeted node's bounds
Rect nodeRect = new Rect();
node.getBoundsInScreen(nodeRect);
Rect displayRect = new Rect();
displayRect.top = 0;
displayRect.left = 0;
displayRect.right = width;
displayRect.bottom = height;
boolean intersect = nodeRect.intersect(displayRect);
return nodeRect;
}
开发者ID:feifadaima,项目名称:https-github.com-hyb1996-NoRootScriptDroid,代码行数:25,代码来源:AccessibilityNodeInfoHelper.java
示例2: calculateFramingRect
import android.graphics.Rect; //导入方法依赖的package包/类
/**
* Calculate framing rectangle, relative to the preview frame.
*
* Note that the SurfaceView may be larger than the container.
*
* Override this for more control over the framing rect calculations.
*
* @param container this container, with left = top = 0
* @param surface the SurfaceView, relative to this container
* @return the framing rect, relative to this container
*/
protected Rect calculateFramingRect(Rect container, Rect surface) {
// intersection is the part of the container that is used for the preview
Rect intersection = new Rect(container);
boolean intersects = intersection.intersect(surface);
if(framingRectSize != null) {
// Specific size is specified. Make sure it's not larger than the container or surface.
int horizontalMargin = Math.max(0, (intersection.width() - framingRectSize.width) / 2);
int verticalMargin = Math.max(0, (intersection.height() - framingRectSize.height) / 2);
intersection.inset(horizontalMargin, verticalMargin);
return intersection;
}
// margin as 10% (default) of the smaller of width, height
int margin = (int) Math.min(intersection.width() * marginFraction, intersection.height() * marginFraction);
intersection.inset(margin, margin);
if (intersection.height() > intersection.width()) {
// We don't want a frame that is taller than wide.
intersection.inset(0, (intersection.height() - intersection.width()) / 2);
}
return intersection;
}
示例3: intersectVisibleToUser
import android.graphics.Rect; //导入方法依赖的package包/类
private boolean intersectVisibleToUser(Rect localRect) {
if (localRect == null || localRect.isEmpty() || this.mView.getWindowVisibility() != 0) {
return false;
}
ViewParent viewParent = this.mView.getParent();
while (viewParent instanceof View) {
View view = (View) viewParent;
if (ViewCompat.getAlpha(view) <= 0.0f || view.getVisibility() != 0) {
return false;
}
viewParent = view.getParent();
}
if (viewParent == null || !this.mView.getLocalVisibleRect(this.mTempVisibleRect)) {
return false;
}
return localRect.intersect(this.mTempVisibleRect);
}
示例4: viewsIntersect
import android.graphics.Rect; //导入方法依赖的package包/类
/**
* Determines if two views intersect in the window.
*/
public static boolean viewsIntersect(View view1, View view2) {
if (view1 == null || view2 == null) return false;
final int[] view1Loc = new int[2];
view1.getLocationOnScreen(view1Loc);
final Rect view1Rect = new Rect(view1Loc[0],
view1Loc[1],
view1Loc[0] + view1.getWidth(),
view1Loc[1] + view1.getHeight());
int[] view2Loc = new int[2];
view2.getLocationOnScreen(view2Loc);
final Rect view2Rect = new Rect(view2Loc[0],
view2Loc[1],
view2Loc[0] + view2.getWidth(),
view2Loc[1] + view2.getHeight());
return view1Rect.intersect(view2Rect);
}
示例5: getSnapHeight
import android.graphics.Rect; //导入方法依赖的package包/类
public int getSnapHeight() {
if (!needSnap) {
return 0;
}
needSnap = false;
Rect displayRect = new Rect(0, scroll, getWidth(), getHeight() + scroll);
int itemCount = getItemCount();
for (int i = 0; i < itemCount; i++) {
Rect itemRect = locationRects.get(i);
if (displayRect.intersect(itemRect)) {
if (lastDy > 0) {
// scroll变大,属于列表往下走,往下找下一个为snapView
if (i < itemCount - 1) {
Rect nextRect = locationRects.get(i + 1);
return nextRect.top - displayRect.top;
}
}
return itemRect.top - displayRect.top;
}
}
return 0;
}
示例6: hits
import android.graphics.Rect; //导入方法依赖的package包/类
private boolean hits(Fish fish, VisibleObject visibleObject) {
int left1 = (int)displayPosX(fish);
int top1 = (int)displayPosY(fish);
int width1 = (int)(mDensityFactor*FISHWIDTH[fish.size]);
int height1 = (int)(mDensityFactor*FISHHEIGHT[fish.size]);
int delta1 = height1*2/10;
Rect r1 = new Rect(left1+delta1, top1+delta1, left1+width1-delta1, top1+height1-delta1);
int left2 = (int)displayPosX(visibleObject);
int top2 = (int)displayPosY(visibleObject);
int width2 = (int)(mDensityFactor*FISHWIDTH[visibleObject.size]);
int height2 = (int)(mDensityFactor*FISHHEIGHT[visibleObject.size]);
int delta2 = height2*2/10;
Rect r2 = new Rect(left2+delta2, top2+delta2, left2+width2-delta2, top2+height2-delta2);
if (r1.intersect(r2)) {
return true;
}
return false;
}
示例7: a
import android.graphics.Rect; //导入方法依赖的package包/类
public boolean a(int i1, int j1) {
Rect rect = c();
boolean flag;
if (rect != null)
flag = rect.intersect(i1, j1, i1, j1);
else
flag = false;
return flag;
}
示例8: getVisibleBounds
import android.graphics.Rect; //导入方法依赖的package包/类
private Rect getVisibleBounds(AccessibilityNodeInfo node) {
if (!visible) {
return new Rect();
}
Rect visibleBounds = getBounds(this.node);
UiAutomationElement parent = getParent();
Rect parentBounds;
while (parent != null && parent.node != null) {
parentBounds = parent.getBounds(this.parent.node);
visibleBounds.intersect(parentBounds);
parent = parent.getParent();
}
return visibleBounds;
}
示例9: updateHq
import android.graphics.Rect; //导入方法依赖的package包/类
public void updateHq(boolean update) {
Rect viewArea = new Rect(getLeft(),getTop(),getRight(),getBottom());
if (viewArea.width() == mSize.x || viewArea.height() == mSize.y) {
// If the viewArea's size matches the unzoomed size, there is no need for an hq patch
if (mPatch != null) {
mPatch.setImageBitmap(null);
mPatch.invalidate();
}
} else {
final Point patchViewSize = new Point(viewArea.width(), viewArea.height());
final Rect patchArea = new Rect(0, 0, mParentSize.x, mParentSize.y);
// Intersect and test that there is an intersection
if (!patchArea.intersect(viewArea))
return;
// Offset patch area to be relative to the view top left
patchArea.offset(-viewArea.left, -viewArea.top);
boolean area_unchanged = patchArea.equals(mPatchArea) && patchViewSize.equals(mPatchViewSize);
// If being asked for the same area as last time and not because of an update then nothing to do
if (area_unchanged && !update)
return;
boolean completeRedraw = !(area_unchanged && update);
// Stop the drawing of previous patch if still going
if (mDrawPatch != null) {
mDrawPatch.cancel();
mDrawPatch = null;
}
// Create and add the image view if not already done
if (mPatch == null) {
mPatch = new OpaqueImageView(mContext);
mPatch.setScaleType(ImageView.ScaleType.MATRIX);
addView(mPatch);
mSearchView.bringToFront();
}
CancellableTaskDefinition<Void, Void> task;
if (completeRedraw)
task = getDrawPageTask(mPatchBm, patchViewSize.x, patchViewSize.y,
patchArea.left, patchArea.top,
patchArea.width(), patchArea.height());
else
task = getUpdatePageTask(mPatchBm, patchViewSize.x, patchViewSize.y,
patchArea.left, patchArea.top,
patchArea.width(), patchArea.height());
mDrawPatch = new CancellableAsyncTask<Void,Void>(task) {
public void onPostExecute(Void result) {
mPatchViewSize = patchViewSize;
mPatchArea = patchArea;
mPatch.setImageBitmap(mPatchBm);
mPatch.invalidate();
//requestLayout();
// Calling requestLayout here doesn't lead to a later call to layout. No idea
// why, but apparently others have run into the problem.
mPatch.layout(mPatchArea.left, mPatchArea.top, mPatchArea.right, mPatchArea.bottom);
}
};
mDrawPatch.execute();
}
}