Skip to content

Saving and accessing decorators #1127

Open

Description

@dexter-ops

I have implemented code through which a user can add decorators through a button click. But how do I permanently save it.
Here is my decorator class:

class RedMarkDecorator(context: MainActivity?, currentDay: CalendarDay?) : DayViewDecorator {
        var myDay = currentDay
        var color = RED
        override fun shouldDecorate(day: CalendarDay?): Boolean {
            return day == myDay
        }

        override fun decorate(view: DayViewFacade) {
            view.addSpan(DotSpan(7f, color))
        }
    }

onDateSelected:

override fun onDateSelected(
     widget: MaterialCalendarView,
     date: CalendarDay,
     selected: Boolean
 ) {
     // Toast.makeText(context,"$date",Toast.LENGTH_SHORT).show()
     redButton.isVisible = true
     greenButton.isVisible = true
     clearButton.isVisible = true
     val thisDate = calendarView.selectedDate?.date
     val date: CalendarDay = CalendarDay.from(thisDate)
     redButton.setOnClickListener {
         calendarView.addDecorator(RedMarkDecorator(myActivity, date))
     }

     greenButton.setOnClickListener {
         calendarView.addDecorator(GreenMarkDecorator(myActivity, date))
     }

     clearButton.setOnClickListener {
         calendarView.removeDecorator(RedMarkDecorator(myActivity,date))
         Toast.makeText(context,"cancel clicked",Toast.LENGTH_SHORT).show()
     }
 }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions