CalendarListview icon indicating copy to clipboard operation
CalendarListview copied to clipboard

Need to show highlighted days only, not ranges

Open Shaw007 opened this issue 10 years ago • 11 comments

Hi, I am trying to change your code to achieve something that I want but unfortunately things are not going in the right direction. I have an ArrayList<CalendarDay> and all i want is to highlight the calendar list dates based on the data in the list i.e I don't want any ranges. Can you please help me out..?

Shaw007 avatar Jan 26 '15 07:01 Shaw007

+1

eeVoskos avatar Mar 11 '15 15:03 eeVoskos

+1

Shahroz16 avatar Apr 19 '15 09:04 Shahroz16

+1

sunswy avatar Jun 10 '15 03:06 sunswy

+1

anirudh-24 avatar Jul 06 '15 06:07 anirudh-24

+1

ameenmaheen avatar Nov 20 '15 10:11 ameenmaheen

+1

Jalsoncc avatar Apr 04 '16 08:04 Jalsoncc

+1

buddhasaikia avatar Jun 02 '16 06:06 buddhasaikia

dayPickerView.setDateTime(new SimpleMonthAdapter.CalendarDay(startdate.getTime())); dayPickerView.setDateTime(new SimpleMonthAdapter.CalendarDay(enddate.getTime())); first is start date and second is end date. call in calendar activity.

rugved-mahamune avatar Jun 30 '16 07:06 rugved-mahamune

@rugved-mahamune not recognized method .setDateTime.

sweetie avatar Jul 02 '16 19:07 sweetie

public void setSelectedDateTime(CalendarDay calendarDay){
    if (selectedDays.getFirst() != null && selectedDays.getLast() == null)
    {
            selectedDays.setFirst(null);
            notifyDataSetChanged();
            return;
        }
        selectedDays.setLast(calendarDay);
        if(selectedDays.getLast().getDate().getTime() < selectedDays.getFirst().getDate().getTime()) {
            CalendarDay tmp = selectedDays.getFirst();
            selectedDays.setFirst(selectedDays.getLast());
            selectedDays.setLast(tmp);
        }
        if (selectedDays.getFirst().month < calendarDay.month)
        {
            for (int i = 0; i < selectedDays.getFirst().month - calendarDay.month - 1; ++i)
                mController.onDayOfMonthSelected(selectedDays.getFirst().year, selectedDays.getFirst().month + i, selectedDays.getFirst().day, selectedDays.getFirst().hourOfDay);
        }
        mController.onDaySelect(calendarDay, selectedDays, false);
        mController.onDateRangeSelected(selectedDays);
    }
    else if (selectedDays.getLast() != null)
    {
        selectedDays.setFirst(calendarDay);
        selectedDays.setLast(null);
        mController.onDaySelect(calendarDay, selectedDays, false);
    }
    else {
        selectedDays.setFirst(calendarDay);
        mController.onDaySelect(calendarDay, selectedDays, false);
    }
    notifyDataSetChanged();
}

Add the above function to SimpleMonthAdpter and the below to DayPickerView public void setDateTime(SimpleMonthAdapter.CalendarDay dateTime){ mAdapter.setSelectedDateTime(dateTime); } sorry I forgot I added these methods.. feel free to ask if any more bugs :)

rugved-mahamune avatar Jul 03 '16 15:07 rugved-mahamune

@rugved-mahamune Am Trying to do the same but there is extra bracket in your above method and no any method onDaySelect.

kumarbhubnesh avatar Dec 05 '17 13:12 kumarbhubnesh