Commit fdfd0d1d authored by Yusuke Iwaki's avatar Yusuke Iwaki Committed by GitHub

Merge pull request #127 from RocketChat/fix_realm_object_listener

fix the issue that RealmObjectObserver's callback is called repeatedly
parents 6b8122be 1ec79026
...@@ -30,7 +30,7 @@ public class RealmListObserver<T extends RealmObject> extends AbstractRealmResul ...@@ -30,7 +30,7 @@ public class RealmListObserver<T extends RealmObject> extends AbstractRealmResul
@Override @Override
public final RealmChangeListener<RealmResults<T>> getListener() { public final RealmChangeListener<RealmResults<T>> getListener() {
return results -> { return results -> {
String currentResultString = results != null ? results.toString() : null; String currentResultString = results != null ? results.toString() : "";
if (previousResultsString != null && previousResultsString.equals(currentResultString)) { if (previousResultsString != null && previousResultsString.equals(currentResultString)) {
return; return;
} }
......
...@@ -37,7 +37,7 @@ public class RealmObjectObserver<T extends RealmObject> extends AbstractRealmRes ...@@ -37,7 +37,7 @@ public class RealmObjectObserver<T extends RealmObject> extends AbstractRealmRes
protected final RealmChangeListener<RealmResults<T>> getListener() { protected final RealmChangeListener<RealmResults<T>> getListener() {
return element -> { return element -> {
T currentResult = impl.extractObjectFromResults(element); T currentResult = impl.extractObjectFromResults(element);
String currentResultString = currentResult != null ? currentResult.toString() : null; String currentResultString = currentResult != null ? currentResult.toString() : "";
if (previousResultString != null && previousResultString.equals(currentResultString)) { if (previousResultString != null && previousResultString.equals(currentResultString)) {
return; return;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment