Last active
August 29, 2015 14:19
-
-
Save kevinvanmierlo/3e7f37b25fcd3ccf0223 to your computer and use it in GitHub Desktop.
Revisions
-
kevinvanmierlo revised this gist
Apr 15, 2015 . 6 changed files with 0 additions and 3 deletions.There are no files selected for viewing
File renamed without changes.File renamed without changes.File renamed without changes.This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1 +0,0 @@ This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1 +0,0 @@ This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1 +0,0 @@ -
kevinvanmierlo created this gist
Apr 15, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ Person: This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ public class Person extends RealmObject { @PrimaryKey private int id; private String name; public int getId() { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ Group: This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ public class Group extends RealmObject { private RealmList<Person> persons; public RealmList<Person> getPersons() { return persons; } public void setPersons(RealmList<Person> persons) { this.persons = persons; } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ Testing code: This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,45 @@ Realm realm = Realm.getInstance(this); realm.beginTransaction(); Group group; if(realm.allObjects(Group.class).size() == 0) { group = realm.createObject(Group.class); }else { group = realm.allObjects(Group.class).first(); } realm.commitTransaction(); for(int i = 1; i <= 10; i++) { Person person = new Person(); person.setId(i); person.setName("Name " + i); realm.beginTransaction(); Person databasePerson = realm.copyToRealmOrUpdate(person); realm.commitTransaction(); group.getPersons().add(databasePerson); } for(int i = 0; i < 10; i++) { System.out.println("first list: " + group.getPersons().get(i).getName()); } group.getPersons().move(1, 0); // Gets handled correctly for(int i = 0; i < 10; i++) { System.out.println("second list - move up: " + group.getPersons().get(i).getName()); } group.getPersons().move(0, 1); // Same as second list, but should be the same as the first list for(int i = 0; i < 10; i++) { System.out.println("third list - move down: " + group.getPersons().get(i).getName()); }