savvisingh / DateRangePicker

Date Range Picker is a Calendar Picker View to show a Customized Date Range Picker with improved UI and functionality to add subtitles to the dates
Apache License 2.0
784 stars 160 forks source link

Days style appears on wrong month #71

Open jkydevelopment opened 5 years ago

jkydevelopment commented 5 years ago

When I try to modify the style of some day cell through CalendarViewCell, the style is also added to the previous or next month if there is space enough. So sometimes appears wrong days inside a month. I attach a screenshot to improve my poor explanations.

git_issue

This is my code:

CalendarCellDecorator calendarCellDecorator = new CalendarCellDecorator() {
                    @Override
                    public void decorate(CalendarCellView cellView, Date date) {
                        for(Evento evento: eventos){
                            if(evento.getDate().getTime()==date.getTime()){
                                int color = getResources().getColor(R.color.white);
                                Drawable bg = getResources().getDrawable(R.drawable.bg_festivo);
                                switch (evento.getTipo()){
                                    case Evento.TIPO_NO_LABORAL: color = getResources().getColor(R.color.calendar_bg_no_laboral); break;
                                    case Evento.TIPO_BLOQUEADO: color = getResources().getColor(R.color.calendar_bg_bloqueado); break;
                                    case Evento.TIPO_VACACION: color = getResources().getColor(R.color.calendar_bg_vacacion); break;
                                }
                                bg.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
                                cellView.getDayOfMonthTextView().setBackground(bg);

                                TextView tv = cellView.getSubTitleTextView();
                                tv.setText(evento.getDetalle());
                                tv.setTextAlignment(View.TEXT_ALIGNMENT_TEXT_END);
                                tv.setTextSize(11); // Aumentamos el tamaño
                            }
                        }
                    }
                };