vikramkakkar / SublimePicker

A material-styled android view that provisions picking of a date, time & recurrence option, all from a single user-interface.
Apache License 2.0
2.31k stars 407 forks source link

Feature/date range without long press #73

Open kiewietn opened 7 years ago

kiewietn commented 7 years ago

This resolves issue #53 . SublimeOptions have been modified to change behaviour between existing long press for date range selection and 2 taps for range selection.

Use the option SublimeOptions.setToggleRangeWithoutLongPress(true) when initializing SublimePicker.

kevinliu23 commented 6 years ago

@vikramkakkar Hi Vikram, can I get some help on an issue. I'm trying to implement the following behavior but having trouble.

Click on a day to select it, long click on the second date to select the range between the two dates.

Can you do it or show me show me in the right direction. Here is what I've tried:

I see that on DayPickerViewPager.java class, the place where you set mIsLongPressed = true is where you determine if it's been long pressed, I was able to keep track of the last start date and modify the mTempSelectedDate's start or end date (depending on which date is before or after the other). But there are small bugs here and there, mainly to do with

tvHeaderDateStart.setActivated(mCurrentlyActivatedRangeItem == RANGE_ACTIVATED_START); tvHeaderDateEnd.setActivated(mCurrentlyActivatedRangeItem == RANGE_ACTIVATED_END);

In SublimeDatePicker.java and some other issues.

Would you happen to know an easy to way to simply do this:

1) Given the user has 1 day selected (not a date range), if user long clicks on a different date, select the date range. 2) If user repeats the long click action while a date range is selected, it would just extend/modify the current date range to include that date.

SebRut commented 5 years ago

@vikramkakkar @vikram-kakkar Could you check this PR?