Launcher中定义的数据类型,根类ItemInfo,类结构图如下:
iteminfo这个类的代码如下:
/**
* Intent extra to store the profile. Format: UserHandle
*/
static final String EXTRA_PROFILE = "profile";
static final int NO_ID = -1;
/**
* The id in the settings database for this item
*/
public long id = NO_ID;
/**
* One of {@link LauncherSettings.Favorites#ITEM_TYPE_APPLICATION},
* {@link LauncherSettings.Favorites#ITEM_TYPE_SHORTCUT},
* {@link LauncherSettings.Favorites#ITEM_TYPE_FOLDER}, or
* {@link LauncherSettings.Favorites#ITEM_TYPE_APPWIDGET}.
*/
public int itemType;
/**
* The id of the container that holds this item. For the desktop, this will be
* {@link LauncherSettings.Favorites#CONTAINER_DESKTOP}. For the all applications folder it
* will be {@link #NO_ID} (since it is not stored in the settings DB). For user folders
* it will be the id of the folder.
*/
public long container = NO_ID;
/**
* Iindicates the screen in which the shortcut appears.
*/
public long screenId = -1;
/**
* Indicates the X position of the associated cell.
*/
public int cellX = -1;
/**
* Indicates the Y position of the associated cell.
*/
public int cellY = -1;
/**
* Indicates the X cell span.
*/
public int spanX = 1;
/**
* Indicates the Y cell span.
*/
int spanY = 1;
/**
* Indicates the minimum X cell span.
*/
public int minSpanX = 1;
/**
* Indicates the minimum Y cell span.
*/
public int minSpanY = 1;
/**
* Indicates that this item needs to be updated in the db
*/
public boolean requiresDbUpdate = false;
/**
* Title of the item
*/
CharSequence title;
/**
* Content description of the item.
*/
CharSequence contentDescription;
/**
* The position of the item in a drag-and-drop operation.
*/
int[] dropPos = null;
UserHandleCompat user;
/**
* M: The unread messages number of the item
*/
int unreadNum = 0;
ItemInfo() {
user = UserHandleCompat.myUserHandle();
}
ItemInfo(ItemInfo info) {
copyFrom(info);
// tempdebug:
LauncherModel.checkItemInfo(this);
}
主要定义了Launcher桌面上的小组件,包括图标、小插件和文件夹、以及图标的位置,大小、尺寸、itemType和container。
可以看到,itemType包括@link LauncherSettings.Favorites#ITEM_TYPE_APPLICATION},
* {@link LauncherSettings.Favorites#ITEM_TYPE_SHORTCUT},
* {@link LauncherSettings.Favorites#ITEM_TYPE_FOLDER}, or
* {@link LauncherSettings.Favorites#ITEM_TYPE_APPWIDGET
四种,container包括CONTAINER_DESKTOP和CONTAINER_HOTSEAT两种。
ITEM_TYPE_APPLICATION是应用程序,SHORTCUT是快捷方式图标,两者区别是SHORTCUT是在launcher上的,APPLICATION是在app列表中的,FOLDER未文件夹,APPWIDGET是Launcher上的小插件,CONTAINER_HOTSEAT是位于workspace下面的一排快捷图标,DESKTOP是workspace上的其它位置。