use of net.osmand.plus.settings.fragments.SettingsCategoryItems in project Osmand by osmandapp.
the class BackupTypesAdapter method getGroupView.
@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
View view = convertView;
if (view == null) {
view = themedInflater.inflate(R.layout.backup_type_item, parent, false);
}
ExportSettingsCategory category = itemsTypes.get(groupPosition);
SettingsCategoryItems items = itemsMap.get(category);
String name = app.getString(category.getTitleId());
Typeface typeface = FontCache.getRobotoMedium(app);
TextView titleTv = view.findViewById(R.id.title);
titleTv.setText(UiUtilities.createCustomFontSpannable(typeface, name, name));
TextView description = view.findViewById(R.id.description);
description.setText(getCategoryDescr(category));
int selectedTypes = 0;
for (ExportSettingsType type : items.getTypes()) {
if (selectedItemsMap.get(type) != null) {
selectedTypes++;
}
}
CompoundButton compoundButton = view.findViewById(R.id.switch_widget);
compoundButton.setChecked(selectedTypes == items.getTypes().size());
UiUtilities.setupCompoundButton(compoundButton, nightMode, CompoundButtonType.GLOBAL);
view.findViewById(R.id.switch_container).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
compoundButton.performClick();
if (listener != null) {
listener.onCategorySelected(category, compoundButton.isChecked());
}
notifyDataSetChanged();
}
});
setupSelectableBackground(view);
adjustIndicator(app, groupPosition, isExpanded, view, !nightMode);
AndroidUiHelper.updateVisibility(view.findViewById(R.id.divider), isExpanded);
AndroidUiHelper.updateVisibility(view.findViewById(R.id.card_top_divider), true);
AndroidUiHelper.updateVisibility(view.findViewById(R.id.card_bottom_divider), !isExpanded);
return view;
}
use of net.osmand.plus.settings.fragments.SettingsCategoryItems in project Osmand by osmandapp.
the class BackupTypesAdapter method getChild.
@Override
public Object getChild(int groupPosition, int childPosition) {
SettingsCategoryItems categoryItems = itemsMap.get(itemsTypes.get(groupPosition));
ExportSettingsType type = categoryItems.getTypes().get(groupPosition);
return categoryItems.getItemsForType(type).get(childPosition);
}
use of net.osmand.plus.settings.fragments.SettingsCategoryItems in project Osmand by osmandapp.
the class BackupTypesAdapter method getChildView.
@Override
public View getChildView(int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
View view = convertView;
if (view == null) {
view = themedInflater.inflate(R.layout.backup_type_item, parent, false);
}
ExportSettingsCategory category = itemsTypes.get(groupPosition);
SettingsCategoryItems categoryItems = itemsMap.get(category);
ExportSettingsType type = categoryItems.getTypes().get(childPosition);
List<?> items = categoryItems.getItemsForType(type);
List<?> selectedItems = selectedItemsMap.get(type);
boolean selected = selectedItems != null;
TextView title = view.findViewById(R.id.title);
title.setText(type.getTitleId());
TextView description = view.findViewById(R.id.description);
description.setText(getSelectedTypeDescr(app, selectedItemsMap, type, items));
CompoundButton compoundButton = view.findViewById(R.id.switch_widget);
compoundButton.setChecked(selected);
UiUtilities.setupCompoundButton(compoundButton, nightMode, CompoundButtonType.GLOBAL);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
compoundButton.performClick();
if (listener != null) {
listener.onTypeSelected(type, compoundButton.isChecked());
}
notifyDataSetChanged();
}
});
setupSelectableBackground(view);
setupChildIcon(view, type.getIconRes(), selected);
AndroidUiHelper.updateVisibility(view.findViewById(R.id.divider), false);
AndroidUiHelper.updateVisibility(view.findViewById(R.id.card_top_divider), false);
AndroidUiHelper.updateVisibility(view.findViewById(R.id.card_bottom_divider), isLastChild);
return view;
}
use of net.osmand.plus.settings.fragments.SettingsCategoryItems in project Osmand by osmandapp.
the class BaseBackupTypesFragment method onCategorySelected.
@Override
public void onCategorySelected(ExportSettingsCategory category, boolean selected) {
boolean hasItemsToDelete = false;
SettingsCategoryItems categoryItems = dataList.get(category);
List<ExportSettingsType> types = categoryItems.getTypes();
for (ExportSettingsType type : types) {
List<Object> items = getItemsForType(type);
hasItemsToDelete |= !Algorithms.isEmpty(items);
selectedItemsMap.put(type, selected ? items : null);
}
if (!selected && hasItemsToDelete) {
showClearTypesBottomSheet(types);
}
}
Aggregations