Search in sources :

Example 1 with RoutingDataObject

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());
}
Also used : BaseBottomSheetItem(net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem) LayoutInflater(android.view.LayoutInflater) Drawable(android.graphics.drawable.Drawable) TextView(android.widget.TextView) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) CompoundButton(android.widget.CompoundButton) RoutingDataObject(net.osmand.plus.profiles.data.RoutingDataObject)

Aggregations

Drawable (android.graphics.drawable.Drawable)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 CompoundButton (android.widget.CompoundButton)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 BaseBottomSheetItem (net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem)1 RoutingDataObject (net.osmand.plus.profiles.data.RoutingDataObject)1