use of com.android.settingslib.drawer.Tile in project android_frameworks_base by ResurrectionRemix.
the class SuggestionParser method readSuggestions.
private void readSuggestions(SuggestionCategory category, List<Tile> suggestions) {
int countBefore = suggestions.size();
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(category.category);
if (category.pkg != null) {
intent.setPackage(category.pkg);
}
TileUtils.getTilesForIntent(mContext, new UserHandle(UserHandle.myUserId()), intent, addCache, null, suggestions, true, false);
for (int i = countBefore; i < suggestions.size(); i++) {
if (!isAvailable(suggestions.get(i)) || !isSupported(suggestions.get(i)) || !satisfiesRequiredAccount(suggestions.get(i)) || isDismissed(suggestions.get(i))) {
suggestions.remove(i--);
}
}
if (!category.multiple && suggestions.size() > (countBefore + 1)) {
// If there are too many, remove them all and only re-add the one with the highest
// priority.
Tile item = suggestions.remove(suggestions.size() - 1);
while (suggestions.size() > countBefore) {
Tile last = suggestions.remove(suggestions.size() - 1);
if (last.priority > item.priority) {
item = last;
}
}
// If category is marked as done, do not add any item.
if (!isCategoryDone(category.category)) {
suggestions.add(item);
}
}
}
use of com.android.settingslib.drawer.Tile in project android_frameworks_base by DirtyUnicorns.
the class SuggestionParser method readSuggestions.
private void readSuggestions(SuggestionCategory category, List<Tile> suggestions) {
int countBefore = suggestions.size();
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(category.category);
if (category.pkg != null) {
intent.setPackage(category.pkg);
}
TileUtils.getTilesForIntent(mContext, new UserHandle(UserHandle.myUserId()), intent, addCache, null, suggestions, true, false);
for (int i = countBefore; i < suggestions.size(); i++) {
if (!isAvailable(suggestions.get(i)) || !isSupported(suggestions.get(i)) || !satisfiesRequiredAccount(suggestions.get(i)) || isDismissed(suggestions.get(i))) {
suggestions.remove(i--);
}
}
if (!category.multiple && suggestions.size() > (countBefore + 1)) {
// If there are too many, remove them all and only re-add the one with the highest
// priority.
Tile item = suggestions.remove(suggestions.size() - 1);
while (suggestions.size() > countBefore) {
Tile last = suggestions.remove(suggestions.size() - 1);
if (last.priority > item.priority) {
item = last;
}
}
// If category is marked as done, do not add any item.
if (!isCategoryDone(category.category)) {
suggestions.add(item);
}
}
}
use of com.android.settingslib.drawer.Tile in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DashboardAdapter method recountItems.
private void recountItems() {
reset();
boolean hasConditions = false;
for (int i = 0; mConditions != null && i < mConditions.size(); i++) {
boolean shouldShow = mConditions.get(i).shouldShow();
hasConditions |= shouldShow;
countItem(mConditions.get(i), R.layout.condition_card, shouldShow, NS_CONDITION);
}
boolean hasSuggestions = mSuggestions != null && mSuggestions.size() != 0;
countItem(null, R.layout.dashboard_spacer, hasConditions && hasSuggestions, NS_SPACER);
countItem(null, R.layout.suggestion_header, hasSuggestions, NS_SPACER);
resetCount();
if (mSuggestions != null) {
int maxSuggestions = getDisplayableSuggestionCount();
for (int i = 0; i < mSuggestions.size(); i++) {
countItem(mSuggestions.get(i), R.layout.suggestion_tile, i < maxSuggestions, NS_SUGGESTION);
}
}
resetCount();
for (int i = 0; mCategories != null && i < mCategories.size(); i++) {
DashboardCategory category = mCategories.get(i);
countItem(category, R.layout.dashboard_category, mIsShowingAll, NS_ITEMS);
for (int j = 0; j < category.tiles.size(); j++) {
Tile tile = category.tiles.get(j);
countItem(tile, R.layout.dashboard_tile, mIsShowingAll || ArrayUtils.contains(DashboardSummary.INITIAL_ITEMS, tile.intent.getComponent().getClassName()), NS_ITEMS);
}
}
notifyDataSetChanged();
}
Aggregations