use of net.osmand.plus.profiles.data.RoutingDataObject in project Osmand by osmandapp.
the class SelectNavProfileBottomSheet method addProfileItem.
@Override
protected void addProfileItem(ProfileDataObject profileDataObject) {
final RoutingDataObject profile = (RoutingDataObject) profileDataObject;
LayoutInflater inflater = UiUtilities.getInflater(getContext(), nightMode);
View itemView = inflater.inflate(getItemLayoutId(profile), null);
TextView tvTitle = itemView.findViewById(R.id.title);
tvTitle.setText(profile.getName());
ImageView ivIcon = itemView.findViewById(R.id.icon);
Drawable drawableIcon = getPaintedIcon(profile.getIconRes(), getIconColor(profile));
ivIcon.setImageDrawable(drawableIcon);
CompoundButton compoundButton = itemView.findViewById(R.id.compound_button);
compoundButton.setChecked(isSelected(profile));
UiUtilities.setupCompoundButton(compoundButton, nightMode, UiUtilities.CompoundButtonType.GLOBAL);
BaseBottomSheetItem.Builder builder = new BaseBottomSheetItem.Builder().setCustomView(itemView);
if (!profile.isOnline() || profile.isPredefined()) {
builder.setOnClickListener(getItemClickListener(profile));
items.add(builder.create());
return;
} else {
View basePart = itemView.findViewById(R.id.basic_item_body);
View endBtn = itemView.findViewById(R.id.end_button);
TextView tvDescription = itemView.findViewById(R.id.description);
tvDescription.setText(profile.getDescription());
ImageView ivEndBtnIcon = itemView.findViewById(R.id.end_button_icon);
Drawable drawable = getIcon(R.drawable.ic_action_settings, getRouteInfoColorId());
if (Build.VERSION.SDK_INT >= 21) {
Drawable activeDrawable = getIcon(R.drawable.ic_action_settings, getActiveColorId());
drawable = AndroidUtils.createPressedStateListDrawable(drawable, activeDrawable);
}
ivEndBtnIcon.setImageDrawable(drawable);
basePart.setOnClickListener(getItemClickListener(profile));
endBtn.setOnClickListener(v -> {
if (getActivity() != null) {
OnlineRoutingEngineFragment.showInstance(getActivity(), getAppMode(), profile.getStringKey());
}
dismiss();
});
}
items.add(builder.create());
}
Aggregations