summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher2/LauncherModel.java
diff options
context:
space:
mode:
authorJoe Onorato <joeo@google.com>2011-02-08 17:26:11 -0800
committerJoe Onorato <joeo@google.com>2011-02-10 11:41:57 -0800
commit17a8922e2ab2ad599df3750d398a095473ccd1b4 (patch)
tree41edae60e7878803880c832fe8937e7fa7712199 /src/com/android/launcher2/LauncherModel.java
parent43e21ac570286cc647ae2458c1a4e640882affcb (diff)
downloadandroid_packages_apps_Trebuchet-17a8922e2ab2ad599df3750d398a095473ccd1b4.tar.gz
android_packages_apps_Trebuchet-17a8922e2ab2ad599df3750d398a095473ccd1b4.tar.bz2
android_packages_apps_Trebuchet-17a8922e2ab2ad599df3750d398a095473ccd1b4.zip
Make the icon caching for SD cards actually work.
We need to save the icon *after* we have loaded all the other information about it. Also, add a check that if apps on SD aren't possible, don't even bother saving the icon. This saves ~200 ms on each run of the loader. Bug: 3240615 Change-Id: Idc2329a868ab970b51deec341ffa8a47a344e110
Diffstat (limited to 'src/com/android/launcher2/LauncherModel.java')
-rw-r--r--src/com/android/launcher2/LauncherModel.java18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/com/android/launcher2/LauncherModel.java b/src/com/android/launcher2/LauncherModel.java
index 005273749..23641743f 100644
--- a/src/com/android/launcher2/LauncherModel.java
+++ b/src/com/android/launcher2/LauncherModel.java
@@ -44,6 +44,7 @@ import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
+import android.os.Environment;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Parcelable;
@@ -65,6 +66,7 @@ public class LauncherModel extends BroadcastReceiver {
static final String TAG = "Launcher.Model";
private static final int ITEMS_CHUNK = 6; // batch size for the workspace icons
+ private final boolean mAppsCanBeOnExternalStorage;
private int mBatchSize; // 0 is all apps at once
private int mAllAppsLoadDelay; // milliseconds between batches
@@ -115,6 +117,7 @@ public class LauncherModel extends BroadcastReceiver {
}
LauncherModel(LauncherApplication app, IconCache iconCache) {
+ mAppsCanBeOnExternalStorage = !Environment.isExternalStorageEmulated();
mApp = app;
mAllAppsList = new AllAppsList(iconCache);
mIconCache = iconCache;
@@ -794,8 +797,6 @@ public class LauncherModel extends BroadcastReceiver {
}
if (info != null) {
- updateSavedIcon(context, info, c, iconIndex);
-
info.intent = intent;
info.id = c.getLong(idIndex);
container = c.getInt(containerIndex);
@@ -820,6 +821,10 @@ public class LauncherModel extends BroadcastReceiver {
folderInfo.add(info);
break;
}
+
+ // now that we've loaded everthing re-save it with the
+ // icon in case it disappears somehow.
+ updateSavedIcon(context, info, c, iconIndex);
} else {
// Failed to load the shortcut, probably because the
// activity manager couldn't resolve it (maybe the app
@@ -1669,6 +1674,10 @@ public class LauncherModel extends BroadcastReceiver {
}
void updateSavedIcon(Context context, ShortcutInfo info, Cursor c, int iconIndex) {
+ // If apps can't be on SD, don't even bother.
+ if (!mAppsCanBeOnExternalStorage) {
+ return;
+ }
// If this icon doesn't have a custom icon, check to see
// what's stored in the DB, and if it doesn't match what
// we're going to show, store what we are going to show back
@@ -1691,9 +1700,8 @@ public class LauncherModel extends BroadcastReceiver {
}
if (needSave) {
Log.d(TAG, "going to save icon bitmap for info=" + info);
- // This is slower than is ideal, but this only happens either
- // after the froyo OTA or when the app is updated with a new
- // icon.
+ // This is slower than is ideal, but this only happens once
+ // or when the app is updated with a new icon.
updateItemInDatabase(context, info);
}
}