Make the retrival of themed icon setting in background again
We get the themed icon setting through content provider through binder
call in background thread to unblock UI.
Video:
- https://drive.google.com/file/d/1d3SxhKTCJtWLtD1vri9qioKvGdZC42ne/view?usp=sharing&resourcekey=0-0r9WI28xLgMaQzRxkQJU_g
Bug: 189894912
Bug: 190564428
Test: Manual
Change-Id: I23321d227df9115839b6fcc9a0c7bb8eb10c1278
diff --git a/src/com/android/customization/model/themedicon/ThemedIconSectionController.java b/src/com/android/customization/model/themedicon/ThemedIconSectionController.java
index 20f3746..32fbfa8 100644
--- a/src/com/android/customization/model/themedicon/ThemedIconSectionController.java
+++ b/src/com/android/customization/model/themedicon/ThemedIconSectionController.java
@@ -25,12 +25,17 @@
import com.android.wallpaper.model.HubSectionController;
import com.android.wallpaper.model.WorkspaceViewModel;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
/** The {@link HubSectionController} for themed icon section. */
public class ThemedIconSectionController implements HubSectionController<ThemedIconSectionView> {
private final ThemedIconSwitchProvider mThemedIconOptionsProvider;
private final WorkspaceViewModel mWorkspaceViewModel;
+ private static ExecutorService sExecutorService = Executors.newSingleThreadExecutor();
+
public ThemedIconSectionController(ThemedIconSwitchProvider themedIconOptionsProvider,
WorkspaceViewModel workspaceViewModel) {
mThemedIconOptionsProvider = themedIconOptionsProvider;
@@ -48,8 +53,11 @@
(ThemedIconSectionView) LayoutInflater.from(context).inflate(
R.layout.themed_icon_section_view, /* root= */ null);
themedIconColorSectionView.setViewListener(this::onViewActivated);
- themedIconColorSectionView.getSwitch()
- .setChecked(mThemedIconOptionsProvider.fetchThemedIconEnabled());
+ sExecutorService.submit(() -> {
+ boolean themedIconEnabled = mThemedIconOptionsProvider.fetchThemedIconEnabled();
+ themedIconColorSectionView.post(() ->
+ themedIconColorSectionView.getSwitch().setChecked(themedIconEnabled));
+ });
return themedIconColorSectionView;
}