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

Commit 5589583d authored by Sunny Goyal's avatar Sunny Goyal Committed by Android (Google) Code Review
Browse files

Merge "Fixing bug when model was not reflected properly on the UI. If launcher...

Merge "Fixing bug when model was not reflected properly on the UI. If launcher submits a job, and then reloads before the job is executed, the correct model is not reflected on the Launcher. In that case, we simply rebind the launcher" into ub-launcher3-master
parents f7ccc82e 605bcf33
Loading
Loading
Loading
Loading
+11 −6
Original line number Diff line number Diff line
@@ -400,6 +400,15 @@ public class Launcher extends BaseActivity
            getStateManager().reapplyState();

            // TODO: We can probably avoid rebind when only screen size changed.
            rebindModel();
        }

        mOldConfig.setTo(newConfig);
        super.onConfigurationChanged(newConfig);
    }

    @Override
    public void rebindModel() {
        int currentPage = mWorkspace.getNextPage();
        if (mModel.startLoader(currentPage)) {
            mWorkspace.setCurrentPage(currentPage);
@@ -407,10 +416,6 @@ public class Launcher extends BaseActivity
        }
    }

        mOldConfig.setTo(newConfig);
        super.onConfigurationChanged(newConfig);
    }

    private void initDeviceProfile(InvariantDeviceProfile idp) {
        // Load configuration-specific DeviceProfile
        mDeviceProfile = idp.getDeviceProfile(this);
@@ -420,7 +425,7 @@ public class Launcher extends BaseActivity
            display.getSize(mwSize);
            mDeviceProfile = mDeviceProfile.getMultiWindowProfile(this, mwSize);
        }
        mModelWriter = mModel.getWriter(mDeviceProfile.isVerticalBarLayout());
        mModelWriter = mModel.getWriter(mDeviceProfile.isVerticalBarLayout(), true);
    }

    public RotationHelper getRotationHelper() {
+5 −2
Original line number Diff line number Diff line
@@ -135,6 +135,8 @@ public class LauncherModel extends BroadcastReceiver
    };

    public interface Callbacks {
        public void rebindModel();

        public int getCurrentWorkspaceScreen();
        public void clearPendingBinds();
        public void startBinding();
@@ -196,8 +198,9 @@ public class LauncherModel extends BroadcastReceiver
        enqueueModelUpdateTask(new AddWorkspaceItemsTask(itemList));
    }

    public ModelWriter getWriter(boolean hasVerticalHotseat) {
        return new ModelWriter(mApp.getContext(), sBgDataModel, hasVerticalHotseat);
    public ModelWriter getWriter(boolean hasVerticalHotseat, boolean verifyChanges) {
        return new ModelWriter(mApp.getContext(), this, sBgDataModel,
                hasVerticalHotseat, verifyChanges);
    }

    static void checkItemInfoLocked(
+7 −9
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@ import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.util.ItemInfoMatcher;
import com.android.launcher3.util.MultiHashMap;
import com.android.launcher3.widget.WidgetListRowEntry;
import com.android.launcher3.widget.WidgetsListAdapter;

import java.util.ArrayList;
import java.util.concurrent.Executor;
@@ -80,19 +79,18 @@ public abstract class BaseModelUpdateTask implements ModelUpdateTask {
     */
    public final void scheduleCallbackTask(final CallbackTask task) {
        final Callbacks callbacks = mModel.getCallback();
        mUiExecutor.execute(new Runnable() {
            public void run() {
        mUiExecutor.execute(() -> {
            Callbacks cb = mModel.getCallback();
            if (callbacks == cb && cb != null) {
                task.execute(callbacks);
            }
            }
        });
    }

    public ModelWriter getModelWriter() {
        // Updates from model task, do not deal with icon position in hotseat.
        return mModel.getWriter(false /* hasVerticalHotseat */);
        // Updates from model task, do not deal with icon position in hotseat. Also no need to
        // verify changes as the ModelTasks always push the changes to callbacks
        return mModel.getWriter(false /* hasVerticalHotseat */, false /* verifyChanges */);
    }


+5 −0
Original line number Diff line number Diff line
@@ -105,6 +105,11 @@ public class BgDataModel {
     */
    public final WidgetsModel widgetsModel = new WidgetsModel();

    /**
     * Id when the model was last bound
     */
    public int lastBindId = 0;

    /**
     * Clears all the data
     */
+1 −2
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherAppWidgetInfo;
import com.android.launcher3.LauncherModel;
import com.android.launcher3.LauncherModel.Callbacks;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.MainThreadExecutor;
@@ -37,7 +36,6 @@ import com.android.launcher3.util.LooperIdleLock;
import com.android.launcher3.util.MultiHashMap;
import com.android.launcher3.util.ViewOnDrawExecutor;
import com.android.launcher3.widget.WidgetListRowEntry;
import com.android.launcher3.widget.WidgetsListAdapter;

import java.lang.ref.WeakReference;
import java.util.ArrayList;
@@ -100,6 +98,7 @@ public class LoaderResults {
            workspaceItems.addAll(mBgDataModel.workspaceItems);
            appWidgets.addAll(mBgDataModel.appWidgets);
            orderedScreenIds.addAll(mBgDataModel.workspaceScreens);
            mBgDataModel.lastBindId++;
        }

        final int currentScreen;
Loading