public void setShowPastItems ( boolean enable ) { if ( enable && ! showPastItems ) { // first reset the minimum date if necessary: if ( getMinDate ( ) != null && compareCalendarDates ( getMinDate ( ) , Calendar . getInstance ( ) ) == 0 ) setMinDate ( null ) ; // create the yesterday and last Monday item: final Resources res = getResources ( ) ; final Calendar date = Calendar . getInstance ( ) ; // yesterday: date . add ( Calendar . DAY_OF_YEAR , - 1 ) ; insertAdapterItem ( new DateItem ( res . getString ( R . string . date_yesterday ) , date , R . id . date_yesterday ) , 0 ) ; // last weekday item: date . add ( Calendar . DAY_OF_YEAR , - 6 ) ; int weekday = date . get ( Calendar . DAY_OF_WEEK ) ; insertAdapterItem ( new DateItem ( getWeekDay ( weekday , R . string . date_last_weekday ) , date , R . id . date_last_week ) , 0 ) ; } else if ( ! enable && showPastItems ) { // delete the yesterday and last weekday items: removeAdapterItemById ( R . id . date_last_week ) ; removeAdapterItemById ( R . id . date_yesterday ) ; // we set the minimum date to today as we don't allow past items setMinDate ( Calendar . getInstance ( ) ) ; } showPastItems = enable ; }
Toggles showing the past items . Past mode shows the yesterday and last weekday item .