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
9a224440
Commit
9a224440
authored
Nov 23, 2016
by
Tiago Cunha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Stops the same object from been propagated over and over as if updated
parent
2ae619c8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
11 deletions
+13
-11
RealmObjectObserver.java
...chat/rocket/android/realm_helper/RealmObjectObserver.java
+13
-11
No files found.
realm-helpers/src/main/java/chat/rocket/android/realm_helper/RealmObjectObserver.java
View file @
9a224440
...
@@ -22,7 +22,7 @@ public class RealmObjectObserver<T extends RealmObject> extends AbstractRealmRes
...
@@ -22,7 +22,7 @@ public class RealmObjectObserver<T extends RealmObject> extends AbstractRealmRes
}
}
protected
boolean
isSame
(
T
element1
,
T
element2
)
{
protected
boolean
isSame
(
T
element1
,
T
element2
)
{
return
false
;
return
element1
.
equals
(
element2
)
;
}
}
}
}
...
@@ -47,29 +47,31 @@ public class RealmObjectObserver<T extends RealmObject> extends AbstractRealmRes
...
@@ -47,29 +47,31 @@ public class RealmObjectObserver<T extends RealmObject> extends AbstractRealmRes
private
T
previousResult
;
private
T
previousResult
;
@Override
protected
final
RealmResults
<
T
>
queryItems
(
Realm
realm
)
{
@Override
protected
final
RealmResults
<
T
>
queryItems
(
Realm
realm
)
{
return
query
.
query
(
realm
).
findAll
();
return
query
.
query
(
realm
).
findAll
();
}
}
@Override
protected
final
RealmChangeListener
<
RealmResults
<
T
>>
getListener
()
{
@Override
protected
final
RealmChangeListener
<
RealmResults
<
T
>>
getListener
()
{
return
new
RealmChangeListener
<
RealmResults
<
T
>>()
{
return
new
RealmChangeListener
<
RealmResults
<
T
>>()
{
@Override
public
void
onChange
(
RealmResults
<
T
>
element
)
{
@Override
T
source
=
impl
.
extractObjectFromResults
(
element
);
public
void
onChange
(
RealmResults
<
T
>
element
)
{
T
target
=
source
!=
null
?
realm
.
copyFromRealm
(
source
)
:
null
;
T
currentResult
=
impl
.
extractObjectFromResults
(
element
)
;
if
(
previousResult
!=
null
&&
impl
.
isSame
(
previousResult
,
targe
t
))
{
if
(
previousResult
!=
null
&&
impl
.
isSame
(
previousResult
,
currentResul
t
))
{
return
;
return
;
}
}
previousResult
=
targe
t
;
previousResult
=
currentResul
t
;
if
(
onUpdateListener
!=
null
)
{
if
(
onUpdateListener
!=
null
)
{
onUpdateListener
.
onUpdateObject
(
target
);
onUpdateListener
.
onUpdateObject
(
currentResult
!=
null
?
realm
.
copyFromRealm
(
currentResult
)
:
null
);
}
}
}
}
};
};
}
}
public
void
sub
()
{
public
void
sub
()
{
previousResult
=
null
;
previousResult
=
null
;
super
.
sub
();
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