realm-list

How do i prevent duplicates in RealmSwift List?

半城伤御伤魂 提交于 2019-12-05 07:47:42
How do I prevent adding duplicates to a list in RealmSwift ? I have my User as a realm object, but the real data source is a server (simply caching the user locally with Realm). When I get the current user data from my server, i want to make sure that my user stored in realm has all the playlists coming from the server (and that their in sync wrt list of tracks and etc.). I'm worried that if i loop over those lists from the server, appending to myUser.playlists , that I may end up adding the same playlist to the user's list of playlists multiple times. class User: Object { dynamic var name = "

RealmList of String Type in Android

泄露秘密 提交于 2019-12-04 23:46:52
I'm using Realm for Local storage in Android. I'm getting following response form server. [{ "ListId": 10, "Names": ["Name1", "Name2", "Name3", "Name4"] }] Here is my Model public class Model extends RealmObject { private int ListId; private RealmList<String> Names = new RealmList<String>() public int getListId() { return ListId; } public void setListId(int listId) { ListId = listId; } public RealmList<String> getNames() { return Names; } public void setNames(RealmList<String> names) { Names = names; } } And I'm getting this for ArrayList Type parameter 'java.lang.String' is not within its

How to add a nested List of objects in Realm “Error: JS value must be of type: object”

北战南征 提交于 2019-12-04 20:13:48
I'm trying to create Realm database that has a json array of objects with a nested array of objects. When I try to add using the code below I always get the error: JS value must be of type: object. Schemas: import Realm from 'realm'; class Exercise extends Realm.Object { } Exercise.schema = { name: 'Exercise', primaryKey: 'id', properties: { id: 'int', name: 'string', category: 'string', bodyPart: 'string', levels: {type: 'list', objectType: 'Level'} } }; class Level extends Realm.Object { } Level.schema = { name: 'Level', properties: { level: 'int', equipments: 'string' } }; export default

Realm Android exception occured during performFiltering()!

对着背影说爱祢 提交于 2019-12-04 06:44:18
问题 The app worked fine when I used Spinner. But when I tried AutoComplete Textview instead of Spinner, nothing is displayed when I type on it. Any help is appreciated. Logcat Warn: 08-23 14:01:13.485 9542-9542/com.vyshnav.realmexample W/art: Failed to find OatDexFile for DexFile /data/data/com.vyshnav.realmexample/files/instant-run/dex/slice-slice_9-classes.dex ( canonical path /data/data/com.vyshnav.realmexample/files/instant-run/dex/slice-slice_9-classes.dex) with checksum 0x0486ffcc in

Realm, network operations, subscribing and observing on different threads with RxJava

。_饼干妹妹 提交于 2019-12-03 09:11:24
I need to : Fetch some data from an API on a background thread Display the data on the UI Save to Realm. fetchItemsFromServer().subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<ItemList>() { @Override public void call(ItemList items) { displayItems(items); try { realm.beginTransaction(); realm.copyToRealmOrUpdate(itemList); realm.commitTransaction(); Logger.v("Realm ", "Copied list object to realm"); } catch (Exception e) { Logger.e("Realm Something went wrong ", e); realm.cancelTransaction(); } } } This throws an error : realm accessed from

Realm - Can't use object after having been deleted

三世轮回 提交于 2019-11-30 22:02:10
I have a video player in my app. There is a list of videos in a collection view. If you tap on one of the cells, a new view controller appears to play the selected video. Also, you can cycle through all of the videos from the collection view in this new view controller because the entire list is passed. The problem is: When the user is in the PlayerVC , they can unfavorite a Video . If they do this, I delete the Video object from Realm. However, this causes a: Terminating app due to uncaught exception 'RLMException', reason: 'Object has been deleted or invalidated.' Basically, if a user is

Realm - Can't use object after having been deleted

狂风中的少年 提交于 2019-11-30 18:01:06
问题 I have a video player in my app. There is a list of videos in a collection view. If you tap on one of the cells, a new view controller appears to play the selected video. Also, you can cycle through all of the videos from the collection view in this new view controller because the entire list is passed. The problem is: When the user is in the PlayerVC , they can unfavorite a Video . If they do this, I delete the Video object from Realm. However, this causes a: Terminating app due to uncaught

Android Realm - findAll returns objects with null parameters [duplicate]

*爱你&永不变心* 提交于 2019-11-28 03:13:20
问题 This question already has an answer here: Cannot retrieve field values from realm object, values are null in debugger 3 answers I need to do a simple query in Realm, retrieve a list of MyModel object and later use it somewhere else in my app. It happens that once I query Realm, each object has null values, but the toString returns the expected values. Model: @RealmClass public class MyModel extends RealmObject implements Serializable { public static final String KEY_MODEL = "key_myModel";

How can I set LIMIT in query in Realm?

早过忘川 提交于 2019-11-28 00:27:42
I have done R&D for limit in query with no success. There is one way with which to paginate data in Realm with sub list but no success with that. It shows duplicate value in it. Here is what I attempted for pagination. RealmResults<Person> mPersonData=RealmUtils.getAllPersonWithTagsDescending(); if (mPersonData != null) { int startPos=getAllPerson.size()-1; int endPos=mPersonData.size()-1; List<Person> newPersonData=mPersonData.subList(startPos,endPos); getAllPerson.addAll(newPersonData); mAdapter.notifyDataSetChanged(); } What am I doing wrong? You can use limit from Realm 5.6.0+. It looks

How can I set LIMIT in query in Realm?

半腔热情 提交于 2019-11-26 21:43:25
问题 I have done R&D for limit in query with no success. There is one way with which to paginate data in Realm with sub list but no success with that. It shows duplicate value in it. Here is what I attempted for pagination. RealmResults<Person> mPersonData=RealmUtils.getAllPersonWithTagsDescending(); if (mPersonData != null) { int startPos=getAllPerson.size()-1; int endPos=mPersonData.size()-1; List<Person> newPersonData=mPersonData.subList(startPos,endPos); getAllPerson.addAll(newPersonData);