use of net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerItem in project Osmand by osmandapp.
the class SelectWptCategoriesBottomSheetDialogFragment method createMenuItems.
@Override
public void createMenuItems(Bundle savedInstanceState) {
gpxFile = getGpxFile();
if (gpxFile == null) {
return;
}
items.add(new TitleItem(getGpxName(gpxFile)));
items.add(new DescriptionItem(getString(R.string.select_waypoints_category_description)));
final BottomSheetItemWithCompoundButton[] selectAllItem = new BottomSheetItemWithCompoundButton[1];
selectAllItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder().setChecked(true).setDescription(getString(R.string.shared_string_total) + ": " + gpxFile.getPoints().size()).setIcon(getContentIcon(R.drawable.ic_action_group_select_all)).setTitle(getString(R.string.shared_string_select_all)).setLayoutId(R.layout.bottom_sheet_item_with_descr_and_checkbox_56dp).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean checked = !selectAllItem[0].isChecked();
selectAllItem[0].setChecked(checked);
for (BottomSheetItemWithCompoundButton item : categoryItems) {
item.setChecked(checked);
}
}
}).create();
items.add(selectAllItem[0]);
items.add(new DividerItem(getContext()));
Map<String, List<WptPt>> pointsByCategories = gpxFile.getPointsByCategories();
for (String category : pointsByCategories.keySet()) {
final BottomSheetItemWithCompoundButton[] categoryItem = new BottomSheetItemWithCompoundButton[1];
categoryItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder().setChecked(true).setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
selectedCategories.add((String) categoryItem[0].getTag());
} else {
selectedCategories.remove((String) categoryItem[0].getTag());
}
}
}).setDescription(String.valueOf(pointsByCategories.get(category).size())).setIcon(getContentIcon(R.drawable.ic_action_folder)).setTitle(category.equals("") ? getString(R.string.waypoints) : category).setLayoutId(R.layout.bottom_sheet_item_with_descr_and_checkbox_56dp).setTag(category).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
categoryItem[0].setChecked(!categoryItem[0].isChecked());
selectAllItem[0].setChecked(isAllChecked());
}
}).create();
items.add(categoryItem[0]);
categoryItems.add(categoryItem[0]);
selectedCategories.add(category);
}
}
use of net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerItem in project Osmand by osmandapp.
the class HistoryMarkerMenuBottomSheetDialogFragment method createMenuItems.
@Override
public void createMenuItems(Bundle savedInstanceState) {
Bundle arguments = getArguments();
if (arguments != null) {
final int pos = arguments.getInt(MARKER_POSITION);
final String markerName = arguments.getString(MARKER_NAME);
final int markerColorIndex = arguments.getInt(MARKER_COLOR_INDEX);
final long markerVisitedDate = arguments.getLong(MARKER_VISITED_DATE);
Date date = new Date(markerVisitedDate);
String month = new SimpleDateFormat("MMM", Locale.getDefault()).format(date);
month = Algorithms.capitalizeFirstLetter(month);
month = month.replaceAll("\\.", "");
String day = new SimpleDateFormat("d", Locale.getDefault()).format(date);
BaseBottomSheetItem markerItem = new BottomSheetItemWithDescription.Builder().setDescription(getString(R.string.passed, month + " " + day)).setIcon(getIcon(R.drawable.ic_action_flag_dark, MapMarker.getColorId(markerColorIndex))).setTitle(markerName).setLayoutId(R.layout.bottom_sheet_item_with_descr_56dp).create();
items.add(markerItem);
items.add(new DividerItem(getContext()));
BaseBottomSheetItem makeActiveItem = new SimpleBottomSheetItem.Builder().setIcon(getContentIcon(R.drawable.ic_action_reset_to_default_dark)).setTitle(getString(R.string.make_active)).setLayoutId(R.layout.bottom_sheet_item_simple).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (listener != null) {
listener.onMakeMarkerActive(pos);
}
dismiss();
}
}).create();
items.add(makeActiveItem);
BaseBottomSheetItem deleteItem = new SimpleBottomSheetItem.Builder().setIcon(getContentIcon(R.drawable.ic_action_delete_dark)).setTitle(getString(R.string.shared_string_delete)).setLayoutId(R.layout.bottom_sheet_item_simple).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (listener != null) {
listener.onDeleteMarker(pos);
}
dismiss();
}
}).create();
items.add(deleteItem);
}
}
Aggregations