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
Show 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
final
MessageItem
messageItem
=
(
MessageItem
)
getItem
(
position
);
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
int
layoutId
;
...
...
@@ -177,41 +176,37 @@ public class ChatMessageAdapter extends BaseAdapter implements UpdatableAdapter
}
View
view
=
activity
.
getLayoutInflater
().
inflate
(
layoutId
,
parent
,
false
);
((
TextView
)
view
.
findViewById
(
R
.
id
.
text
))
.
setTextAppearance
(
activity
,
appearanceStyle
);
TextView
textView
=
(
TextView
)
view
.
findViewById
(
R
.
id
.
text
);
textView
.
setTextAppearance
(
activity
,
appearanceStyle
);
if
(
incoming
)
{
view
.
findViewById
(
R
.
id
.
text
)
.
setBackgroundResource
(
R
.
drawable
.
chat_bg
);
view
.
findViewById
(
R
.
id
.
text
)
.
getBackground
().
setLevel
(
AccountManager
.
getInstance
().
getColorLevel
(
account
));
textView
.
setBackgroundResource
(
R
.
drawable
.
chat_bg
);
textView
.
getBackground
().
setLevel
(
AccountManager
.
getInstance
().
getColorLevel
(
account
));
}
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
());
ChatAction
action
=
messageItem
.
getAction
();
SpannableStringBuilder
builder
=
new
SpannableStringBuilder
();
if
(
action
==
null
)
{
int
message
Resource
=
R
.
drawable
.
ic_message_delivered
;
int
message
Icon
=
R
.
drawable
.
ic_message_delivered
;
if
(!
incoming
)
{
if
(
messageItem
.
isError
())
{
message
Resource
=
R
.
drawable
.
ic_message_has_error
;
message
Icon
=
R
.
drawable
.
ic_message_has_error
;
}
else
if
(!
messageItem
.
isSent
())
{
message
Resource
=
R
.
drawable
.
ic_message_not_sent
;
message
Icon
=
R
.
drawable
.
ic_message_not_sent
;
}
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
)
{
append
(
builder
,
resource
,
new
TextAppearanceSpan
(
activity
,
R
.
style
.
ChatHeader_Name
));
}
append
(
builder
,
divider
,
new
TextAppearanceSpan
(
activity
,
R
.
style
.
ChatHeader
));
}
Date
timeStamp
=
messageItem
.
getDelayTimestamp
();
...
...
@@ -221,6 +216,7 @@ public class ChatMessageAdapter extends BaseAdapter implements UpdatableAdapter
append
(
builder
,
delay
,
new
TextAppearanceSpan
(
activity
,
R
.
style
.
ChatHeader_Delay
));
append
(
builder
,
divider
,
new
TextAppearanceSpan
(
activity
,
R
.
style
.
ChatHeader
));
}
if
(
messageItem
.
isUnencypted
())
{
append
(
builder
,
activity
.
getString
(
R
.
string
.
otr_unencrypted_message
),
new
TextAppearanceSpan
(
activity
,
R
.
style
.
ChatHeader_Delay
));
...
...
@@ -232,18 +228,39 @@ public class ChatMessageAdapter extends BaseAdapter implements UpdatableAdapter
}
else
{
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
,
" "
,
new
TextAppearanceSpan
(
activity
,
R
.
style
.
ChatHeader
));
if
(!
incoming
)
{
append
(
builder
,
" "
,
new
ImageSpan
(
activity
,
messageIcon
));
}
}
else
{
text
=
Emoticons
.
newSpannable
(
action
.
getText
(
activity
,
resource
,
text
.
toString
()));
Emoticons
.
getSmiledText
(
activity
.
getApplication
(),
text
);
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
.
setMovementMethod
(
LinkMovementMethod
.
getInstance
());
if
(
incoming
)
{
setUpAvatar
(
messageItem
,
view
);
}
return
view
;
}
private
void
setUpAvatar
(
MessageItem
messageItem
,
View
view
)
{
ImageView
avatarView
=
(
ImageView
)
view
.
findViewById
(
R
.
id
.
avatar
);
if
(
SettingsManager
.
chatsShowAvatars
())
{
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
));
...
...
@@ -262,8 +279,6 @@ public class ChatMessageAdapter extends BaseAdapter implements UpdatableAdapter
avatarView
.
setVisibility
(
View
.
GONE
);
}
}
return
view
;
}
public
String
getAccount
()
{
return
account
;
...
...
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