Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0327839f authored by Ching-Sung Li's avatar Ching-Sung Li Committed by Automerger Merge Worker
Browse files

Make the retrival of themed icon setting in background again am: b780674c

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/ThemePicker/+/14909665

Change-Id: I13097dced0da221675f7f3f1610a2e52f79104e7
parents 87337480 b780674c
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -25,12 +25,17 @@ import com.android.wallpaper.R;
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 @@ public class ThemedIconSectionController implements HubSectionController<ThemedI
                (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;
    }