diff options
author | cretin45 <cretin45@gmail.com> | 2016-05-10 13:36:09 -0700 |
---|---|---|
committer | Ed Carrigan <cretin45@gmail.com> | 2016-05-10 14:55:22 -0700 |
commit | 70e60db0360adb5dcd4250c804572c41fa669e9c (patch) | |
tree | 781c001424479b754a3a99cc31368f19d6637016 /src/com/android/launcher3/LauncherModel.java | |
parent | 019b74b566d0589ada06a3ea6b6b11be829c106a (diff) | |
download | android_packages_apps_Trebuchet-70e60db0360adb5dcd4250c804572c41fa669e9c.tar.gz android_packages_apps_Trebuchet-70e60db0360adb5dcd4250c804572c41fa669e9c.tar.bz2 android_packages_apps_Trebuchet-70e60db0360adb5dcd4250c804572c41fa669e9c.zip |
Trebuchet: Index folder contents screen and cells on first load
Issue-id: CYNGNOS-2755
Change-Id: I260d1b098e7759a0134bc40f892b8783452c9528
(cherry picked from commit 499902463bb16aad036a57b9e02b34cb74548acf)
Diffstat (limited to 'src/com/android/launcher3/LauncherModel.java')
-rw-r--r-- | src/com/android/launcher3/LauncherModel.java | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java index 687e56563..5e2a64184 100644 --- a/src/com/android/launcher3/LauncherModel.java +++ b/src/com/android/launcher3/LauncherModel.java @@ -34,6 +34,7 @@ import android.content.pm.ProviderInfo; import android.content.pm.ResolveInfo; import android.database.Cursor; import android.graphics.Bitmap; +import android.graphics.Point; import android.net.Uri; import android.os.Environment; import android.os.Handler; @@ -2451,13 +2452,43 @@ public class LauncherModel extends BroadcastReceiver for (FolderInfo folder : sBgFolders) { Collections.sort(folder.contents, Folder.ITEM_POS_COMPARATOR); int pos = 0; + int needIndexing = 0; for (ShortcutInfo info : folder.contents) { - if (info.usingLowResIcon) { + if (info.usingLowResIcon && pos < FolderIcon.NUM_ITEMS_IN_PREVIEW) { info.updateIcon(mIconCache, false); } pos ++; - if (pos >= FolderIcon.NUM_ITEMS_IN_PREVIEW) { - break; + needIndexing += info.screenId + info.cellX + info.cellY; + } + // If all screenId, cellX, and cellY are 0, then we assume they were all null. + if (needIndexing == 0) { + synchronized (sBgLock) { + int curX = 0; + int curY = 0; + int folderScreenId = 0; + int folderCount = folder.contents.size(); + Point point = Utilities + .caluclateFolderContentDimensions(folderCount, countX, countY); + int maxX = point.x; + int maxY = point.y; + for (ShortcutInfo info : folder.contents) { + ItemInfo itemInfo = sBgItemsIdMap.get(info.id); + if (curY == maxY) { // New screen + curX = 0; + curY = 0; + folderScreenId++; + } + itemInfo.screenId = folderScreenId; + itemInfo.cellX = curX; + itemInfo.cellY = curY; + LauncherModel.updateItemInDatabase(context, itemInfo); + if (curX == maxX - 1) { + curX = 0; + curY++; + } else { + curX++; + } + } } } } |