private Calendar getTimeFromPoint ( float x , float y ) { int leftDaysWithGaps = ( int ) - ( Math . ceil ( mCurrentOrigin . x / ( mWidthPerDay + mColumnGap ) ) ) ; float startPixel = mCurrentOrigin . x + ( mWidthPerDay + mColumnGap ) * leftDaysWithGaps + mHeaderColumnWidth ; for ( int dayNumber = leftDaysWithGaps + 1 ; dayNumber <= leftDaysWithGaps + mNumberOfVisibleDays + 1 ; dayNumber ++ ) { float start = ( startPixel < mHeaderColumnWidth ? mHeaderColumnWidth : startPixel ) ; if ( mWidthPerDay + startPixel - start > 0 && x > start && x < startPixel + mWidthPerDay ) { Calendar day = today ( ) ; day . add ( Calendar . DATE , dayNumber - 1 ) ; float pixelsFromZero = y - mCurrentOrigin . y - mHeaderHeight - mHeaderRowPadding * 2 - mTimeTextHeight / 2 - mHeaderMarginBottom ; int hour = ( int ) ( pixelsFromZero / mHourHeight ) ; int minute = ( int ) ( 60 * ( pixelsFromZero - hour * mHourHeight ) / mHourHeight ) ; day . add ( Calendar . HOUR , hour ) ; day . set ( Calendar . MINUTE , minute ) ; return day ; } startPixel += mWidthPerDay + mColumnGap ; } return null ; }
Get the time and date where the user clicked on .