Update the thumbnail in the wallpaper section to the selected wallpaper.

Bug: 149716966
Change-Id: I944c8308730866f7dc47659a908184e59c09b85b
diff --git a/src/com/android/wallpaper/picker/individual/IndividualPickerFragment.java b/src/com/android/wallpaper/picker/individual/IndividualPickerFragment.java
index f0888a5..297c06a 100755
--- a/src/com/android/wallpaper/picker/individual/IndividualPickerFragment.java
+++ b/src/com/android/wallpaper/picker/individual/IndividualPickerFragment.java
@@ -122,6 +122,21 @@
      */
     private static final boolean TEMP_BOTTOM_ACTION_BAR_FEATURE = false;
 
+    /**
+     * An interface for updating the thumbnail with the specific wallpaper.
+     */
+    public interface ThumbnailUpdater {
+        /**
+         * Updates the thumbnail with the specific wallpaper.
+         */
+        void updateThumbnail(WallpaperInfo wallpaperInfo);
+
+        /**
+         * Restores to the thumbnails of the wallpapers which were applied.
+         */
+        void restoreThumbnails();
+    }
+
     WallpaperPreferences mWallpaperPreferences;
     WallpaperChangedNotifier mWallpaperChangedNotifier;
     RecyclerView mImageGrid;
@@ -398,6 +413,7 @@
         if (TEMP_BOTTOM_ACTION_BAR_FEATURE) {
             mBottomActionBar.setVisibility(View.GONE);
             mBottomActionBar.clearActionClickListeners();
+            restoreThumbnails();
         }
         super.onDestroyView();
     }
@@ -738,6 +754,20 @@
         }
     }
 
+    private void updateThumbnail(WallpaperInfo wallpaperInfo) {
+        ThumbnailUpdater thumbnailUpdater = (ThumbnailUpdater) getParentFragment();
+        if (thumbnailUpdater != null) {
+            thumbnailUpdater.updateThumbnail(wallpaperInfo);
+        }
+    }
+
+    private void restoreThumbnails() {
+        ThumbnailUpdater thumbnailUpdater = (ThumbnailUpdater) getParentFragment();
+        if (thumbnailUpdater != null) {
+            thumbnailUpdater.restoreThumbnails();
+        }
+    }
+
     /**
      * ViewHolder subclass for "daily refresh" tile in the RecyclerView, only shown if rotation is
      * enabled for this category.
@@ -1072,6 +1102,11 @@
             if (wallpaperId != null && wallpaperId.equals(prefs.getHomeWallpaperRemoteId())) {
                 mSelectedAdapterPosition = position;
             }
+
+            if (TEMP_BOTTOM_ACTION_BAR_FEATURE) {
+                holder.itemView.findViewById(R.id.tile)
+                        .setOnClickListener(view -> updateThumbnail(wallpaper));
+            }
         }
     }
 }