Loading src/com/android/launcher3/WidgetPreviewLoader.java +22 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ import android.appwidget.AppWidgetProviderInfo; import android.content.ComponentName; import android.content.ContentValues; import android.content.Context; import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.res.Resources; Loading Loading @@ -100,6 +101,7 @@ class BitmapFactoryOptionsCache extends SoftReferenceThreadLocal<BitmapFactory.O public class WidgetPreviewLoader { static final String TAG = "WidgetPreviewLoader"; static final String ANDROID_INCREMENTAL_VERSION_NAME_KEY = "android.incremental.version"; private int mPreviewBitmapWidth; private int mPreviewBitmapHeight; Loading Loading @@ -147,6 +149,20 @@ public class WidgetPreviewLoader { mDb = app.getWidgetPreviewCacheDb(); mLoadedPreviews = new HashMap<String, WeakReference<Bitmap>>(); mUnusedBitmaps = new ArrayList<SoftReference<Bitmap>>(); SharedPreferences sp = context.getSharedPreferences( LauncherAppState.getSharedPreferencesKey(), Context.MODE_PRIVATE); final String lastVersionName = sp.getString(ANDROID_INCREMENTAL_VERSION_NAME_KEY, null); final String versionName = android.os.Build.VERSION.INCREMENTAL; if (!versionName.equals(lastVersionName)) { // clear all the previews whenever the system version changes, to ensure that previews // are up-to-date for any apps that might have been updated with the system clearDb(); SharedPreferences.Editor editor = sp.edit(); editor.putString(ANDROID_INCREMENTAL_VERSION_NAME_KEY, versionName); editor.commit(); } } public void setPreviewSize(int previewWidth, int previewHeight, Loading Loading @@ -334,6 +350,12 @@ public class WidgetPreviewLoader { db.insert(CacheDb.TABLE_NAME, null, values); } private void clearDb() { SQLiteDatabase db = mDb.getWritableDatabase(); // Delete everything db.delete(CacheDb.TABLE_NAME, null, null); } public static void removePackageFromDb(final CacheDb cacheDb, final String packageName) { synchronized(sInvalidPackages) { sInvalidPackages.add(packageName); Loading Loading
src/com/android/launcher3/WidgetPreviewLoader.java +22 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ import android.appwidget.AppWidgetProviderInfo; import android.content.ComponentName; import android.content.ContentValues; import android.content.Context; import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.res.Resources; Loading Loading @@ -100,6 +101,7 @@ class BitmapFactoryOptionsCache extends SoftReferenceThreadLocal<BitmapFactory.O public class WidgetPreviewLoader { static final String TAG = "WidgetPreviewLoader"; static final String ANDROID_INCREMENTAL_VERSION_NAME_KEY = "android.incremental.version"; private int mPreviewBitmapWidth; private int mPreviewBitmapHeight; Loading Loading @@ -147,6 +149,20 @@ public class WidgetPreviewLoader { mDb = app.getWidgetPreviewCacheDb(); mLoadedPreviews = new HashMap<String, WeakReference<Bitmap>>(); mUnusedBitmaps = new ArrayList<SoftReference<Bitmap>>(); SharedPreferences sp = context.getSharedPreferences( LauncherAppState.getSharedPreferencesKey(), Context.MODE_PRIVATE); final String lastVersionName = sp.getString(ANDROID_INCREMENTAL_VERSION_NAME_KEY, null); final String versionName = android.os.Build.VERSION.INCREMENTAL; if (!versionName.equals(lastVersionName)) { // clear all the previews whenever the system version changes, to ensure that previews // are up-to-date for any apps that might have been updated with the system clearDb(); SharedPreferences.Editor editor = sp.edit(); editor.putString(ANDROID_INCREMENTAL_VERSION_NAME_KEY, versionName); editor.commit(); } } public void setPreviewSize(int previewWidth, int previewHeight, Loading Loading @@ -334,6 +350,12 @@ public class WidgetPreviewLoader { db.insert(CacheDb.TABLE_NAME, null, values); } private void clearDb() { SQLiteDatabase db = mDb.getWritableDatabase(); // Delete everything db.delete(CacheDb.TABLE_NAME, null, null); } public static void removePackageFromDb(final CacheDb cacheDb, final String packageName) { synchronized(sInvalidPackages) { sInvalidPackages.add(packageName); Loading