public boolean addChild(int position, E element) { ListDiffEntry diffentry = Diffs.createListDiffEntry(position, true, element); boolean res = elements.add(element); final ListDiff diff = Diffs.createListDiff(diffentry); Realm realm = getRealm(); Assert.isNotNull(realm, REALM_MUST_NOT_BE_NULL); realm.exec( new Runnable() { @Override public void run() { if (!isDisposed()) { fireListChange(diff); } } }); return res; }
public boolean removeChild(E element) { final int index = elements.indexOf(element); ListDiffEntry diffentry = Diffs.createListDiffEntry(index, false, element); boolean res = elements.remove(element); final ListDiff diff = Diffs.createListDiff(diffentry); Realm realm = getRealm(); Assert.isNotNull(realm, REALM_MUST_NOT_BE_NULL); realm.exec( new Runnable() { @Override public void run() { if (!isDisposed()) { fireListChange(diff); } } }); return res; }