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

onEventClick and onEventViewClick not fired #23

Open
reuniware opened this issue Jan 3, 2020 · 0 comments
Open

onEventClick and onEventViewClick not fired #23

reuniware opened this issue Jan 3, 2020 · 0 comments

Comments

@reuniware
Copy link

reuniware commented Jan 3, 2020

Hello !
I'm trying to use your component in a Kotlin project but I cannot have these events fired when I click anywhere in the visible control...
Here is the Kotlin code :

package com.reuniware.beautylogic

import android.os.Bundle
import android.util.Log
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import com.framgia.library.calendardayview.EventView
import com.framgia.library.calendardayview.EventView.OnEventClickListener
import com.framgia.library.calendardayview.data.IEvent
import com.framgia.library.calendardayview.decoration.CdvDecorationDefault
import kotlinx.android.synthetic.main.activity_main.*


class MainActivity : AppCompatActivity() {

    val events = ArrayList<IEvent>()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        (dayView.decoration as CdvDecorationDefault).setOnEventClickListener(
            object : OnEventClickListener {
                override fun onEventClick(view: EventView, data: IEvent) {
                    Log.e("TAG", "onEventClick:" + data.name)
                }

                override fun onEventViewClick(
                    view: View,
                    eventView: EventView,
                    data: IEvent
                ) {
                    Log.e("TAG", "onEventViewClick:" + data.name)
                    if (data is IEvent) { // change event (ex: set event color)
                        dayView.setEvents(events)
                    }
                }
            })

        dayView.setEvents(events)
    }
}

And here is the code of the XML layout file :

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="24dp"
        android:layout_marginBottom="24dp"
        android:layout_marginStart="24dp"
        android:layout_marginEnd="24dp">
        <com.framgia.library.calendardayview.CalendarDayView
            android:id="@+id/dayView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </ScrollView>

</androidx.constraintlayout.widget.ConstraintLayout>

Thanks in advance !

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