Search in sources :

Example 6 with FolderNameProvider

use of com.android.launcher3.folder.FolderNameProvider in project android_packages_apps_404Launcher by P-404.

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 7 with FolderNameProvider

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

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 8 with FolderNameProvider

use of com.android.launcher3.folder.FolderNameProvider in project android_packages_apps_Trebuchet by LineageOS.

the class Folder method updateItemLocationsInDatabaseBatch.

private void updateItemLocationsInDatabaseBatch(boolean isBind) {
    FolderGridOrganizer verifier = new FolderGridOrganizer(mLauncher.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()) {
        mLauncher.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 9 with FolderNameProvider

use of com.android.launcher3.folder.FolderNameProvider in project android_packages_apps_Trebuchet by LineageOS.

the class LoaderTask method loadFolderNames.

private void loadFolderNames() {
    FolderNameProvider provider = FolderNameProvider.newInstance(mApp.getContext(), mBgAllAppsList.data, mBgDataModel.folders);
    synchronized (mBgDataModel) {
        for (int i = 0; i < mBgDataModel.folders.size(); i++) {
            FolderNameInfos suggestionInfos = new FolderNameInfos();
            FolderInfo info = mBgDataModel.folders.valueAt(i);
            if (info.suggestedFolderNames == null) {
                provider.getSuggestedFolderName(mApp.getContext(), info.contents, suggestionInfos);
                info.suggestedFolderNames = suggestionInfos;
            }
        }
    }
}
Also used : FolderNameInfos(com.android.launcher3.folder.FolderNameInfos) FolderNameProvider(com.android.launcher3.folder.FolderNameProvider) FolderInfo(com.android.launcher3.model.data.FolderInfo)

Example 10 with FolderNameProvider

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

the class LoaderTask method loadFolderNames.

private void loadFolderNames() {
    FolderNameProvider provider = FolderNameProvider.newInstance(mApp.getContext(), mBgAllAppsList.data, mBgDataModel.folders);
    synchronized (mBgDataModel) {
        for (int i = 0; i < mBgDataModel.folders.size(); i++) {
            FolderNameInfos suggestionInfos = new FolderNameInfos();
            FolderInfo info = mBgDataModel.folders.valueAt(i);
            if (info.suggestedFolderNames == null) {
                provider.getSuggestedFolderName(mApp.getContext(), info.contents, suggestionInfos);
                info.suggestedFolderNames = suggestionInfos;
            }
        }
    }
}
Also used : FolderNameInfos(com.android.launcher3.folder.FolderNameInfos) FolderNameProvider(com.android.launcher3.folder.FolderNameProvider) FolderInfo(com.android.launcher3.model.data.FolderInfo) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point)

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