-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RealmCursor #1090
RealmCursor #1090
Conversation
cursor = realm.allObjects(AllTypes.class).getCursor(); | ||
} | ||
|
||
private void populateTestRealm(Realm realm, int objects) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use this is almost all our test modules. Why don't we move to a helper class?
table = null; // Instead of closing the table, we just release it. Original RealmResults would also be closed otherwise. | ||
realm.removeChangeListener(changeListener); | ||
dataSetObservable.notifyInvalidated(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's safe to call contentObservable.unregisterAll()
at this point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. It has been added.
Reverting to WIP status. There are some details about ContentObservers and NotificationUri's that needs to be discussed as it is probably also part of #989 |
Conflicts: realm/src/androidTest/java/io/realm/RealmResultsTest.java realm/src/androidTest/java/io/realm/RealmTest.java realm/src/androidTest/java/io/realm/TestHelper.java
private static final int FIELD_TYPE_STRING; | ||
private static final int FIELD_TYPE_BLOB; | ||
static { | ||
if (android.os.Build.VERSION.SDK_INT >= 11) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This branch can be removed.
Constant values are always inlined(http://docs.oracle.com/javase/specs/jls/se7/html/jls-13.html#jls-13.1-110-C).
This means there will be no reference to Cursor.FIELD* in class file.
Is Cursor example still not ready? |
No, there is work on it here though: realm/realm-android-adapters#53 |
I'm trying to switch from SQLite to Realm while I'm on early stage of project. |
What is also not quite clear for me from documentation... |
We don't support LIMIT yet, but since RealmResults are lazy-loaded, you normally don't need it anyway. You can use |
Thank you for suggestion. Today I also stumbled upon the limitation trying to extend class from external library. |
Closing this PR as it is now being tracked realm/realm-android-adapters#6 instead |
Fixes #438
Missing
ContentProviders exposes a cursor, which works fine if used within a app. However it breaks if shared with another app:
We can ship RealmCursor with the explicit caveat that it doesn't work with ContentProviders across apps, but it is not ideal.
Description
This adds a Cursor implementation for Realm data. The main challenge is mapping the very limited types in SQLite to the more expressive types in Realm.
The current approach is to respect the Cursor interface as much as possible as that is what will be exposed in ContentProviders and other framework classes.
This has the following implications:
I have a single new method
setIdColumn(String columnName)
that creates a virtual "_id" field used by many framework classes. This should be acceptable as it is defined when the Cursor is created and the developer know it is a ReamCursor. Adding other nice methods likegetDate()
should be avoided as client code should only interact with the cursor using the Interface.Note that RealmCursor just reuses the tableview backing the RealmResults. This means that any changes to RealmResults will be reflected in the RealmCursor. I am not sure this behaviour is developer friendly but AFAIK we cannot lock the tableview until we start implementing Async queries.
@emanuelez @kneth @bmunkholm