synchronized void removeItem(Context context, Iterable<? extends ItemInfo> items) { for (ItemInfo item : items) { switch (item.itemType) { case LauncherSettings.Favorites.ITEM_TYPE_FOLDER: folders.remove(item.id); workspaceItems.remove(item); break; case LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT: { // Decrement pinned shortcut count ShortcutKey pinnedShortcut = ShortcutKey.fromItemInfo(item); MutableInt count = pinnedShortcutCounts.get(pinnedShortcut); if ((count == null || --count.value == 0) && !InstallShortcutReceiver.getPendingShortcuts(context) .contains(pinnedShortcut)) { DeepShortcutManager.getInstance(context).unpinShortcut(pinnedShortcut); } // Fall through. } case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION: case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT: workspaceItems.remove(item); break; case LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET: case LauncherSettings.Favorites.ITEM_TYPE_CUSTOM_APPWIDGET: appWidgets.remove(item); break; } itemsIdMap.remove(item.id); } }
/** * Decrement the count for the given pinned shortcut, unpinning it if the count becomes 0. */ private static void decrementPinnedShortcutCount(final ShortcutKey pinnedShortcut) { synchronized (sBgLock) { MutableInt count = sBgPinnedShortcutCounts.get(pinnedShortcut); if (count == null || --count.value == 0) { LauncherAppState.getInstance().getShortcutManager().unpinShortcut(pinnedShortcut); } } }
private void addChannel(Channel channel) { mChannels.add(channel); String inputId = channel.getInputId(); MutableInt count = mChannelCountMap.get(inputId); if (count == null) { mChannelCountMap.put(inputId, new MutableInt(1)); } else { count.value++; } }
/** * Returns the total channel count for a given input. * * @param inputId The ID of the input. */ public int getChannelCountForInput(String inputId) { MutableInt count = mChannelCountMap.get(inputId); return count == null ? 0 : count.value; }