Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xabber-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
xabber-android
Commits
fdc5c2da
Commit
fdc5c2da
authored
Feb 19, 2015
by
Grigory Fedorov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ChatMessageAdapter: time and icon moved after text. refactoring.
parent
bca36b8c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
34 deletions
+49
-34
ChatMessageAdapter.java
...ava/com/xabber/android/ui/adapter/ChatMessageAdapter.java
+49
-34
No files found.
app/src/main/java/com/xabber/android/ui/adapter/ChatMessageAdapter.java
View file @
fdc5c2da
...
@@ -165,8 +165,7 @@ public class ChatMessageAdapter extends BaseAdapter implements UpdatableAdapter
...
@@ -165,8 +165,7 @@ public class ChatMessageAdapter extends BaseAdapter implements UpdatableAdapter
final
MessageItem
messageItem
=
(
MessageItem
)
getItem
(
position
);
final
MessageItem
messageItem
=
(
MessageItem
)
getItem
(
position
);
final
boolean
incoming
=
((
MessageItem
)
getItem
(
position
)).
isIncoming
();
final
boolean
incoming
=
((
MessageItem
)
getItem
(
position
)).
isIncoming
();
final
String
account
=
messageItem
.
getChat
().
getAccount
();
final
String
user
=
messageItem
.
getChat
().
getUser
();
final
String
resource
=
messageItem
.
getResource
();
final
String
resource
=
messageItem
.
getResource
();
final
int
layoutId
;
final
int
layoutId
;
...
@@ -177,41 +176,37 @@ public class ChatMessageAdapter extends BaseAdapter implements UpdatableAdapter
...
@@ -177,41 +176,37 @@ public class ChatMessageAdapter extends BaseAdapter implements UpdatableAdapter
}
}
View
view
=
activity
.
getLayoutInflater
().
inflate
(
layoutId
,
parent
,
false
);
View
view
=
activity
.
getLayoutInflater
().
inflate
(
layoutId
,
parent
,
false
);
TextView
textView
=
(
TextView
)
view
.
findViewById
(
R
.
id
.
text
);
((
TextView
)
view
.
findViewById
(
R
.
id
.
text
))
.
setTextAppearance
(
activity
,
appearanceStyle
);
textView
.
setTextAppearance
(
activity
,
appearanceStyle
);
if
(
incoming
)
{
if
(
incoming
)
{
view
.
findViewById
(
R
.
id
.
text
)
.
setBackgroundResource
(
R
.
drawable
.
chat_bg
);
textView
.
setBackgroundResource
(
R
.
drawable
.
chat_bg
);
view
.
findViewById
(
R
.
id
.
text
)
.
getBackground
().
setLevel
(
AccountManager
.
getInstance
().
getColorLevel
(
account
));
textView
.
getBackground
().
setLevel
(
AccountManager
.
getInstance
().
getColorLevel
(
account
));
}
}
Spannable
text
=
messageItem
.
getSpannable
();
Spannable
text
=
messageItem
.
getSpannable
();
TextView
textView
=
(
TextView
)
view
.
findViewById
(
R
.
id
.
text
);
ImageView
avatarView
=
(
ImageView
)
view
.
findViewById
(
R
.
id
.
avatar
);
ChatAction
action
=
messageItem
.
getAction
();
String
time
=
StringUtils
.
getSmartTimeText
(
messageItem
.
getTimestamp
());
String
time
=
StringUtils
.
getSmartTimeText
(
messageItem
.
getTimestamp
());
ChatAction
action
=
messageItem
.
getAction
();
SpannableStringBuilder
builder
=
new
SpannableStringBuilder
();
SpannableStringBuilder
builder
=
new
SpannableStringBuilder
();
if
(
action
==
null
)
{
if
(
action
==
null
)
{
int
message
Resource
=
R
.
drawable
.
ic_message_delivered
;
int
message
Icon
=
R
.
drawable
.
ic_message_delivered
;
if
(!
incoming
)
{
if
(!
incoming
)
{
if
(
messageItem
.
isError
())
{
if
(
messageItem
.
isError
())
{
message
Resource
=
R
.
drawable
.
ic_message_has_error
;
message
Icon
=
R
.
drawable
.
ic_message_has_error
;
}
else
if
(!
messageItem
.
isSent
())
{
}
else
if
(!
messageItem
.
isSent
())
{
message
Resource
=
R
.
drawable
.
ic_message_not_sent
;
message
Icon
=
R
.
drawable
.
ic_message_not_sent
;
}
else
if
(!
messageItem
.
isDelivered
())
{
}
else
if
(!
messageItem
.
isDelivered
())
{
message
Resource
=
R
.
drawable
.
ic_message_not_delivered
;
message
Icon
=
R
.
drawable
.
ic_message_not_delivered
;
}
}
}
}
append
(
builder
,
" "
,
new
ImageSpan
(
activity
,
messageResource
));
append
(
builder
,
" "
,
new
TextAppearanceSpan
(
activity
,
R
.
style
.
ChatHeader
));
append
(
builder
,
time
,
new
TextAppearanceSpan
(
activity
,
R
.
style
.
ChatHeader_Time
));
append
(
builder
,
" "
,
new
TextAppearanceSpan
(
activity
,
R
.
style
.
ChatHeader
));
if
(
isMUC
)
{
if
(
isMUC
)
{
append
(
builder
,
resource
,
new
TextAppearanceSpan
(
activity
,
R
.
style
.
ChatHeader_Name
));
append
(
builder
,
resource
,
new
TextAppearanceSpan
(
activity
,
R
.
style
.
ChatHeader_Name
));
append
(
builder
,
divider
,
new
TextAppearanceSpan
(
activity
,
R
.
style
.
ChatHeader
));
}
}
append
(
builder
,
divider
,
new
TextAppearanceSpan
(
activity
,
R
.
style
.
ChatHeader
));
Date
timeStamp
=
messageItem
.
getDelayTimestamp
();
Date
timeStamp
=
messageItem
.
getDelayTimestamp
();
...
@@ -221,6 +216,7 @@ public class ChatMessageAdapter extends BaseAdapter implements UpdatableAdapter
...
@@ -221,6 +216,7 @@ public class ChatMessageAdapter extends BaseAdapter implements UpdatableAdapter
append
(
builder
,
delay
,
new
TextAppearanceSpan
(
activity
,
R
.
style
.
ChatHeader_Delay
));
append
(
builder
,
delay
,
new
TextAppearanceSpan
(
activity
,
R
.
style
.
ChatHeader_Delay
));
append
(
builder
,
divider
,
new
TextAppearanceSpan
(
activity
,
R
.
style
.
ChatHeader
));
append
(
builder
,
divider
,
new
TextAppearanceSpan
(
activity
,
R
.
style
.
ChatHeader
));
}
}
if
(
messageItem
.
isUnencypted
())
{
if
(
messageItem
.
isUnencypted
())
{
append
(
builder
,
activity
.
getString
(
R
.
string
.
otr_unencrypted_message
),
append
(
builder
,
activity
.
getString
(
R
.
string
.
otr_unencrypted_message
),
new
TextAppearanceSpan
(
activity
,
R
.
style
.
ChatHeader_Delay
));
new
TextAppearanceSpan
(
activity
,
R
.
style
.
ChatHeader_Delay
));
...
@@ -232,37 +228,56 @@ public class ChatMessageAdapter extends BaseAdapter implements UpdatableAdapter
...
@@ -232,37 +228,56 @@ public class ChatMessageAdapter extends BaseAdapter implements UpdatableAdapter
}
else
{
}
else
{
append
(
builder
,
text
,
new
TextAppearanceSpan
(
activity
,
R
.
style
.
ChatRead
));
append
(
builder
,
text
,
new
TextAppearanceSpan
(
activity
,
R
.
style
.
ChatRead
));
}
}
}
else
{
append
(
builder
,
" "
,
new
TextAppearanceSpan
(
activity
,
R
.
style
.
ChatHeader
));
append
(
builder
,
time
,
new
TextAppearanceSpan
(
activity
,
R
.
style
.
ChatHeader_Time
));
append
(
builder
,
time
,
new
TextAppearanceSpan
(
activity
,
R
.
style
.
ChatHeader_Time
));
append
(
builder
,
" "
,
new
TextAppearanceSpan
(
activity
,
R
.
style
.
ChatHeader
));
append
(
builder
,
" "
,
new
TextAppearanceSpan
(
activity
,
R
.
style
.
ChatHeader
));
if
(!
incoming
)
{
append
(
builder
,
" "
,
new
ImageSpan
(
activity
,
messageIcon
));
}
}
else
{
text
=
Emoticons
.
newSpannable
(
action
.
getText
(
activity
,
resource
,
text
.
toString
()));
text
=
Emoticons
.
newSpannable
(
action
.
getText
(
activity
,
resource
,
text
.
toString
()));
Emoticons
.
getSmiledText
(
activity
.
getApplication
(),
text
);
Emoticons
.
getSmiledText
(
activity
.
getApplication
(),
text
);
append
(
builder
,
text
,
new
TextAppearanceSpan
(
activity
,
R
.
style
.
ChatHeader_Delay
));
append
(
builder
,
text
,
new
TextAppearanceSpan
(
activity
,
R
.
style
.
ChatHeader_Delay
));
append
(
builder
,
" "
,
new
TextAppearanceSpan
(
activity
,
R
.
style
.
ChatHeader
));
append
(
builder
,
time
,
new
TextAppearanceSpan
(
activity
,
R
.
style
.
ChatHeader_Time
));
}
}
textView
.
setText
(
builder
);
textView
.
setText
(
builder
);
textView
.
setMovementMethod
(
LinkMovementMethod
.
getInstance
());
textView
.
setMovementMethod
(
LinkMovementMethod
.
getInstance
());
if
(
incoming
)
{
if
(
incoming
)
{
if
(
SettingsManager
.
chatsShowAvatars
())
{
setUpAvatar
(
messageItem
,
view
);
avatarView
.
setVisibility
(
View
.
VISIBLE
);
}
if
((
isMUC
&&
MUCManager
.
getInstance
().
getNickname
(
account
,
user
).
equalsIgnoreCase
(
resource
)))
{
return
view
;
avatarView
.
setImageDrawable
(
AvatarManager
.
getInstance
().
getAccountAvatar
(
account
));
}
}
else
{
if
(
isMUC
)
{
private
void
setUpAvatar
(
MessageItem
messageItem
,
View
view
)
{
if
(
""
.
equals
(
resource
))
{
ImageView
avatarView
=
(
ImageView
)
view
.
findViewById
(
R
.
id
.
avatar
);
avatarView
.
setImageDrawable
(
AvatarManager
.
getInstance
().
getRoomAvatar
(
user
));
}
else
{
if
(
SettingsManager
.
chatsShowAvatars
())
{
avatarView
.
setImageDrawable
(
AvatarManager
.
getInstance
().
getOccupantAvatar
(
user
+
"/"
+
resource
));
final
String
account
=
messageItem
.
getChat
().
getAccount
();
}
final
String
user
=
messageItem
.
getChat
().
getUser
();
final
String
resource
=
messageItem
.
getResource
();
avatarView
.
setVisibility
(
View
.
VISIBLE
);
if
((
isMUC
&&
MUCManager
.
getInstance
().
getNickname
(
account
,
user
).
equalsIgnoreCase
(
resource
)))
{
avatarView
.
setImageDrawable
(
AvatarManager
.
getInstance
().
getAccountAvatar
(
account
));
}
else
{
if
(
isMUC
)
{
if
(
""
.
equals
(
resource
))
{
avatarView
.
setImageDrawable
(
AvatarManager
.
getInstance
().
getRoomAvatar
(
user
));
}
else
{
}
else
{
avatarView
.
setImageDrawable
(
AvatarManager
.
getInstance
().
get
UserAvatar
(
user
));
avatarView
.
setImageDrawable
(
AvatarManager
.
getInstance
().
get
OccupantAvatar
(
user
+
"/"
+
resource
));
}
}
}
else
{
avatarView
.
setImageDrawable
(
AvatarManager
.
getInstance
().
getUserAvatar
(
user
));
}
}
}
else
{
avatarView
.
setVisibility
(
View
.
GONE
);
}
}
}
else
{
avatarView
.
setVisibility
(
View
.
GONE
);
}
}
return
view
;
}
}
public
String
getAccount
()
{
public
String
getAccount
()
{
...
...
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