Projects >> android_packages_apps_Launcher2 >>fb12dc352e54b1330220f47fa746c5820e2c316c

Chunk
Conflicting content
            LayoutParams lp = (LayoutParams) v.getLayoutParams();
        int top = boundingRect.top;
        int left = boundingRect.left;
        for (View v: dup) {
        return success;
    }

<<<<<<< HEAD
    // This method looks in the specified direction to see if there is an additional view
    // immediately adjecent in that direction
    private boolean addViewInDirection(ArrayList views, Rect boundingRect, int[] direction,
            boolean[][] occupied) {
        boolean found = false;

        int childCount = mShortcutsAndWidgets.getChildCount();
        Rect r0 = new Rect(boundingRect);
        Rect r1 = new Rect();

        int deltaX = 0;
        int deltaY = 0;
        if (direction[1] < 0) {
            r0.set(r0.left, r0.top - 1, r0.right, r0.bottom);
            deltaY = -1;
        } else if (direction[1] > 0) {
            r0.set(r0.left, r0.top, r0.right, r0.bottom + 1);
            deltaY = 1;
        } else if (direction[0] < 0) {
            r0.set(r0.left - 1, r0.top, r0.right, r0.bottom);
            deltaX = -1;
        } else if (direction[0] > 0) {
            r0.set(r0.left, r0.top, r0.right + 1, r0.bottom);
            deltaX = 1;
        }

        for (int i = 0; i < childCount; i++) {
            View child = mShortcutsAndWidgets.getChildAt(i);
            if (views.contains(child)) continue;
            LayoutParams lp = (LayoutParams) child.getLayoutParams();

            r1.set(lp.tmpCellX, lp.tmpCellY, lp.tmpCellX + lp.cellHSpan, lp.tmpCellY + lp.cellVSpan);
            if (Rect.intersects(r0, r1)) {
                if (!lp.canReorder) {
                    return false;
                }
                boolean pushed = false;
                for (int x = lp.tmpCellX; x < lp.tmpCellX + lp.cellHSpan; x++) {
                    for (int y = lp.tmpCellY; y < lp.tmpCellY + lp.cellVSpan; y++) {
                        boolean inBounds = x - deltaX >= 0 && x -deltaX < mCountX
                                && y - deltaY >= 0 && y - deltaY < mCountY;
                        if (inBounds && occupied[x - deltaX][y - deltaY]) {
                            pushed = true;
                        }
                    }
                }
                if (pushed) {
                    views.add(child);
                    boundingRect.union(lp.tmpCellX, lp.tmpCellY, lp.tmpCellX + lp.cellHSpan,
                            lp.tmpCellY + lp.cellVSpan);
                    found = true;
                }
            }
        }
        return found;
    }

    private boolean pushViewsToTempLocation(ArrayList views, Rect rectOccupiedByPotentialDrop,
            int[] direction) {
        if (views.size() == 0) return true;


        boolean success = false;

        // We construct a rect which represents the entire group of views
        Rect boundingRect = null;
        for (View v: views) {
            LayoutParams lp = (LayoutParams) v.getLayoutParams();
            if (boundingRect == null) {
                boundingRect = new Rect(lp.tmpCellX, lp.tmpCellY, lp.tmpCellX + lp.cellHSpan,
                        lp.tmpCellY + lp.cellVSpan);
            } else {
                boundingRect.union(lp.tmpCellX, lp.tmpCellY, lp.tmpCellX + lp.cellHSpan,
                        lp.tmpCellY + lp.cellVSpan);
            }
        }

        ArrayList dup = (ArrayList) views.clone();
        while (addViewInDirection(dup, boundingRect, direction, mTmpOccupied)) {
        }
        for (View v: dup) {
            LayoutParams lp = (LayoutParams) v.getLayoutParams();
            markCellsForView(lp.tmpCellX, lp.tmpCellY, lp.cellHSpan,
                    lp.cellVSpan, mTmpOccupied, false); 
        }

        boolean[][] blockOccupied = new boolean[boundingRect.width()][boundingRect.height()];
            markCellsForView(lp.tmpCellX - left, lp.tmpCellY - top, lp.cellHSpan,
                    lp.cellVSpan, blockOccupied, true); 
        }

        markCellsForRect(rectOccupiedByPotentialDrop, mTmpOccupied, true);

        findNearestAreaInDirection(boundingRect.left, boundingRect.top, boundingRect.width(),
                boundingRect.height(), direction, mTmpOccupied, blockOccupied, mTempLocation);

        int deltaX = mTempLocation[0] - boundingRect.left;
        int deltaY = mTempLocation[1] - boundingRect.top;
        if (mTempLocation[0] >= 0 && mTempLocation[1] >= 0) {
            for (View v: dup) {
                LayoutParams lp = (LayoutParams) v.getLayoutParams();
                lp.tmpCellX += deltaX;
                lp.tmpCellY += deltaY;
            }
            success = true;
        }
        for (View v: dup) {
            LayoutParams lp = (LayoutParams) v.getLayoutParams();
            markCellsForView(lp.tmpCellX, lp.tmpCellY, lp.cellHSpan,
                    lp.cellVSpan, mTmpOccupied, true);
        }
        return success;
    }

=======
>>>>>>> a006e870ae23479ee8b4dc68089a7af591e26e7c
    private boolean addViewsToTempLocation(ArrayList views, Rect rectOccupiedByPotentialDrop,
            int[] direction) {
        if (views.size() == 0) return true;
Solution content
                        boolean inBounds = x - deltaX >= 0 && x -deltaX < mCountX
        return success;
    }

    // This method looks in the specified direction to see if there is an additional view
    // immediately adjecent in that direction
    private boolean addViewInDirection(ArrayList views, Rect boundingRect, int[] direction,
            boolean[][] occupied) {
        boolean found = false;

        int childCount = mShortcutsAndWidgets.getChildCount();
        Rect r0 = new Rect(boundingRect);
        Rect r1 = new Rect();

        int deltaX = 0;
        int deltaY = 0;
        if (direction[1] < 0) {
            r0.set(r0.left, r0.top - 1, r0.right, r0.bottom);
            deltaY = -1;
        } else if (direction[1] > 0) {
            r0.set(r0.left, r0.top, r0.right, r0.bottom + 1);
            deltaY = 1;
        } else if (direction[0] < 0) {
            r0.set(r0.left - 1, r0.top, r0.right, r0.bottom);
            deltaX = -1;
        } else if (direction[0] > 0) {
            r0.set(r0.left, r0.top, r0.right + 1, r0.bottom);
            deltaX = 1;
        }

        for (int i = 0; i < childCount; i++) {
            View child = mShortcutsAndWidgets.getChildAt(i);
            if (views.contains(child)) continue;
            LayoutParams lp = (LayoutParams) child.getLayoutParams();

            r1.set(lp.tmpCellX, lp.tmpCellY, lp.tmpCellX + lp.cellHSpan, lp.tmpCellY + lp.cellVSpan);
            if (Rect.intersects(r0, r1)) {
                if (!lp.canReorder) {
                    return false;
                }
                boolean pushed = false;
                for (int x = lp.tmpCellX; x < lp.tmpCellX + lp.cellHSpan; x++) {
                    for (int y = lp.tmpCellY; y < lp.tmpCellY + lp.cellVSpan; y++) {
                                && y - deltaY >= 0 && y - deltaY < mCountY;
                        if (inBounds && occupied[x - deltaX][y - deltaY]) {
                            pushed = true;
                        }
                    }
                }
                if (pushed) {
                    views.add(child);
                    boundingRect.union(lp.tmpCellX, lp.tmpCellY, lp.tmpCellX + lp.cellHSpan,
                            lp.tmpCellY + lp.cellVSpan);
                    found = true;
                }
            }
        }
        return found;
    }

    private boolean pushViewsToTempLocation(ArrayList views, Rect rectOccupiedByPotentialDrop,
            int[] direction) {
        if (views.size() == 0) return true;


        boolean success = false;

        // We construct a rect which represents the entire group of views
        Rect boundingRect = null;
        for (View v: views) {
            LayoutParams lp = (LayoutParams) v.getLayoutParams();
            if (boundingRect == null) {
                boundingRect = new Rect(lp.tmpCellX, lp.tmpCellY, lp.tmpCellX + lp.cellHSpan,
                        lp.tmpCellY + lp.cellVSpan);
            } else {
                boundingRect.union(lp.tmpCellX, lp.tmpCellY, lp.tmpCellX + lp.cellHSpan,
                        lp.tmpCellY + lp.cellVSpan);
            }
        }

        ArrayList dup = (ArrayList) views.clone();
        while (addViewInDirection(dup, boundingRect, direction, mTmpOccupied)) {
        }
        for (View v: dup) {
            LayoutParams lp = (LayoutParams) v.getLayoutParams();
            markCellsForView(lp.tmpCellX, lp.tmpCellY, lp.cellHSpan,
                    lp.cellVSpan, mTmpOccupied, false); 
        }

        boolean[][] blockOccupied = new boolean[boundingRect.width()][boundingRect.height()];
        int top = boundingRect.top;
        int left = boundingRect.left;
        for (View v: dup) {
            LayoutParams lp = (LayoutParams) v.getLayoutParams();
            markCellsForView(lp.tmpCellX - left, lp.tmpCellY - top, lp.cellHSpan,
                    lp.cellVSpan, blockOccupied, true); 
        }

        markCellsForRect(rectOccupiedByPotentialDrop, mTmpOccupied, true);

        findNearestAreaInDirection(boundingRect.left, boundingRect.top, boundingRect.width(),
                boundingRect.height(), direction, mTmpOccupied, blockOccupied, mTempLocation);

        int deltaX = mTempLocation[0] - boundingRect.left;
        int deltaY = mTempLocation[1] - boundingRect.top;
        if (mTempLocation[0] >= 0 && mTempLocation[1] >= 0) {
            for (View v: dup) {
                LayoutParams lp = (LayoutParams) v.getLayoutParams();
                lp.tmpCellX += deltaX;
                lp.tmpCellY += deltaY;
            }
            success = true;
        }
        for (View v: dup) {
            LayoutParams lp = (LayoutParams) v.getLayoutParams();
            markCellsForView(lp.tmpCellX, lp.tmpCellY, lp.cellHSpan,
                    lp.cellVSpan, mTmpOccupied, true);
        }
        return success;
    }

    private boolean addViewsToTempLocation(ArrayList views, Rect rectOccupiedByPotentialDrop,
            int[] direction) {
        if (views.size() == 0) return true;
File
CellLayout.java
Developer's decision
Version 1
Kind of conflict
Comment
Method declaration