Example usage for android.graphics Region union

List of usage examples for android.graphics Region union

Introduction

In this page you can find the example usage for android.graphics Region union.

Prototype

public final boolean union(Rect r) 

Source Link

Usage

From source file:org.androfarsh.widget.DragGridLayout.java

private Set<Node> findNodesUnder(Node dragNode, Set<Cell> hoveredCells) {
    if ((dragNode == null) || hoveredCells.isEmpty()) {
        return Collections.emptySet();
    }//from   www.j a v  a  2  s . com

    final Rect tmpRect = new Rect();
    final Region tmpRegion = new Region();
    for (Cell cell : hoveredCells) {
        tmpRegion.union(cell.rect);
    }

    Set<Node> nodes = new HashSet<Node>();
    int childCount = getChildCount();
    for (int i = 0; i < childCount; ++i) {
        View child = getChildAt(i);
        if ((child == mRootView) || (child == dragNode.view)) {
            continue;
        }

        requestCurrentRect(tmpRect, child);
        mTmpRegion.set(tmpRegion);
        mTmpRegion.op(tmpRect, Op.INTERSECT);

        if (!mTmpRegion.isEmpty()) {
            nodes.add(new Node(child, tmpRect));
        }
    }
    return nodes;
}