3 ms·
Just as a heads up your documentation doesn't work with the newest version of the Android Gradle plugin (0.13.0), see here: http://stackoverflow.com/a/25939518/
by jc4p 12y ago
Just as a heads up your documentation doesn't work with the newest version of the Android Gradle plugin (0.13.0), see here: http://stackoverflow.com/a/25939518/472021 http://stackoverflow.com/a/25939518/472021
the `android-apt` dependency needs to be switched to 1.4 else you get:
A problem occurred configuring project ':cachetest'.
> No such property: projectDependencies for class: com.android.build.gradle.internal.api.ApplicationVariantImpl_Decorated
Edit #1: Is there any way to instantiate my RealmObject from JSON? I'm currently using GSON to take API calls <--> POJOs, I can't figure out any way to do this using Realm since models "must be instantiated from the Realm using the realm.createObject() instance method".
Edit #2: Okay I have no idea how to use this. Given a list of `Object`, how do I make a `RealmList` of it? Do I have to use Realm.createObject? Is there not any way of just taking a couple already instantiated versions of an object and jamming them into a `RealmList`?
I was really excited about trying this out (the Stack Exchange app currently has a 37ms delay on a cold start to get the list of all of our sites back into active memory) but this does not look like it's going to be easy to use.
- timanglade 12y agoThanks for the heads-up! We’ll get that fixed shortly. We do support JSON (and GSON) — you can see it at work in our gridViewExample (https://github.com/realm/realm-java/tree/master/examples/gridViewExample https://github.com/realm/realm-java/tree/master/examples/gri...)
- jc4p 12y agoEek so I actually have to make/use a setter for every single attribute of my models? That's definitely a deal breaker for me.
- timanglade 12y agoWe’re still exploring ways to let people use public properties instead, but that’s one of the things that is hard to do without copying (and paying the huge performance price associated with it).
- tburch 12y agotry using http://projectlombok.org/ http://projectlombok.org/
- greyskull 12y agoThat's neat. I'll have to keep that in mind for the future. I wish Java would take a hint from C# properties through :(
- emanuelez 12y agoThanks for the heads up! We will address that right away. Also, one of the examples (GridViewExample) in the release reads JSON data with GSON.
- timanglade 12y agoThis is good feedback — we definitely expect to be polishing the API quite a bit in the weeks to come, just like we did on iOS> You have to use Realm.createObject because objects are strongly tied to one Realm at a time. We could introduce standalone objects you can create with regular constructors but you’d be a really heft performance hit there. RealmLists are mostly used to model relationships at this point, so you could add them to a another model like (http://realm.io/docs/java/0.70.1/#relationships http://realm.io/docs/java/0.70.1/#relationships) although eventually we do want to introduce standalone RealmLists. What would you expect to use multiple RealmObjects in a single RealmList for? (Just so we can learn from your use-case.)
- jc4p 12y agoI was trying to add in a Realm test to a benchmarking project I already have set up to see how quickly I can retrieve a list of Stack Exchange sites from disk/db/etc, the Site model is laid out here: https://api.stackexchange.com/docs/types/site https://api.stackexchange.com/docs/types/site -- each Site object can have anywhere from 0 to N related_site objects, which in my current model I just have as a RelatedSite[], since my test case is running all the different ways to cache/read at the same time I was trying to make a method in my RealmObject version of Site that takes in a regular Site object and transforms everything over, but I couldn't figure out how to translate the RelatedSite[] array into a RealmList<RelatedSite> without actually iterating through every one and recreating them by hand.
- emanuelez 12y agoThank you for bringing the subject up! Importing data from JSON in a painless way is very high on the priority list. Right now we don't have an elegant solution for your specific use-case, but we're working on it so stay tuned! Please feel free to join us in the mailing list as we would love to hear more about your project and help with it if possible!