forrestguice / SuntimesCalendars

A calendar provider add-on for Suntimes.
GNU General Public License v3.0
32 stars 11 forks source link

Feature request: provide calendars for all events #9

Closed robinpaulson closed 5 years ago

robinpaulson commented 5 years ago

That is, one for sunset (every day), one for sunrise (ditto), one for moon rise, for nautical twilight and so on and so on....

I currently create my own with pyephem and import them, but I'm sure others would appreciate it happening via an app like this.

forrestguice commented 5 years ago

Added this in v0.3.0. It should be on F-Droid in the next week or so.

To simplify things I'm only showing the twilight periods (so if interested in sunrise/sunset times you'd select Civil Twilight). I haven't added solar noon, or the blue or golden hours (but those are of course possible if somebody finds it useful). I'm open to additions / changes.

It is very slow.. probably much slower than your pyephem solution. On an older device it takes several minutes per twilight calendar. I think its a combination of retrieving events through a ContentProvider, and then writing to the Calendar via another. The ContentProvider mechanism itself just seems very inefficient.

robinpaulson commented 5 years ago

Oh, that's excellent, cheers.

I wonder if there are other methods of creating and importing the calendar data, short-circuiting the contentprovider mechanism?

forrestguice commented 4 years ago

I wonder if there are other methods of creating and importing the calendar data

I've taken another look at this. There is a huge performance improvement when using bulkInsert. It seems a lot of time is spent indexing events after each call. After a quick benchmark, it takes ~60s to insert 2000 events individually, which can be reduced to 25s by inserting 128 at a time, or 10s by inserting just twice. Unfortunately there is a limit on the size of the data (or we could bulkInsert just once). The progress animation is also updated less frequently - it doesn't really "look" fast despite it being objectively faster.