Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AloqaIM-Android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
AloqaIM-Android
Commits
2aeaa74a
Commit
2aeaa74a
authored
Nov 25, 2016
by
Yusuke Iwaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve "Stops the same object from been propagated over and over as if updated"
parent
32229162
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
15 deletions
+10
-15
RealmObjectObserver.java
...chat/rocket/android/realm_helper/RealmObjectObserver.java
+10
-15
No files found.
realm-helpers/src/main/java/chat/rocket/android/realm_helper/RealmObjectObserver.java
View file @
2aeaa74a
...
...
@@ -20,10 +20,6 @@ public class RealmObjectObserver<T extends RealmObject> extends AbstractRealmRes
protected
T
extractObjectFromResults
(
RealmResults
<
T
>
results
)
{
return
results
.
isEmpty
()
?
null
:
results
.
last
();
}
protected
boolean
isSame
(
T
element1
,
T
element2
)
{
return
element1
.
equals
(
element2
);
}
}
private
final
Query
<
T
>
query
;
...
...
@@ -45,23 +41,21 @@ public class RealmObjectObserver<T extends RealmObject> extends AbstractRealmRes
return
this
;
}
private
T
previousResult
;
private
String
previousResultString
;
@Override
protected
final
RealmResults
<
T
>
queryItems
(
Realm
realm
)
{
@Override
protected
final
RealmResults
<
T
>
queryItems
(
Realm
realm
)
{
return
query
.
query
(
realm
).
findAll
();
}
@Override
protected
final
RealmChangeListener
<
RealmResults
<
T
>>
getListener
()
{
@Override
protected
final
RealmChangeListener
<
RealmResults
<
T
>>
getListener
()
{
return
new
RealmChangeListener
<
RealmResults
<
T
>>()
{
@Override
public
void
onChange
(
RealmResults
<
T
>
element
)
{
@Override
public
void
onChange
(
RealmResults
<
T
>
element
)
{
T
currentResult
=
impl
.
extractObjectFromResults
(
element
);
if
(
previousResult
!=
null
&&
impl
.
isSame
(
previousResult
,
currentResult
))
{
String
currentResultString
=
currentResult
!=
null
?
currentResult
.
toString
()
:
null
;
if
(
previousResultString
!=
null
&&
previousResultString
.
equals
(
currentResultString
))
{
return
;
}
previousResult
=
currentResult
;
previousResult
String
=
currentResultString
;
if
(
onUpdateListener
!=
null
)
{
onUpdateListener
.
onUpdateObject
(
currentResult
!=
null
?
realm
.
copyFromRealm
(
currentResult
)
:
null
);
...
...
@@ -70,8 +64,9 @@ public class RealmObjectObserver<T extends RealmObject> extends AbstractRealmRes
};
}
public
void
sub
()
{
previousResult
=
null
;
previousResult
String
=
null
;
super
.
sub
();
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment