Closed Egorand closed 2 years ago
As Android developer I can say that it would be really nice to add Loader pattern support to ORMLite.
Why there's been no feedback on this pull request yet?
Sorry for not responding sooner. The problem with this is that it requires a higher version of Android, correct. But the worse case is a compilation error if you try to use these classes on a lower version of Android, right?
It would require the support v4 package to compile, and presumably would only throw a ClassNotFoundException if an app attempted to use them without the support jar.
We've been doing something similar in our apps, although nothing quite open-sourceable, although its always been on the todo list. It would be great to have easy access to loaders and ORMLite. Will take a look at this when I get a chance as well.
-Kevin
On Thu, Oct 24, 2013 at 10:39 AM, Gray notifications@github.com wrote:
Sorry for not responding sooner. The problem with this is that it requires a higher version of Android, correct. But the worse case is a compilation error if you try to use these classes on a lower version of Android, right?
— Reply to this email directly or view it on GitHubhttps://github.com/j256/ormlite-android/pull/5#issuecomment-26997776 .
Thanks for replying. Yes, it uses the support version of Loaders, so it requires the support-v4 library. However, the dependency to support-v4 is marked as optional, so there's no need to use it if you're not planning to use the Loaders.
Hi guys What is a loader? Can you point me a link whit some ifo? Thanks!!! El 24/10/2013 11:49, "kpgalligan" notifications@github.com escribió:
It would require the support v4 package to compile, and presumably would only throw a ClassNotFoundException if an app attempted to use them without the support jar.
We've been doing something similar in our apps, although nothing quite open-sourceable, although its always been on the todo list. It would be great to have easy access to loaders and ORMLite. Will take a look at this when I get a chance as well.
-Kevin
On Thu, Oct 24, 2013 at 10:39 AM, Gray notifications@github.com wrote:
Sorry for not responding sooner. The problem with this is that it requires a higher version of Android, correct. But the worse case is a compilation error if you try to use these classes on a lower version of Android, right?
— Reply to this email directly or view it on GitHub< https://github.com/j256/ormlite-android/pull/5#issuecomment-26997776> .
— Reply to this email directly or view it on GitHubhttps://github.com/j256/ormlite-android/pull/5#issuecomment-26998702 .
Loaders load and monitor data for changes, and live a bit outside of the fragment/activity lifecycle. They're generally preferred to AsyncTask for similar methods of loading data.
http://developer.android.com/guide/components/loaders.html
The general design is for use with ContentProvider, but I'm personally not a fan on ContentProvider, so we use AsyncTaskLoader.
This implementation should be extended somewhat to provider for a way of listening to updates, and I would also say a way to use a cursor rather than load all data at once. Have seen some implementations like this before.
On Sat, Oct 26, 2013 at 9:21 PM, ddfire notifications@github.com wrote:
Hi guys What is a loader? Can you point me a link whit some ifo? Thanks!!!
Thanks
Ok. I've just checked this code into android trunk. Sorry for the delay. Thanks much EgorAnd!! I could not just merge in the pull request for some reason so I just copied the classes in. I've got a couple XXX comments in there in places to mark outstanding questions. I've also tweaked formatting, used protected fields, etc.. Comments, welcome.
Hey, can someone write a little HelloAndroid like program using Loaders so I can check it in as an example and play with it?
Thank you for taking a look at it, really glad I could contribute. I'm sure I have a sample app using the OrmLiteLoader somewhere, I can add it when I have some spare time. BTW, what will be the right place to put it?
Could you guys provide an example app to use this?
And if I try to use this, will it be an improvement over loading data with standard RuntimeExceptionDao? I mean, standard DAO queries on main thread? I am looking for a way to get my results asynchronously, that's why I'm here. But only if this will improve my performance.
Also, will classes written by Egorand work with RuntimeExceptionDao? And it does't yet provide a functionality of auto-updating data in adapters?
Here's a different loader and adapter implementation that supports notifications and includes a sample application: https://github.com/j256/ormlite-android/pull/8
That's been on our verbal todo list for a while, but never seem to find the time ;)
Will take a look if I can figure out how to check out a pull request properly.
On Sat, Apr 5, 2014 at 1:45 AM, Mike Burton notifications@github.comwrote:
Here's a different loader and adapter implementation that supports notifications and includes a sample application: #8https://github.com/j256/ormlite-android/pull/8
Reply to this email directly or view it on GitHubhttps://github.com/j256/ormlite-android/pull/5#issuecomment-39629780 .
@emmby 's implementation works like a charm. using it with my app. right now three different data models and thus three loaders. more to come. so far so good. thanks mate!
glad to hear it!
I've decided to use Emmby's loading implementation @Egorand. Thanks for your work however. Have you had a chance to review it? Any comments?
Unfortunately haven't had a chance to take a look, but would love to when I have time. Thanks @emmby !
This is good news everyone! I have been waiting for a long time to be able to use ORMLite in conjuction with CursorLoaders. When could we expect this to be released?
Hello guys , when this feature will be available ?
FYI I just came across this implementation of a CursorLoader / ListLoader: https://github.com/campnic/ormlite-android-extras - it's quite similar to what I've put together in my latest app.
@hadimichael thanks I will check this implementation :-)
@j256 Do you need some help to test the implementation ? I will be glad to help you !
Hello guys, any update on this ?
@Egorand I tried your loader implementation, it's very slow. Can you show me best practice of using this loader to really fast and much good result than call from UI thread ?
I usually use Loaders when populating lists with data, so I've made a couple of Loader implementations for executing queries. There are more ways to query the database in ORMLite, so I'm planning to add more implementations, or maybe find a more generic way to cover all use-cases.
Please let me know if there's anything I can add like unit tests or additional documentation. Thank you.