code-troopers / android-betterpickers

[NO LONGER MAINTAINED] Android library for better Picker DialogFragments
2.68k stars 566 forks source link

Fixes bug #350 #376

Open carrizo opened 6 years ago

carrizo commented 6 years ago

This solves bug #350

I did reproduce the error described by @Rx2TF which throws this exception: java.lang.ArrayIndexOutOfBoundsException: length=5; index=-1

Looks like EventRecurrence#parse() method is leaving some garbage data in the EventRecurrence#byday field. This can be reproduced calling parse() two times, one with a weekly recurrence and then with a monthly recurrence; after this, the byday field keeps some data from the first call.

I didn't solve the root problem in EventRecurrence class because it looks like I can easily break something there.

potatopeelings commented 6 years ago

@carrizo - I believe a cleaner way to fix this would be to make recurrence.byday be null

I made the following changes to fix this issue. Give it a shot and let me know if you run into any issues.

  1. byday = null; to resetFields in EventRecurrence.java This takes care of updates via a parse.
    1. eventRecurrence.byday = null; to the end of the first if block in case RecurrenceModel.FREQ_MONTHLY: in copyModelToEventRecurrence in RecurrencePickerDialogFragment.java This takes care of updates via the UI.

Cheers!