prolificinteractive / material-calendarview

A Material design back port of Android's CalendarView
https://prolificinteractive.github.io/material-calendarview/
MIT License
5.91k stars 1.32k forks source link

I can't use copyTo() #1106

Open Young-Seok-Kim opened 3 years ago

Young-Seok-Kim commented 3 years ago

I tried for someday's color change but i can't use copyTo i leave part of my code please advise me. I did import for materialcalendarvie thank you

import com.prolificinteractive.materialcalendarview.CalendarDay import com.prolificinteractive.materialcalendarview.DayViewDecorator import com.prolificinteractive.materialcalendarview.DayViewFacade

....

override fun shouldDecorate(day: CalendarDay): Boolean
{
     day?.copyTo(calendar)// calendar 변수에 day 변수 저장
    val weekDay = calendar[Calendar.DAY_OF_WEEK] // calendar 변수에서 무슨 요일인지 가져옴
    return weekDay == Calendar.SATURDAY // 가져온 calendar 변수 요일이 토요일이면 True
}

this is error message [Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: public fun File.copyTo(target: File, overwrite: Boolean = ..., bufferSize: Int = ...): File defined in kotlin.io public fun InputStream.copyTo(out: OutputStream, bufferSize: Int = ...): Long defined in kotlin.io public fun Reader.copyTo(out: Writer, bufferSize: Int = ...): Long defined in kotlin.io]

haeinkkk commented 3 years ago

int sunday = day.getDate().with(DayOfWeek.SATURDAY).getDayOfMonth(); return sunday == day.getDay();

Young-Seok-Kim commented 3 years ago

I find why can't use copyTo() i fixed material calendar version 2.0.1 -> 1.4.3

haeinkkk commented 3 years ago

한국인이시져??? 제가 영어를 못해서 한국말로 할께욯 ㅎㅎㅎ 자바에서는 copyTo() 사ㅓ용하지않고 위방법으로 정상동작되는데 코틀린에서는 잘 모르겠네여.. 아마 같은메소드가 잇지 않을까 생각이 듭니다만,,ㅠㅠ

Young-Seok-Kim commented 3 years ago

네! 코틀린으로 위방법대로 했는데 잘 안되더라구요 ㅜㅜ 라이브러리 버전을 내렸더니 정상작동했습니다! 라이브러리가 업데이트 되면서 해당 메소드 지원을 안하는건지 ㅜㅜ 덕분에 잘 고쳤습니다 감사합니다 ㅎㅎ

sorongosdev commented 1 year ago

버전 2.0.1 기준 코틀린 코드는 다음과 같습니다. 여기서 DayOfWeek.SATURDAYimport org.threeten.bp.DayOfWeek 를 통해 불러와야합니다.

class SaturdayDecorator: DayViewDecorator { override fun shouldDecorate(day: CalendarDay?): Boolean { val sunday = day?.date?.with(DayOfWeek.SATURDAY)?.dayOfMonth return sunday == day?.day } override fun decorate(view: DayViewFacade?) { view?.addSpan(object: ForegroundColorSpan(Color.BLUE){}) } }

songmik commented 1 year ago

2.0.0 업데이트 부터 copyTo() 사용이 안되네요. 2.0.1 버전을 1.6.1으로 바꿔도 사용 가능 합니다.

I think can't use copyTo() from version 2.0.0. So You have to change the version 2.0.1 to 1.6.1. It helped me.