use of io.jawg.osmcontributor.ui.adapters.OpeningMonthAdapter in project osm-contributor by jawg.
the class OpeningHoursViewBinder method onBindViewHolder.
@Override
public void onBindViewHolder(TagItemOpeningTimeViewHolder holder, TagItem tagItem) {
// Save holder
this.content = holder.getContent();
holder.getTextViewKey().setText(ParserManager.parseTagName(tagItem.getKey(), holder.getContent().getContext()));
OpeningTime openingTime = null;
try {
openingTime = openingTimeValueParser.fromValue(tagItem.getValue());
} catch (IllegalArgumentException e) {
e.printStackTrace();
tagItem.setConform(false);
}
if (openingTime == null) {
openingTime = new OpeningTime();
}
final OpeningMonthAdapter adapter = new OpeningMonthAdapter(openingTime, activity.get());
adapter.setTime(tagItem.getValue());
if (tagItem.getTagType() == TagItem.Type.TIME) {
adapter.hideMonth(true);
}
holder.getOpeningTimeRecyclerView().setAdapter(adapter);
holder.getOpeningTimeRecyclerView().setLayoutManager(new LinearLayoutManager(activity.get()));
holder.getOpeningTimeRecyclerView().setHasFixedSize(false);
RecyclerView.ItemAnimator itemAnimator = new DefaultItemAnimator();
itemAnimator.setAddDuration(300);
holder.getOpeningTimeRecyclerView().setItemAnimator(itemAnimator);
holder.getOpeningTimeRecyclerView().addItemDecoration(new DividerItemDecoration(activity.get()));
final OpeningTime finalOpeningTime = openingTime;
holder.getAddButton().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finalOpeningTime.addOpeningMonth(new OpeningMonth());
adapter.notifyItemInserted(adapter.getItemCount() - 1);
}
});
showInvalidityMessage(tagItem);
}
Aggregations