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:
Samuel Fufa
2020-05-04 11:14:52 -07:00
parent 43e789ff9b
commit 385e93249e
10 changed files with 211 additions and 35 deletions

View File

@@ -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;
}
}