Search in sources :

Example 11 with FolderNameProvider

use of com.android.launcher3.folder.FolderNameProvider in project android_packages_apps_Launcher3 by ProtonAOSP.

the class Folder method updateItemLocationsInDatabaseBatch.

private void updateItemLocationsInDatabaseBatch(boolean isBind) {
    FolderGridOrganizer verifier = new FolderGridOrganizer(mActivityContext.getDeviceProfile().inv).setFolderInfo(mInfo);
    ArrayList<ItemInfo> items = new ArrayList<>();
    int total = mInfo.contents.size();
    for (int i = 0; i < total; i++) {
        WorkspaceItemInfo itemInfo = mInfo.contents.get(i);
        if (verifier.updateRankAndPos(itemInfo, i)) {
            items.add(itemInfo);
        }
    }
    if (!items.isEmpty()) {
        mLauncherDelegate.getModelWriter().moveItemsInDatabase(items, mInfo.id, 0);
    }
    if (FeatureFlags.FOLDER_NAME_SUGGEST.get() && !isBind && total > 1) /* no need to update if there's one icon */
    {
        Executors.MODEL_EXECUTOR.post(() -> {
            FolderNameInfos nameInfos = new FolderNameInfos();
            FolderNameProvider fnp = FolderNameProvider.newInstance(getContext());
            fnp.getSuggestedFolderName(getContext(), mInfo.contents, nameInfos);
            mInfo.suggestedFolderNames = nameInfos;
        });
    }
}
Also used : ItemInfo(com.android.launcher3.model.data.ItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) ArrayList(java.util.ArrayList) SuppressLint(android.annotation.SuppressLint) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 12 with FolderNameProvider

use of com.android.launcher3.folder.FolderNameProvider in project android_packages_apps_Launcher3 by AOSPA.

the class Folder method updateItemLocationsInDatabaseBatch.

private void updateItemLocationsInDatabaseBatch(boolean isBind) {
    FolderGridOrganizer verifier = new FolderGridOrganizer(mActivityContext.getDeviceProfile().inv).setFolderInfo(mInfo);
    ArrayList<ItemInfo> items = new ArrayList<>();
    int total = mInfo.contents.size();
    for (int i = 0; i < total; i++) {
        WorkspaceItemInfo itemInfo = mInfo.contents.get(i);
        if (verifier.updateRankAndPos(itemInfo, i)) {
            items.add(itemInfo);
        }
    }
    if (!items.isEmpty()) {
        mLauncherDelegate.getModelWriter().moveItemsInDatabase(items, mInfo.id, 0);
    }
    if (FeatureFlags.FOLDER_NAME_SUGGEST.get() && !isBind && total > 1) /* no need to update if there's one icon */
    {
        Executors.MODEL_EXECUTOR.post(() -> {
            FolderNameInfos nameInfos = new FolderNameInfos();
            FolderNameProvider fnp = FolderNameProvider.newInstance(getContext());
            fnp.getSuggestedFolderName(getContext(), mInfo.contents, nameInfos);
            mInfo.suggestedFolderNames = nameInfos;
        });
    }
}
Also used : ItemInfo(com.android.launcher3.model.data.ItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) ArrayList(java.util.ArrayList) SuppressLint(android.annotation.SuppressLint) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Aggregations

SuppressLint (android.annotation.SuppressLint)11 FolderNameInfos (com.android.launcher3.folder.FolderNameInfos)6 FolderNameProvider (com.android.launcher3.folder.FolderNameProvider)6 FolderInfo (com.android.launcher3.model.data.FolderInfo)6 ItemInfo (com.android.launcher3.model.data.ItemInfo)6 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)6 ArrayList (java.util.ArrayList)6 Point (android.graphics.Point)5