Search in sources :

Example 1 with OpeningHoursDaysDialogFragment

use of net.osmand.plus.osmedit.dialogs.OpeningHoursDaysDialogFragment in project Osmand by osmandapp.

the class BasicEditPoiFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_edit_poi_normal, container, false);
    TypedValue typedValue = new TypedValue();
    Resources.Theme theme = getActivity().getTheme();
    theme.resolveAttribute(android.R.attr.textColorSecondary, typedValue, true);
    int iconColor = typedValue.data;
    ImageView streetImageView = (ImageView) view.findViewById(R.id.streetImageView);
    streetImageView.setImageDrawable(getPaintedContentIcon(R.drawable.ic_action_street_name, iconColor));
    ImageView houseNumberImageView = (ImageView) view.findViewById(R.id.houseNumberImageView);
    houseNumberImageView.setImageDrawable(getPaintedContentIcon(R.drawable.ic_action_building_number, iconColor));
    ImageView phoneImageView = (ImageView) view.findViewById(R.id.phoneImageView);
    phoneImageView.setImageDrawable(getPaintedContentIcon(R.drawable.ic_action_call_dark, iconColor));
    ImageView webSiteImageView = (ImageView) view.findViewById(R.id.webSiteImageView);
    webSiteImageView.setImageDrawable(getPaintedContentIcon(R.drawable.ic_world_globe_dark, iconColor));
    ImageView descriptionImageView = (ImageView) view.findViewById(R.id.descriptionImageView);
    descriptionImageView.setImageDrawable(getPaintedContentIcon(R.drawable.ic_action_description, iconColor));
    ImageView openingHoursImageView = (ImageView) view.findViewById(R.id.openingHoursImageView);
    openingHoursImageView.setImageDrawable(getPaintedContentIcon(R.drawable.ic_action_time, iconColor));
    streetEditText = (EditText) view.findViewById(R.id.streetEditText);
    houseNumberEditText = (EditText) view.findViewById(R.id.houseNumberEditText);
    phoneEditText = (EditText) view.findViewById(R.id.phoneEditText);
    webSiteEditText = (EditText) view.findViewById(R.id.webSiteEditText);
    descriptionEditText = (EditText) view.findViewById(R.id.descriptionEditText);
    addTextWatcher(OSMSettings.OSMTagKey.ADDR_STREET.getValue(), streetEditText);
    addTextWatcher(OSMSettings.OSMTagKey.WEBSITE.getValue(), webSiteEditText);
    addTextWatcher(OSMSettings.OSMTagKey.PHONE.getValue(), phoneEditText);
    addTextWatcher(OSMSettings.OSMTagKey.ADDR_HOUSE_NUMBER.getValue(), houseNumberEditText);
    addTextWatcher(OSMSettings.OSMTagKey.DESCRIPTION.getValue(), descriptionEditText);
    Button addOpeningHoursButton = (Button) view.findViewById(R.id.addOpeningHoursButton);
    addOpeningHoursButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            BasicOpeningHourRule rule = new BasicOpeningHourRule();
            rule.setStartTime(9 * 60);
            rule.setEndTime(18 * 60);
            OpeningHoursDaysDialogFragment fragment = OpeningHoursDaysDialogFragment.createInstance(rule, -1);
            fragment.show(getChildFragmentManager(), "OpenTimeDialogFragment");
        }
    });
    LinearLayout openHoursContainer = (LinearLayout) view.findViewById(R.id.openHoursContainer);
    Drawable clockDrawable = getPaintedContentIcon(R.drawable.ic_action_time, iconColor);
    Drawable deleteDrawable = getPaintedContentIcon(R.drawable.ic_action_remove_dark, iconColor);
    if (savedInstanceState != null && savedInstanceState.containsKey(OPENING_HOURS)) {
        mOpeningHoursAdapter = new OpeningHoursAdapter((OpeningHoursParser.OpeningHours) savedInstanceState.getSerializable(OPENING_HOURS), openHoursContainer, getData(), clockDrawable, deleteDrawable);
        mOpeningHoursAdapter.updateViews();
    } else {
        mOpeningHoursAdapter = new OpeningHoursAdapter(new OpeningHoursParser.OpeningHours(), openHoursContainer, getData(), clockDrawable, deleteDrawable);
    }
    onFragmentActivated();
    return view;
}
Also used : BasicOpeningHourRule(net.osmand.util.OpeningHoursParser.BasicOpeningHourRule) Drawable(android.graphics.drawable.Drawable) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) ImageButton(android.widget.ImageButton) Button(android.widget.Button) OpeningHoursDaysDialogFragment(net.osmand.plus.osmedit.dialogs.OpeningHoursDaysDialogFragment) Resources(android.content.res.Resources) ImageView(android.widget.ImageView) LinearLayout(android.widget.LinearLayout) TypedValue(android.util.TypedValue) Nullable(android.support.annotation.Nullable)

Aggregations

Resources (android.content.res.Resources)1 Drawable (android.graphics.drawable.Drawable)1 Nullable (android.support.annotation.Nullable)1 TypedValue (android.util.TypedValue)1 View (android.view.View)1 Button (android.widget.Button)1 ImageButton (android.widget.ImageButton)1 ImageView (android.widget.ImageView)1 LinearLayout (android.widget.LinearLayout)1 TextView (android.widget.TextView)1 OpeningHoursDaysDialogFragment (net.osmand.plus.osmedit.dialogs.OpeningHoursDaysDialogFragment)1 BasicOpeningHourRule (net.osmand.util.OpeningHoursParser.BasicOpeningHourRule)1