use of com.android.launcher3.model.ModelWriter in project android_packages_apps_Launcher3 by AOSPA.
the class DeleteDropTarget method completeDrop.
@Override
public void completeDrop(DragObject d) {
ItemInfo item = d.dragInfo;
if (canRemove(item)) {
ItemInfo pageItem = item;
if (item.container <= 0) {
View v = mLauncher.getWorkspace().getHomescreenIconByItemId(item.container);
if (v != null) {
pageItem = (ItemInfo) v.getTag();
}
}
IntSet pageIds = pageItem.container == Favorites.CONTAINER_DESKTOP ? IntSet.wrap(pageItem.screenId) : mLauncher.getWorkspace().getCurrentPageScreenIds();
onAccessibilityDrop(null, item);
ModelWriter modelWriter = mLauncher.getModelWriter();
Runnable onUndoClicked = () -> {
mLauncher.setPagesToBindSynchronously(pageIds);
modelWriter.abortDelete();
mLauncher.getStatsLogManager().logger().log(LAUNCHER_UNDO);
};
Snackbar.show(mLauncher, R.string.item_removed, R.string.undo, modelWriter::commitDelete, onUndoClicked);
}
}
use of com.android.launcher3.model.ModelWriter in project android_packages_apps_Trebuchet by LineageOS.
the class DeleteDropTarget method completeDrop.
@Override
public void completeDrop(DragObject d) {
ItemInfo item = d.dragInfo;
if (canRemove(item)) {
int itemPage = mLauncher.getWorkspace().getCurrentPage();
onAccessibilityDrop(null, item);
ModelWriter modelWriter = mLauncher.getModelWriter();
Runnable onUndoClicked = () -> {
mLauncher.setPageToBindSynchronously(itemPage);
modelWriter.abortDelete();
mLauncher.getUserEventDispatcher().logActionOnControl(TAP, UNDO);
};
Snackbar.show(mLauncher, R.string.item_removed, R.string.undo, modelWriter::commitDelete, onUndoClicked);
}
}
use of com.android.launcher3.model.ModelWriter in project android_packages_apps_Trebuchet by LineageOS.
the class FolderInfo method setTitle.
@Override
public void setTitle(@Nullable CharSequence title, ModelWriter modelWriter) {
// Retaining null title(ie., UNLABELED state) allows auto-labeling when new items added.
if (isEmpty(title) && this.title == null) {
return;
}
// Updating title to same value does not change any states.
if (title != null && title.equals(this.title)) {
return;
}
this.title = title;
LabelState newLabelState = title == null ? LabelState.UNLABELED : title.length() == 0 ? LabelState.EMPTY : getAcceptedSuggestionIndex().isPresent() ? LabelState.SUGGESTED : LabelState.MANUAL;
if (newLabelState.equals(LabelState.MANUAL)) {
options |= FLAG_MANUAL_FOLDER_NAME;
} else {
options &= ~FLAG_MANUAL_FOLDER_NAME;
}
if (modelWriter != null) {
modelWriter.updateItemInDatabase(this);
}
}
use of com.android.launcher3.model.ModelWriter in project android_packages_apps_Launcher3 by ProtonAOSP.
the class DeleteDropTarget method completeDrop.
@Override
public void completeDrop(DragObject d) {
ItemInfo item = d.dragInfo;
if (canRemove(item)) {
ItemInfo pageItem = item;
if (item.container <= 0) {
View v = mLauncher.getWorkspace().getHomescreenIconByItemId(item.container);
if (v != null) {
pageItem = (ItemInfo) v.getTag();
}
}
IntSet pageIds = pageItem.container == Favorites.CONTAINER_DESKTOP ? IntSet.wrap(pageItem.screenId) : mLauncher.getWorkspace().getCurrentPageScreenIds();
onAccessibilityDrop(null, item);
ModelWriter modelWriter = mLauncher.getModelWriter();
Runnable onUndoClicked = () -> {
mLauncher.setPagesToBindSynchronously(pageIds);
modelWriter.abortDelete();
mLauncher.getStatsLogManager().logger().log(LAUNCHER_UNDO);
};
Snackbar.show(mLauncher, R.string.item_removed, R.string.undo, modelWriter::commitDelete, onUndoClicked);
}
}
use of com.android.launcher3.model.ModelWriter in project android_packages_apps_404Launcher by P-404.
the class DeleteDropTarget method completeDrop.
@Override
public void completeDrop(DragObject d) {
ItemInfo item = d.dragInfo;
if (canRemove(item)) {
ItemInfo pageItem = item;
if (item.container <= 0) {
View v = mLauncher.getWorkspace().getHomescreenIconByItemId(item.container);
if (v != null) {
pageItem = (ItemInfo) v.getTag();
}
}
IntSet pageIds = pageItem.container == Favorites.CONTAINER_DESKTOP ? IntSet.wrap(pageItem.screenId) : mLauncher.getWorkspace().getCurrentPageScreenIds();
onAccessibilityDrop(null, item);
ModelWriter modelWriter = mLauncher.getModelWriter();
Runnable onUndoClicked = () -> {
mLauncher.setPagesToBindSynchronously(pageIds);
modelWriter.abortDelete();
mLauncher.getStatsLogManager().logger().log(LAUNCHER_UNDO);
};
Snackbar.show(mLauncher, R.string.item_removed, R.string.undo, modelWriter::commitDelete, onUndoClicked);
}
}
Aggregations