Fix bug with some 1x1 widget previews

Bug: 8310045
diff --git a/src/com/android/launcher2/WidgetPreviewLoader.java b/src/com/android/launcher2/WidgetPreviewLoader.java
index 6c06e0f..68813d4 100644
--- a/src/com/android/launcher2/WidgetPreviewLoader.java
+++ b/src/com/android/launcher2/WidgetPreviewLoader.java
@@ -254,7 +254,7 @@
     }
 
     static class WidgetPreviewCacheDb extends SQLiteOpenHelper {
-        final static int DB_VERSION = 1;
+        final static int DB_VERSION = 2;
         final static String DB_NAME = "widgetpreviews.db";
         final static String TABLE_NAME = "shortcut_and_widget_previews";
         final static String COLUMN_NAME = "name";
@@ -280,7 +280,10 @@
 
         @Override
         public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
-            // We are still only on version 1
+            if (oldVersion != newVersion) {
+                // Delete all the records; they'll be repopulated as this is a cache
+                db.execSQL("DELETE FROM " + TABLE_NAME);
+            }
         }
     }
 
@@ -403,11 +406,6 @@
     }
 
     public Bitmap generateWidgetPreview(AppWidgetProviderInfo info, Bitmap preview) {
-        // should just read what's in the DB, and return it
-        // what's the method that's used?
-        // going to have to track down more or less how the DB stuff works
-        // when you long click on something, we're going to have to load the bigger preview at that
-        // time (worry about it later)
         int[] cellSpans = Launcher.getSpanForWidget(mLauncher, info);
         int maxWidth = maxWidthForWidgetPreview(cellSpans[0]);
         int maxHeight = maxHeightForWidgetPreview(cellSpans[1]);
@@ -526,7 +524,7 @@
             final Rect dest = mCachedAppWidgetPreviewDestRect.get();
             c.setBitmap(preview);
             src.set(0, 0, defaultPreview.getWidth(), defaultPreview.getHeight());
-            dest.set(x, 0, previewWidth, previewHeight);
+            dest.set(x, 0, x + previewWidth, previewHeight);
 
             Paint p = mCachedAppWidgetPreviewPaint.get();
             if (p == null) {