use of io.jawg.osmcontributor.ui.dialogs.EditMonthsDialogFragment in project osm-contributor by jawg.
the class OpeningMonthAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final OpeningTimeHolder holder, int position) {
final OpeningMonth openingMonth = openingTime.getOpeningMonths().get(position);
holder.getTextInputLayout().setVisibility(hasToHide ? View.INVISIBLE : View.VISIBLE);
String[] split = openingMonthValueParser.toValue(openingMonth).split(OpeningMonthValueParser.MONTH_SEP);
if (split.length > 1) {
holder.getTextViewMonthValue().setText(openingMonthValueParser.toValue(openingMonth).split(OpeningMonthValueParser.MONTH_SEP)[0]);
}
// When the months input text is clicked, we start the dialog to pick
// the opening months
holder.getTextViewMonthValue().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
EditMonthsDialogFragment fragment = new EditMonthsDialogFragment();
fragment.setOpeningMonth(openingMonth);
fragment.setOnEditMonthsListener(new EditMonthsDialogFragment.OnEditMonthsTagListener() {
@Override
public void onOpeningMonthChanged(OpeningMonth o) {
openingMonth.setMonths(o.getMonths());
String[] split = openingMonthValueParser.toValue(openingMonth).split(OpeningMonthValueParser.MONTH_SEP);
if (split.length > 1) {
holder.getTextViewMonthValue().setText(openingMonthValueParser.toValue(openingMonth).split(OpeningMonthValueParser.MONTH_SEP)[0]);
}
eventBus.post(new PleaseApplyOpeningTimeChange(openingTime));
}
});
fragment.show(activity.getFragmentManager(), EditDaysDialogFragment.class.getSimpleName());
}
});
holder.getDeleteButton().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
openingTime.getOpeningMonths().remove(openingMonth);
eventBus.post(new PleaseApplyOpeningTimeChange(openingTime));
notifyDataSetChanged();
}
});
holder.getOpeningHoursLayout().removeAllViews();
new OpeningHoursLinearLayoutAdapter(openingTime, openingMonth.getOpeningHours(), holder.getOpeningHoursLayout(), activity, hasToHide);
}
Aggregations