use of com.simplecity.amp_library.model.CategoryItem in project Shuttle by timusus.
the class SettingsPresenter method chooseDefaultPageClicked.
public void chooseDefaultPageClicked(Context context) {
SettingsView settingsView = getView();
if (settingsView != null) {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
List<CategoryItem> categoryItems = Stream.of(CategoryItem.getCategoryItems(sharedPreferences)).filter(categoryItem -> categoryItem.isChecked).toList();
int defaultPageType = settingsManager.getDefaultPageType();
int defaultPage = Math.min(Stream.of(categoryItems).indexed().filter(categoryItemIntPair -> categoryItemIntPair.getSecond().type == defaultPageType).map(IntPair::getFirst).findFirst().orElse(1), categoryItems.size());
settingsView.showDefaultPageDialog(new MaterialDialog.Builder(context).title(R.string.pref_title_default_page).items(Stream.of(categoryItems).map(categoryItem -> context.getString(categoryItem.getTitleResId())).toList()).itemsCallbackSingleChoice(defaultPage, (dialog, itemView, which, text) -> {
settingsManager.setDefaultPageType(categoryItems.get(which).type);
return false;
}).build());
}
}
Aggregations