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

Using clicked empty cell as a button. #3

Open
ff50885 opened this issue Oct 4, 2020 · 0 comments
Open

Using clicked empty cell as a button. #3

ff50885 opened this issue Oct 4, 2020 · 0 comments

Comments

@ff50885
Copy link

ff50885 commented Oct 4, 2020

Hi, is there any way to use cells as button for add a new schedule after click second time. And in the first click to cell change backgorund as plus mark or something like that.

I used code below. But it's not realy productive and work slowly.

`
table.setOnTimeCellClickListener(
object :OnTimeCellClickListener{
override fun timeCellClicked(scheduleDay: Int, time: Int) {

                if (add_schedule_key){
                    scheduleList.removeLast()
                    table.updateSchedules(scheduleList)
                    add_schedule_key = false
                }

                val start_time = schedule_add_start_time(time)
                val end_time = schedule_add_end_time(start_time)

                val schedule_add_schedule = ScheduleEntity(
                    999, //originId
                    "ADD PLAN", //scheduleName
                    "", //roomInfo
                    scheduleDay, //ScheduleDay object (MONDAY ~ SUNDAY)
                    start_time, //startTime format: "HH:mm"
                    end_time, //endTime  format: "HH:mm"
                    "#3F51B5", //backgroundColor (optional)
                )

                scheduleList.add(schedule_add_schedule)
                table.updateSchedules(scheduleList)
                add_schedule_key = true

                schedule_add_schedule.setOnClickListener(View.OnClickListener {
                    val action = week_timetableDirections.actionWeekTimetableToAddSchedule()
                    Navigation.findNavController(table).navigate(action)
                    add_schedule_key = false
                    scheduleList.remove(schedule_add_schedule)
                    table.updateSchedules(scheduleList)
                })
            }
    })`
private fun schedule_add_start_time (clicked_time : Int): String {
    var star_time = clicked_time.toString()

    if (star_time.length == 1){
        star_time = "0$star_time:00"
    }else{
        star_time = "$star_time:00"
    }
    return  star_time
}

private fun schedule_add_end_time (star_time : String): String {
    var end_time = (((star_time[0].toString() + star_time[1].toString()).toInt()) + 1).toString()
    end_time = "$end_time:00"
    return end_time
}`
@ff50885 ff50885 changed the title Use clicked empty cell ass button. Using clicked empty cell as a button. Oct 4, 2020
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