Example usage for android.content.pm ShortcutInfo equals

List of usage examples for android.content.pm ShortcutInfo equals

Introduction

In this page you can find the example usage for android.content.pm ShortcutInfo equals.

Prototype

public boolean equals(Object obj) 

Source Link

Document

Indicates whether some other object is "equal to" this one.

Usage

From source file:com.aliyun.homeshell.Folder.java

private void insertItem(ShortcutInfo item) {
    // TODO Auto-generated method stub
    setupContentForNumItems(getItemCount() + 1);
    int xCount = mContent.getCountX();
    int yCount = mContent.getCountY();
    int currentPos = item.screen * xCount * yCount + item.cellY * xCount + item.cellX;
    int maxItemsPerPage = getMaxItemsCountPerPage();
    for (ShortcutInfo si : mInfo.contents) {
        int pos = si.screen * xCount * yCount + si.cellY * xCount + si.cellX;
        if (si == item) {
            createAndAddShortcut(si);/*from  w  ww  . j  a v  a2  s  .  c o m*/
            LauncherModel.addOrMoveItemInDatabase(mLauncher, si, mInfo.id, si.screen, si.cellX, si.cellY);
            continue;
        }
        if (pos >= currentPos || (pos == currentPos && !item.equals(si))) {
            View view = mContentList.get(si.screen).getChildAt(si.cellX, si.cellY);
            mContentList.get(si.screen).removeView(view);
            si.screen = (pos + 1) / maxItemsPerPage;
            si.cellX = ((pos + 1) % maxItemsPerPage) % xCount;
            si.cellY = ((pos + 1) % maxItemsPerPage) / xCount;
            if (view == null) {
                Log.e(TAG, "the view of " + si.title + "should not be null,but now is null");
                createAndAddShortcut(si);
            } else {
                CellLayout.LayoutParams lp = new CellLayout.LayoutParams(si.cellX, si.cellY, si.spanX,
                        si.spanY);
                boolean insert = false;
                mContentList.get(si.screen).addViewToCellLayout(view, insert ? 0 : -1, (int) si.id, lp, true);
            }
            LauncherModel.addOrMoveItemInDatabase(mLauncher, si, mInfo.id, si.screen, si.cellX, si.cellY);
        }
    }
}