mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-01 16:26:47 +00:00
Improve Hybird hotseat cache support
Loads list of cached apps and shows predicted app icons with the rest of workspace items. -> Extracted prediction caching logic into a model layer Bug: 155029837 Test: Manual Change-Id: I6981594a910f5fe4e8e8cf8fe39db0cb856e7acd
This commit is contained in:
@@ -19,11 +19,14 @@ import com.android.launcher3.InvariantDeviceProfile;
|
||||
import com.android.launcher3.LauncherSettings;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.util.IntArray;
|
||||
import com.android.launcher3.util.IntSet;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
/**
|
||||
* Utils class for {@link com.android.launcher3.LauncherModel}.
|
||||
@@ -109,4 +112,17 @@ public class ModelUtils {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterates though current workspace items and returns available hotseat ranks for prediction.
|
||||
*/
|
||||
public static IntArray getMissingHotseatRanks(List<ItemInfo> items, int len) {
|
||||
IntSet seen = new IntSet();
|
||||
items.stream().filter(
|
||||
info -> info.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT)
|
||||
.forEach(i -> seen.add(i.screenId));
|
||||
IntArray result = new IntArray(len);
|
||||
IntStream.range(0, len).filter(i -> !seen.contains(i)).forEach(result::add);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user