List of usage examples for android.graphics Rect intersects
public boolean intersects(int left, int top, int right, int bottom)
From source file:de.spiritcroc.modular_remote.Util.java
public static boolean hasContainerOverlappingFragments(Container container) { ModuleFragment[] fragments = container.getFragments(); ArrayList<Container> containedContainers = new ArrayList<>(); for (int i = 0; i < fragments.length; i++) { if (fragments[i] instanceof Container) { containedContainers.add((Container) fragments[i]); }//from w w w. jav a2s . c o m View currentView = fragments[i].getView(); if (currentView != null) { Rect currentRect = new Rect(currentView.getLeft(), currentView.getTop(), currentView.getRight(), currentView.getBottom()); for (int j = i + 1; j < fragments.length; j++) { View checkView = fragments[j].getView(); if (checkView != null && currentRect.intersects(checkView.getLeft(), checkView.getTop(), checkView.getRight(), checkView.getBottom())) { Log.i(LOG_TAG, fragments[i].getReadableName() + " overlaps with " + fragments[j].getReadableName()); return true; } } } } for (int i = 0; i < containedContainers.size(); i++) { if (hasContainerOverlappingFragments(containedContainers.get(i))) { return true; } } return false; }
From source file:com.example.nitish.welcomapp.widgetpt.PeriodicTableView.java
/** * Determine if a block is within the visible region. This is used to avoid useless drawing * operations./*from w w w . j a va 2 s .c o m*/ * * @param rect The block boundaries * @return True if the block is visible */ private boolean isBlockVisible(@NonNull Rect rect) { return rect.intersects(0, 0, getWidth(), getHeight()); }
From source file:com.facebook.litho.MountState.java
private static void mountViewIncrementally(View view, Rect localVisibleRect) { assertMainThread();/* ww w . j a v a 2 s . c o m*/ if (view instanceof LithoView) { final LithoView lithoView = (LithoView) view; lithoView.performIncrementalMount(localVisibleRect); } else if (view instanceof ViewGroup) { final ViewGroup viewGroup = (ViewGroup) view; for (int i = 0; i < viewGroup.getChildCount(); i++) { final View childView = viewGroup.getChildAt(i); if (localVisibleRect.intersects(childView.getLeft(), childView.getTop(), childView.getRight(), childView.getBottom())) { final Rect rect = ComponentsPools.acquireRect(); rect.set(Math.max(0, localVisibleRect.left - childView.getLeft()), Math.max(0, localVisibleRect.top - childView.getTop()), childView.getWidth() - Math.max(0, childView.getRight() - localVisibleRect.right), childView.getHeight() - Math.max(0, childView.getBottom() - localVisibleRect.bottom)); mountViewIncrementally(childView, rect); ComponentsPools.release(rect); } } } }