use of net.osmand.plus.widgets.chips.ChipItem in project Osmand by osmandapp.
the class ChartsCard method fillInMenu.
@SuppressLint("NotifyDataSetChanged")
private void fillInMenu() {
int activeColor = ColorUtilities.getActiveColor(app, nightMode);
List<ChipItem> items = new ArrayList<>();
for (ChartType<?> type : chartTypes) {
if (!type.isAvailable()) {
continue;
}
String title = type.getTitle();
ChipItem item = new ChipItem(title);
item.title = title;
item.tag = type;
if (type.isCustom()) {
item.titleColor = activeColor;
}
items.add(item);
}
graphTypesMenu.setItems(items);
ChipItem selected = graphTypesMenu.getChipById(visibleType.getTitle());
graphTypesMenu.setSelected(selected);
graphTypesMenu.setOnSelectChipListener(chip -> {
ChartType<?> chosenType = (ChartType<?>) chip.tag;
if (!isVisibleType(chosenType)) {
changeVisibleType(chosenType);
}
graphTypesMenu.smoothScrollTo(chip);
return true;
});
graphTypesMenu.notifyDataSetChanged();
}
use of net.osmand.plus.widgets.chips.ChipItem in project Osmand by osmandapp.
the class SendGpxBottomSheetFragment method createMenuItems.
@Override
public void createMenuItems(Bundle savedInstanceState) {
OsmandApplication app = requiredMyApplication();
plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
LayoutInflater themedInflater = UiUtilities.getInflater(app, nightMode);
View sendGpxView = themedInflater.inflate(R.layout.send_gpx_fragment, null);
sendGpxView.getViewTreeObserver().addOnGlobalLayoutListener(getShadowLayoutListener());
if (selectedUploadVisibility == null) {
selectedUploadVisibility = plugin.OSM_UPLOAD_VISIBILITY.get();
}
tagsField = sendGpxView.findViewById(R.id.tags_field);
messageField = sendGpxView.findViewById(R.id.message_field);
TextView accountName = sendGpxView.findViewById(R.id.user_name);
if (!Algorithms.isEmpty(plugin.OSM_USER_DISPLAY_NAME.get())) {
accountName.setText(plugin.OSM_USER_DISPLAY_NAME.get());
} else {
accountName.setText(plugin.OSM_USER_NAME_OR_EMAIL.get());
}
final TextView visibilityName = sendGpxView.findViewById(R.id.visibility_name);
final TextView visibilityDescription = sendGpxView.findViewById(R.id.visibility_description);
visibilityName.setText(selectedUploadVisibility.getTitleId());
visibilityDescription.setText(selectedUploadVisibility.getDescriptionId());
List<ChipItem> itemsVisibility = new ArrayList<>();
for (UploadVisibility visibilityType : UploadVisibility.values()) {
String title = getString(visibilityType.getTitleId());
ChipItem item = new ChipItem(title);
item.title = title;
item.tag = visibilityType;
itemsVisibility.add(item);
}
HorizontalChipsView chipsView = sendGpxView.findViewById(R.id.selector_view);
chipsView.setItems(itemsVisibility);
ChipItem selected = chipsView.getChipById(getString(selectedUploadVisibility.getTitleId()));
chipsView.setSelected(selected);
chipsView.setOnSelectChipListener(chip -> {
selectedUploadVisibility = (UploadVisibility) chip.tag;
plugin.OSM_UPLOAD_VISIBILITY.set(selectedUploadVisibility);
visibilityName.setText(selectedUploadVisibility.getTitleId());
visibilityDescription.setText(selectedUploadVisibility.getDescriptionId());
chipsView.smoothScrollTo(chip);
return true;
});
chipsView.notifyDataSetChanged();
LinearLayout account = sendGpxView.findViewById(R.id.account_container);
account.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
FragmentActivity activity = getActivity();
if (activity != null) {
showOpenStreetMapScreen(activity);
}
dismiss();
}
});
SimpleBottomSheetItem titleItem = (SimpleBottomSheetItem) new SimpleBottomSheetItem.Builder().setCustomView(sendGpxView).create();
items.add(titleItem);
}
Aggregations