Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saving and accessing decorators #1127

Open
dexter-ops opened this issue Jan 22, 2022 · 0 comments
Open

Saving and accessing decorators #1127

dexter-ops opened this issue Jan 22, 2022 · 0 comments

Comments

@dexter-ops
Copy link

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()
     }
 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant