本文整理匯總了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();
}
}