diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2018-10-04 15:11:00 -0700 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2018-10-08 14:52:39 -0700 |
commit | efb7e84242e174f7bb1a994889742820d229935d (patch) | |
tree | cd2b22e3ec324ebb0f7589df0c21ea7e03c89064 /src/com/android/launcher3/LauncherModel.java | |
parent | f307b6032e708ee22b6e477e6c81ba07eecd4d4f (diff) | |
download | android_packages_apps_Trebuchet-efb7e84242e174f7bb1a994889742820d229935d.tar.gz android_packages_apps_Trebuchet-efb7e84242e174f7bb1a994889742820d229935d.tar.bz2 android_packages_apps_Trebuchet-efb7e84242e174f7bb1a994889742820d229935d.zip |
Converting long item IDs to int
> Items ids were already being typecasted to int when being bound on the UI
> Using a consistent type allow better use of platform data-structures
> Adding IntArray and IntSet as a replacement for various Collection classes
Change-Id: Id3c650ed2420c2bfca3bd7671d2b705b56112371
Diffstat (limited to 'src/com/android/launcher3/LauncherModel.java')
-rw-r--r-- | src/com/android/launcher3/LauncherModel.java | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java index 5424d97bf..d571cf47d 100644 --- a/src/com/android/launcher3/LauncherModel.java +++ b/src/com/android/launcher3/LauncherModel.java @@ -55,6 +55,7 @@ import com.android.launcher3.provider.LauncherDbUtils; import com.android.launcher3.shortcuts.DeepShortcutManager; import com.android.launcher3.shortcuts.ShortcutInfoCompat; import com.android.launcher3.util.ComponentKey; +import com.android.launcher3.util.IntArray; import com.android.launcher3.util.ItemInfoMatcher; import com.android.launcher3.util.MultiHashMap; import com.android.launcher3.util.PackageUserKey; @@ -143,15 +144,14 @@ public class LauncherModel extends BroadcastReceiver public void clearPendingBinds(); public void startBinding(); public void bindItems(List<ItemInfo> shortcuts, boolean forceAnimateIcons); - public void bindScreens(ArrayList<Long> orderedScreenIds); + public void bindScreens(IntArray orderedScreenIds); public void finishFirstPageBind(ViewOnDrawExecutor executor); public void finishBindingItems(int currentScreen); public void bindAllApplications(ArrayList<AppInfo> apps); public void bindAppsAddedOrUpdated(ArrayList<AppInfo> apps); public void preAddApps(); - public void bindAppsAdded(ArrayList<Long> newScreens, - ArrayList<ItemInfo> addNotAnimated, - ArrayList<ItemInfo> addAnimated); + public void bindAppsAdded(IntArray newScreens, + ArrayList<ItemInfo> addNotAnimated, ArrayList<ItemInfo> addAnimated); public void bindPromiseAppProgressUpdated(PromiseAppInfo app); public void bindShortcutsChanged(ArrayList<ShortcutInfo> updated, UserHandle user); public void bindWidgetsRestored(ArrayList<LauncherAppWidgetInfo> widgets); @@ -211,7 +211,7 @@ public class LauncherModel extends BroadcastReceiver } static void checkItemInfoLocked( - final long itemId, final ItemInfo item, StackTraceElement[] stackTrace) { + final int itemId, final ItemInfo item, StackTraceElement[] stackTrace) { if (com.android.launcher3.Utilities.IS_RUNNING_IN_TEST_HARNESS && com.android.launcher3.Utilities.IS_DEBUG_DEVICE) { android.util.Log.d("b/117332845", @@ -255,7 +255,7 @@ public class LauncherModel extends BroadcastReceiver static void checkItemInfo(final ItemInfo item) { final StackTraceElement[] stackTrace = new Throwable().getStackTrace(); - final long itemId = item.id; + final int itemId = item.id; Runnable r = new Runnable() { public void run() { synchronized (sBgDataModel) { @@ -270,17 +270,16 @@ public class LauncherModel extends BroadcastReceiver * Update the order of the workspace screens in the database. The array list contains * a list of screen ids in the order that they should appear. */ - public static void updateWorkspaceScreenOrder(Context context, final ArrayList<Long> screens) { - final ArrayList<Long> screensCopy = new ArrayList<Long>(screens); + public static void updateWorkspaceScreenOrder(Context context, IntArray screens) { final ContentResolver cr = context.getContentResolver(); final Uri uri = LauncherSettings.WorkspaceScreens.CONTENT_URI; - // Remove any negative screen ids -- these aren't persisted - Iterator<Long> iter = screensCopy.iterator(); - while (iter.hasNext()) { - long id = iter.next(); - if (id < 0) { - iter.remove(); + // Create a copy with only non-negative values + final IntArray screensCopy = new IntArray(); + for (int i = 0; i < screens.size(); i++) { + int id = screens.get(i); + if (id >= 0) { + screensCopy.add(id); } } @@ -293,7 +292,7 @@ public class LauncherModel extends BroadcastReceiver int count = screensCopy.size(); for (int i = 0; i < count; i++) { ContentValues v = new ContentValues(); - long screenId = screensCopy.get(i); + int screenId = screensCopy.get(i); v.put(LauncherSettings.WorkspaceScreens._ID, screenId); v.put(LauncherSettings.WorkspaceScreens.SCREEN_RANK, i); ops.add(ContentProviderOperation.newInsert(uri).withValues(v).build()); @@ -516,7 +515,7 @@ public class LauncherModel extends BroadcastReceiver /** * Loads the workspace screen ids in an ordered list. */ - public static ArrayList<Long> loadWorkspaceScreensDb(Context context) { + public static IntArray loadWorkspaceScreensDb(Context context) { final ContentResolver contentResolver = context.getContentResolver(); final Uri screensUri = LauncherSettings.WorkspaceScreens.CONTENT_URI; |