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

Change-Id: I380242a4de13e7b2bc326d1a076f0a974435999c
This commit is contained in:
Sunny Goyal
2018-03-02 15:16:12 -08:00
parent d912e3f82a
commit 605bcf3367
7 changed files with 102 additions and 36 deletions

View File

@@ -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() {
Callbacks cb = mModel.getCallback();
if (callbacks == cb && cb != null) {
task.execute(callbacks);
}
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 */);
}