SimplicityApks / ReminderDatePicker

A Google Keep-like Date and Time Picker for reminders
Apache License 2.0
74 stars 26 forks source link

Feature to add time items and date items manually #29

Closed chrisonline closed 8 years ago

chrisonline commented 9 years ago

Another user request from my app. Can you add a feature that the user can add there own time items and date items?

Some users don't need "Evening" with 17:00 instead they want 16:00 and so on ... So it would be great to make the "text" and the time manually changeable.

A method like "addDropDownElements" or something like that. So I can made a screen for the users where he can change and add time text and values. After that I create the DropDownElements for the spinner. The same for date.

SimplicityApks commented 9 years ago

Well technically you can do that right now with a couple of add-, remove-, and insertAdapterItem() calls, passing DateItems or TimeItems. But I know it is going to be messy as hell because the flag setting methods (and possibly others) are written without this in mind, assuming the spinner items are not changed externally. Also, adding a bunch of items at once or replacing all of them would be nice.

I'll see if I can find a way to implement that without having to rewrite the whole Adapter class breaking the flags...

chrisonline commented 9 years ago

Thanks, hopefully you can find a easy way. Would be a great feature.

SimplicityApks commented 9 years ago

OK so I thought about this a bit, and this is what I've come up with so far: We'll change the items so that each TwinTextItem has an ID (haven't decided whether that has to be unique or not). Then we'd add a removeAdapterItemById method to the PickerSpinner and rewrite the various setter methods in both spinners to rely on IDs instead of position. At that point you could already manually add and remove items (and I'll add a batch add method as well), but I want to go a little further and move the spinner item creation in the getSpinnerItems() method over to an xml file which you could then easily override to provide a completely different set of spinner items.

This is quite a bit of work as I'm unsure what bugs will arise from the item removing (especially when retaining the selection), so I'll see when I get some free time. I'll first do a 1.2.1 release to maven though, if that answers the question in the other issue ;)

chrisonline commented 9 years ago

I think this is a good idea. So if you find some free time let the show begin ;-)

Perfect, so I can use again the 'compile' feature once 1.2.1 is out ... At the moment I use the downloaded project with 'compile project'...

SimplicityApks commented 9 years ago

There you go, it took some time to get a couple of bugs sorted out, but now you can easily add and remove spinner items, both from xml and at runtime. This will be in version 1.3 as there were quite a few changes needed.

chrisonline commented 9 years ago

Wow amazing! Thanks.. Will check this once I find time!! Thanks again for such a quick implementation!!

SimplicityApks commented 8 years ago

Implemented in release 1.3.