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

Commit b780674c authored by Ching-Sung Li's avatar Ching-Sung Li
Browse files

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
parent c395e58f
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;
    }