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
da692e15
Commit
da692e15
authored
Oct 06, 2018
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix view less/view more button getting lost
parent
2b9e7144
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
15 deletions
+19
-15
MessageAttachmentViewHolder.kt
...t/android/chatroom/adapter/MessageAttachmentViewHolder.kt
+19
-15
No files found.
app/src/main/java/chat/rocket/android/chatroom/adapter/MessageAttachmentViewHolder.kt
View file @
da692e15
...
...
@@ -3,6 +3,7 @@ package chat.rocket.android.chatroom.adapter
import
android.animation.ValueAnimator
import
android.text.method.LinkMovementMethod
import
android.view.View
import
android.view.ViewGroup
import
android.view.animation.LinearInterpolator
import
androidx.core.view.isVisible
import
chat.rocket.android.R
...
...
@@ -16,8 +17,6 @@ class MessageAttachmentViewHolder(
reactionListener
:
EmojiReactionListener
?
=
null
)
:
BaseViewHolder
<
MessageAttachmentUiModel
>(
itemView
,
listener
,
reactionListener
)
{
private
var
expanded
=
true
init
{
with
(
itemView
)
{
setupActionMenu
(
attachment_container
)
...
...
@@ -33,7 +32,11 @@ class MessageAttachmentViewHolder(
text_message_time
.
text
=
data
.
time
text_sender
.
text
=
data
.
senderName
text_content
.
text
=
data
.
content
text_view_more
.
text
=
viewLess
text_view_more
.
isVisible
=
true
text_view_more
.
text
=
if
(
isExpanded
())
viewLess
else
viewMore
val
lp
=
text_content
.
layoutParams
lp
.
height
=
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
text_content
.
layoutParams
=
lp
text_content
.
addOnLayoutChangeListener
(
object
:
View
.
OnLayoutChangeListener
{
override
fun
onLayoutChange
(
v
:
View
,
left
:
Int
,
top
:
Int
,
right
:
Int
,
bottom
:
Int
,
...
...
@@ -45,8 +48,6 @@ class MessageAttachmentViewHolder(
return
}
text_view_more
.
isVisible
=
true
val
expandAnimation
=
ValueAnimator
.
ofInt
(
collapsedHeight
,
textMeasuredHeight
)
.
setDuration
(
300
)
...
...
@@ -57,18 +58,15 @@ class MessageAttachmentViewHolder(
.
setDuration
(
300
)
collapseAnimation
.
interpolator
=
LinearInterpolator
()
val
lp
=
text_content
.
layoutParams
expandAnimation
.
addUpdateListener
{
val
value
=
it
.
animatedValue
as
Int
lp
.
height
=
value
text_content
.
layoutParams
=
lp
expanded
=
if
(
value
==
textMeasuredHeight
)
{
if
(
value
==
textMeasuredHeight
)
{
text_view_more
.
text
=
viewLess
true
lp
.
height
=
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
}
else
{
text_view_more
.
text
=
viewMore
false
}
}
...
...
@@ -76,19 +74,18 @@ class MessageAttachmentViewHolder(
val
value
=
it
.
animatedValue
as
Int
lp
.
height
=
value
text_content
.
layoutParams
=
lp
expanded
=
if
(
value
==
textMeasuredHeight
)
{
if
(
value
==
textMeasuredHeight
)
{
text_view_more
.
text
=
viewLess
true
lp
.
height
=
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
}
else
{
text_view_more
.
text
=
viewMore
false
}
}
text_view_more
.
setOnClickListener
{
if
(
expandAnimation
.
isRunning
)
return
@setOnClickListener
if
(
expanded
)
{
if
(
isExpanded
()
)
{
collapseAnimation
.
start
()
}
else
{
expandAnimation
.
start
()
...
...
@@ -100,4 +97,11 @@ class MessageAttachmentViewHolder(
})
}
}
}
\ No newline at end of file
private
fun
isExpanded
():
Boolean
{
with
(
itemView
)
{
val
lp
=
text_content
.
layoutParams
return
lp
.
height
==
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
}
}
}
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