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
b1118d16
Commit
b1118d16
authored
Jan 17, 2017
by
Tiago Cunha
Committed by
GitHub
Jan 17, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #154 from RocketChat/fix/message-diff-computation
Implemented equals and hashCode
parents
7f855b85
4f526046
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
263 additions
and
1 deletion
+263
-1
MessageListAdapter.java
...ket/android/layouthelper/chatroom/MessageListAdapter.java
+1
-1
PairedMessage.java
...t/rocket/android/layouthelper/chatroom/PairedMessage.java
+26
-0
Email.java
app/src/main/java/chat/rocket/android/model/ddp/Email.java
+26
-0
Message.java
app/src/main/java/chat/rocket/android/model/ddp/Message.java
+58
-0
Preferences.java
.../main/java/chat/rocket/android/model/ddp/Preferences.java
+82
-0
Settings.java
...src/main/java/chat/rocket/android/model/ddp/Settings.java
+26
-0
User.java
app/src/main/java/chat/rocket/android/model/ddp/User.java
+44
-0
No files found.
app/src/main/java/chat/rocket/android/layouthelper/chatroom/MessageListAdapter.java
View file @
b1118d16
...
@@ -158,7 +158,7 @@ public class MessageListAdapter
...
@@ -158,7 +158,7 @@ public class MessageListAdapter
PairedMessage
oldMessage
=
oldList
.
get
(
oldItemPosition
);
PairedMessage
oldMessage
=
oldList
.
get
(
oldItemPosition
);
PairedMessage
newMessage
=
newList
.
get
(
newItemPosition
);
PairedMessage
newMessage
=
newList
.
get
(
newItemPosition
);
return
oldMessage
.
toString
().
equals
(
newMessage
.
toString
()
);
return
oldMessage
.
equals
(
newMessage
);
}
}
}
}
}
}
app/src/main/java/chat/rocket/android/layouthelper/chatroom/PairedMessage.java
View file @
b1118d16
...
@@ -44,4 +44,30 @@ public class PairedMessage {
...
@@ -44,4 +44,30 @@ public class PairedMessage {
", nextSibling="
+
nextSibling
+
", nextSibling="
+
nextSibling
+
'}'
;
'}'
;
}
}
@SuppressWarnings
({
"PMD.ShortVariable"
})
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
{
return
true
;
}
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
{
return
false
;
}
PairedMessage
that
=
(
PairedMessage
)
o
;
if
(!
target
.
equals
(
that
.
target
))
{
return
false
;
}
return
nextSibling
!=
null
?
nextSibling
.
equals
(
that
.
nextSibling
)
:
that
.
nextSibling
==
null
;
}
@Override
public
int
hashCode
()
{
int
result
=
target
.
hashCode
();
result
=
31
*
result
+
(
nextSibling
!=
null
?
nextSibling
.
hashCode
()
:
0
);
return
result
;
}
}
}
app/src/main/java/chat/rocket/android/model/ddp/Email.java
View file @
b1118d16
...
@@ -9,4 +9,30 @@ import io.realm.annotations.PrimaryKey;
...
@@ -9,4 +9,30 @@ import io.realm.annotations.PrimaryKey;
public
class
Email
extends
RealmObject
{
public
class
Email
extends
RealmObject
{
@PrimaryKey
private
String
address
;
@PrimaryKey
private
String
address
;
private
boolean
verified
;
private
boolean
verified
;
@SuppressWarnings
({
"PMD.ShortVariable"
})
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
{
return
true
;
}
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
{
return
false
;
}
Email
email
=
(
Email
)
o
;
if
(
verified
!=
email
.
verified
)
{
return
false
;
}
return
address
!=
null
?
address
.
equals
(
email
.
address
)
:
email
.
address
==
null
;
}
@Override
public
int
hashCode
()
{
int
result
=
address
!=
null
?
address
.
hashCode
()
:
0
;
result
=
31
*
result
+
(
verified
?
1
:
0
);
return
result
;
}
}
}
app/src/main/java/chat/rocket/android/model/ddp/Message.java
View file @
b1118d16
...
@@ -148,4 +148,62 @@ public class Message extends RealmObject {
...
@@ -148,4 +148,62 @@ public class Message extends RealmObject {
", urls='"
+
urls
+
'\''
+
", urls='"
+
urls
+
'\''
+
'}'
;
'}'
;
}
}
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
{
return
true
;
}
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
{
return
false
;
}
Message
message
=
(
Message
)
o
;
if
(
syncstate
!=
message
.
syncstate
)
{
return
false
;
}
if
(
ts
!=
message
.
ts
)
{
return
false
;
}
if
(
groupable
!=
message
.
groupable
)
{
return
false
;
}
if
(
_id
!=
null
?
!
_id
.
equals
(
message
.
_id
)
:
message
.
_id
!=
null
)
{
return
false
;
}
if
(
t
!=
null
?
!
t
.
equals
(
message
.
t
)
:
message
.
t
!=
null
)
{
return
false
;
}
if
(
rid
!=
null
?
!
rid
.
equals
(
message
.
rid
)
:
message
.
rid
!=
null
)
{
return
false
;
}
if
(
msg
!=
null
?
!
msg
.
equals
(
message
.
msg
)
:
message
.
msg
!=
null
)
{
return
false
;
}
if
(
u
!=
null
?
!
u
.
equals
(
message
.
u
)
:
message
.
u
!=
null
)
{
return
false
;
}
if
(
attachments
!=
null
?
!
attachments
.
equals
(
message
.
attachments
)
:
message
.
attachments
!=
null
)
{
return
false
;
}
return
urls
!=
null
?
urls
.
equals
(
message
.
urls
)
:
message
.
urls
==
null
;
}
@Override
public
int
hashCode
()
{
int
result
=
_id
!=
null
?
_id
.
hashCode
()
:
0
;
result
=
31
*
result
+
(
t
!=
null
?
t
.
hashCode
()
:
0
);
result
=
31
*
result
+
(
rid
!=
null
?
rid
.
hashCode
()
:
0
);
result
=
31
*
result
+
syncstate
;
result
=
31
*
result
+
(
int
)
(
ts
^
(
ts
>>>
32
));
result
=
31
*
result
+
(
msg
!=
null
?
msg
.
hashCode
()
:
0
);
result
=
31
*
result
+
(
u
!=
null
?
u
.
hashCode
()
:
0
);
result
=
31
*
result
+
(
groupable
?
1
:
0
);
result
=
31
*
result
+
(
attachments
!=
null
?
attachments
.
hashCode
()
:
0
);
result
=
31
*
result
+
(
urls
!=
null
?
urls
.
hashCode
()
:
0
);
return
result
;
}
}
}
app/src/main/java/chat/rocket/android/model/ddp/Preferences.java
View file @
b1118d16
...
@@ -84,4 +84,86 @@ public class Preferences extends RealmObject {
...
@@ -84,4 +84,86 @@ public class Preferences extends RealmObject {
public
boolean
isHideFlexTab
()
{
public
boolean
isHideFlexTab
()
{
return
hideFlexTab
;
return
hideFlexTab
;
}
}
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
{
return
true
;
}
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
{
return
false
;
}
Preferences
that
=
(
Preferences
)
o
;
if
(
newRoomNotification
!=
that
.
newRoomNotification
)
{
return
false
;
}
if
(
newMessageNotification
!=
that
.
newMessageNotification
)
{
return
false
;
}
if
(
useEmojis
!=
that
.
useEmojis
)
{
return
false
;
}
if
(
convertAsciiEmoji
!=
that
.
convertAsciiEmoji
)
{
return
false
;
}
if
(
saveMobileBandwidth
!=
that
.
saveMobileBandwidth
)
{
return
false
;
}
if
(
collapseMediaByDefault
!=
that
.
collapseMediaByDefault
)
{
return
false
;
}
if
(
unreadRoomsMode
!=
that
.
unreadRoomsMode
)
{
return
false
;
}
if
(
autoImageLoad
!=
that
.
autoImageLoad
)
{
return
false
;
}
if
(
unreadAlert
!=
that
.
unreadAlert
)
{
return
false
;
}
if
(
desktopNotificationDuration
!=
that
.
desktopNotificationDuration
)
{
return
false
;
}
if
(
viewMode
!=
that
.
viewMode
)
{
return
false
;
}
if
(
hideUsernames
!=
that
.
hideUsernames
)
{
return
false
;
}
if
(
hideAvatars
!=
that
.
hideAvatars
)
{
return
false
;
}
if
(
hideFlexTab
!=
that
.
hideFlexTab
)
{
return
false
;
}
if
(
id
!=
null
?
!
id
.
equals
(
that
.
id
)
:
that
.
id
!=
null
)
{
return
false
;
}
return
emailNotificationMode
!=
null
?
emailNotificationMode
.
equals
(
that
.
emailNotificationMode
)
:
that
.
emailNotificationMode
==
null
;
}
@Override
public
int
hashCode
()
{
int
result
=
id
!=
null
?
id
.
hashCode
()
:
0
;
result
=
31
*
result
+
(
newRoomNotification
?
1
:
0
);
result
=
31
*
result
+
(
newMessageNotification
?
1
:
0
);
result
=
31
*
result
+
(
useEmojis
?
1
:
0
);
result
=
31
*
result
+
(
convertAsciiEmoji
?
1
:
0
);
result
=
31
*
result
+
(
saveMobileBandwidth
?
1
:
0
);
result
=
31
*
result
+
(
collapseMediaByDefault
?
1
:
0
);
result
=
31
*
result
+
(
unreadRoomsMode
?
1
:
0
);
result
=
31
*
result
+
(
autoImageLoad
?
1
:
0
);
result
=
31
*
result
+
(
emailNotificationMode
!=
null
?
emailNotificationMode
.
hashCode
()
:
0
);
result
=
31
*
result
+
(
unreadAlert
?
1
:
0
);
result
=
31
*
result
+
desktopNotificationDuration
;
result
=
31
*
result
+
viewMode
;
result
=
31
*
result
+
(
hideUsernames
?
1
:
0
);
result
=
31
*
result
+
(
hideAvatars
?
1
:
0
);
result
=
31
*
result
+
(
hideFlexTab
?
1
:
0
);
return
result
;
}
}
}
app/src/main/java/chat/rocket/android/model/ddp/Settings.java
View file @
b1118d16
...
@@ -13,4 +13,30 @@ public class Settings extends RealmObject {
...
@@ -13,4 +13,30 @@ public class Settings extends RealmObject {
public
Preferences
getPreferences
()
{
public
Preferences
getPreferences
()
{
return
preferences
;
return
preferences
;
}
}
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
{
return
true
;
}
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
{
return
false
;
}
Settings
settings
=
(
Settings
)
o
;
if
(
id
!=
null
?
!
id
.
equals
(
settings
.
id
)
:
settings
.
id
!=
null
)
{
return
false
;
}
return
preferences
!=
null
?
preferences
.
equals
(
settings
.
preferences
)
:
settings
.
preferences
==
null
;
}
@Override
public
int
hashCode
()
{
int
result
=
id
!=
null
?
id
.
hashCode
()
:
0
;
result
=
31
*
result
+
(
preferences
!=
null
?
preferences
.
hashCode
()
:
0
);
return
result
;
}
}
}
app/src/main/java/chat/rocket/android/model/ddp/User.java
View file @
b1118d16
...
@@ -91,4 +91,48 @@ public class User extends RealmObject {
...
@@ -91,4 +91,48 @@ public class User extends RealmObject {
", settings="
+
settings
+
", settings="
+
settings
+
'}'
;
'}'
;
}
}
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
{
return
true
;
}
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
{
return
false
;
}
User
user
=
(
User
)
o
;
if
(
Double
.
compare
(
user
.
utcOffset
,
utcOffset
)
!=
0
)
{
return
false
;
}
if
(
_id
!=
null
?
!
_id
.
equals
(
user
.
_id
)
:
user
.
_id
!=
null
)
{
return
false
;
}
if
(
username
!=
null
?
!
username
.
equals
(
user
.
username
)
:
user
.
username
!=
null
)
{
return
false
;
}
if
(
status
!=
null
?
!
status
.
equals
(
user
.
status
)
:
user
.
status
!=
null
)
{
return
false
;
}
if
(
emails
!=
null
?
!
emails
.
equals
(
user
.
emails
)
:
user
.
emails
!=
null
)
{
return
false
;
}
return
settings
!=
null
?
settings
.
equals
(
user
.
settings
)
:
user
.
settings
==
null
;
}
@Override
public
int
hashCode
()
{
int
result
;
long
temp
;
result
=
_id
!=
null
?
_id
.
hashCode
()
:
0
;
result
=
31
*
result
+
(
username
!=
null
?
username
.
hashCode
()
:
0
);
result
=
31
*
result
+
(
status
!=
null
?
status
.
hashCode
()
:
0
);
temp
=
Double
.
doubleToLongBits
(
utcOffset
);
result
=
31
*
result
+
(
int
)
(
temp
^
(
temp
>>>
32
));
result
=
31
*
result
+
(
emails
!=
null
?
emails
.
hashCode
()
:
0
);
result
=
31
*
result
+
(
settings
!=
null
?
settings
.
hashCode
()
:
0
);
return
result
;
}
}
}
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