summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/model/LoaderCursor.java
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2017-01-11 14:33:38 -0800
committerSunny Goyal <sunnygoyal@google.com>2017-01-13 10:38:41 -0800
commitc1ad0ce8aebb76794fdd8b44a0bf50435f0cf39a (patch)
tree7c7d1a7ff0d6418f1e6948f882ef8c19da9e4518 /src/com/android/launcher3/model/LoaderCursor.java
parent761d49a7a1c51de256a1b0e6181e9ad46c9347e1 (diff)
downloadandroid_packages_apps_Trebuchet-c1ad0ce8aebb76794fdd8b44a0bf50435f0cf39a.tar.gz
android_packages_apps_Trebuchet-c1ad0ce8aebb76794fdd8b44a0bf50435f0cf39a.tar.bz2
android_packages_apps_Trebuchet-c1ad0ce8aebb76794fdd8b44a0bf50435f0cf39a.zip
Only marking items not already restored as restore
> Moving the restore property to LoaderCursor Bug: 34123089 Change-Id: I1f992ef086d65e0b3cf18d3b2cf37a4f254c97d2
Diffstat (limited to 'src/com/android/launcher3/model/LoaderCursor.java')
-rw-r--r--src/com/android/launcher3/model/LoaderCursor.java23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/com/android/launcher3/model/LoaderCursor.java b/src/com/android/launcher3/model/LoaderCursor.java
index b271e6fbd..711be37b4 100644
--- a/src/com/android/launcher3/model/LoaderCursor.java
+++ b/src/com/android/launcher3/model/LoaderCursor.java
@@ -83,6 +83,7 @@ public class LoaderCursor extends CursorWrapper {
private final int cellXIndex;
private final int cellYIndex;
private final int profileIdIndex;
+ private final int restoredIndex;
// Properties loaded per iteration
public long serialNumber;
@@ -90,6 +91,7 @@ public class LoaderCursor extends CursorWrapper {
public long id;
public long container;
public int itemType;
+ public int restoreFlag;
public LoaderCursor(Cursor c, LauncherAppState app) {
super(c);
@@ -111,6 +113,7 @@ public class LoaderCursor extends CursorWrapper {
cellXIndex = getColumnIndexOrThrow(LauncherSettings.Favorites.CELLX);
cellYIndex = getColumnIndexOrThrow(LauncherSettings.Favorites.CELLY);
profileIdIndex = getColumnIndexOrThrow(LauncherSettings.Favorites.PROFILE_ID);
+ restoredIndex = getColumnIndexOrThrow(LauncherSettings.Favorites.RESTORED);
}
@Override
@@ -123,6 +126,7 @@ public class LoaderCursor extends CursorWrapper {
id = getLong(idIndex);
serialNumber = getInt(profileIdIndex);
user = allUsers.get(serialNumber);
+ restoreFlag = getInt(restoredIndex);
}
return result;
}
@@ -185,7 +189,7 @@ public class LoaderCursor extends CursorWrapper {
* Make an ShortcutInfo object for a restored application or shortcut item that points
* to a package that is not yet installed on the system.
*/
- public ShortcutInfo getRestoredItemInfo(Intent intent, int promiseType) {
+ public ShortcutInfo getRestoredItemInfo(Intent intent) {
final ShortcutInfo info = new ShortcutInfo();
info.user = user;
info.intent = intent;
@@ -196,22 +200,22 @@ public class LoaderCursor extends CursorWrapper {
mIconCache.getTitleAndIcon(info, false /* useLowResIcon */);
}
- if ((promiseType & ShortcutInfo.FLAG_RESTORED_ICON) != 0) {
+ if (hasRestoreFlag(ShortcutInfo.FLAG_RESTORED_ICON)) {
String title = getTitle();
if (!TextUtils.isEmpty(title)) {
info.title = Utilities.trim(title);
}
- } else if ((promiseType & ShortcutInfo.FLAG_AUTOINTALL_ICON) != 0) {
+ } else if (hasRestoreFlag(ShortcutInfo.FLAG_AUTOINTALL_ICON)) {
if (TextUtils.isEmpty(info.title)) {
info.title = getTitle();
}
} else {
- throw new InvalidParameterException("Invalid restoreType " + promiseType);
+ throw new InvalidParameterException("Invalid restoreType " + restoreFlag);
}
info.contentDescription = mUserManager.getBadgedLabelForUser(info.title, info.user);
info.itemType = itemType;
- info.status = promiseType;
+ info.status = restoreFlag;
return info;
}
@@ -305,7 +309,14 @@ public class LoaderCursor extends CursorWrapper {
* Marks the current item as restored
*/
public void markRestored() {
- restoredRows.add(id);
+ if (restoreFlag != 0) {
+ restoredRows.add(id);
+ restoreFlag = 0;
+ }
+ }
+
+ public boolean hasRestoreFlag(int flagMask) {
+ return (restoreFlag & flagMask) != 0;
}
public void commitRestoredItems() {