Skip to content

Header Click Event #27

Open
Open
@rincyrose

Description

@rincyrose

How to get Calendar header click event.I need to show a datepicker on click header.

Activity

alamkanak

alamkanak commented on Dec 2, 2014

@alamkanak
Owner

Currently this feature is not available. Thanks for suggesting the idea 👍
Will let you know when the feature is available.

rincyrose

rincyrose commented on Dec 3, 2014

@rincyrose
Author

If you can make click event asap it will be very helpful for me to use this calendar in my app.

Thank you

dukerok

dukerok commented on Mar 29, 2016

@dukerok
        @Override
        public boolean onSingleTapConfirmed(MotionEvent e) {
            // If the tap was on an event then trigger the callback.
            if (mEventRects != null && mEventClickListener != null) {
                List<EventRect> reversedEventRects = mEventRects;
                Collections.reverse(reversedEventRects);
                for (EventRect event : reversedEventRects) {
                    if (event.rectF != null && e.getX() > event.rectF.left && e.getX() < event.rectF.right && e.getY() > event.rectF.top && e.getY() < event.rectF.bottom) {
                        mEventClickListener.onEventClick(event.originalEvent, event.rectF);
                        playSoundEffect(SoundEffectConstants.CLICK);
                        return super.onSingleTapConfirmed(e);
                    }
                }
            }
            // If the tap was on in an empty space, then trigger the callback.
            if (mEmptyViewClickListener != null && e.getX() > mHeaderColumnWidth && e.getY() > (mHeaderHeight + mHeaderRowPadding * 2 + mHeaderMarginBottom)) {
                Calendar selectedTime = getTimeFromPoint(e.getX(), e.getY());
                if (selectedTime != null) {
                    playSoundEffect(SoundEffectConstants.CLICK);
                    mEmptyViewClickListener.onEmptyViewClicked(selectedTime);
                }
            }

            //todo added
            if (mHeaderViewClickListener != null && e.getX() > mHeaderColumnWidth && e.getY() < (mHeaderHeight + mHeaderRowPadding * 2 + mHeaderMarginBottom)) {
                Calendar selectedTime = getTimeFromPoint(e.getX(), e.getY() + mHourHeight);
                if (selectedTime != null) {
                    playSoundEffect(SoundEffectConstants.CLICK);
                    mHeaderViewClickListener.onHeaderViewClicked(selectedTime);
                }
            }

            return super.onSingleTapConfirmed(e);
        }
basmasrour

basmasrour commented on Mar 1, 2017

@basmasrour

Where can I override onSingleTapConfirmed()? in which class?
And how to add HeaderViewClickListener?

dukerok

dukerok commented on Mar 1, 2017

@dukerok

As the solution, I suggest you to change a WeekView.mGestureListener (onSingleTapConfirmed() method) field realization. But the tricky part here is that this field has private access and that is why you cannot access him directly.

I suggest you to fork library sources, change implementation, recompile and then use this jar or class;

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @alamkanak@rincyrose@dukerok@basmasrour

        Issue actions

          Header Click Event · Issue #27 · alamkanak/Android-Week-View