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
122db8ba
Commit
122db8ba
authored
Feb 04, 2018
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement CitationSnackbar class
parent
693778eb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
71 additions
and
0 deletions
+71
-0
CitationSnackbar.kt
.../java/chat/rocket/android/chatroom/ui/CitationSnackbar.kt
+71
-0
No files found.
app/src/main/java/chat/rocket/android/chatroom/ui/CitationSnackbar.kt
0 → 100644
View file @
122db8ba
package
chat.rocket.android.chatroom.ui
import
android.graphics.drawable.Drawable
import
android.support.design.widget.BaseTransientBottomBar
import
android.support.v4.view.ViewCompat
import
android.text.Spannable
import
android.text.SpannableString
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
android.widget.ImageView
import
android.widget.TextView
import
chat.rocket.android.R
import
chat.rocket.android.helper.MessageParser
import
chat.rocket.android.util.content
import
ru.noties.markwon.Markwon
class
CitationSnackbar
:
BaseTransientBottomBar
<
CitationSnackbar
>
{
companion
object
{
fun
make
(
parentViewGroup
:
ViewGroup
,
content
:
String
):
CitationSnackbar
{
val
context
=
parentViewGroup
.
context
val
view
=
LayoutInflater
.
from
(
context
).
inflate
(
R
.
layout
.
quote_bar
,
parentViewGroup
,
false
)
val
citationSnackbar
=
CitationSnackbar
(
parentViewGroup
,
view
,
CallbackImpl
(
view
))
citationSnackbar
.
textView
=
view
.
findViewById
(
R
.
id
.
text_view_quote
)
as
TextView
citationSnackbar
.
cancelView
=
view
.
findViewById
(
R
.
id
.
image_view_cancel_quote
)
as
ImageView
citationSnackbar
.
duration
=
BaseTransientBottomBar
.
LENGTH_INDEFINITE
val
spannable
=
SpannableString
(
content
)
citationSnackbar
.
marginDrawable
=
context
.
getDrawable
(
R
.
drawable
.
quote
)
spannable
.
setSpan
(
MessageParser
.
QuoteMarginSpan
(
citationSnackbar
.
marginDrawable
,
10
),
0
,
content
.
length
,
0
)
citationSnackbar
.
textView
.
content
=
spannable
return
citationSnackbar
}
}
lateinit
var
cancelView
:
View
private
lateinit
var
textView
:
TextView
private
lateinit
var
marginDrawable
:
Drawable
var
text
:
String
=
""
set
(
value
)
{
val
spannable
=
Markwon
.
markdown
(
this
.
context
,
value
)
as
Spannable
spannable
.
setSpan
(
MessageParser
.
QuoteMarginSpan
(
marginDrawable
,
10
),
0
,
spannable
.
length
,
0
)
textView
.
content
=
spannable
}
override
fun
dismiss
()
{
super
.
dismiss
()
text
=
""
}
private
constructor
(
parentViewGroup
:
ViewGroup
,
content
:
View
,
contentViewCallback
:
BaseTransientBottomBar
.
ContentViewCallback
)
:
super
(
parentViewGroup
,
content
,
contentViewCallback
)
class
CallbackImpl
(
val
content
:
View
)
:
BaseTransientBottomBar
.
ContentViewCallback
{
override
fun
animateContentOut
(
delay
:
Int
,
duration
:
Int
)
{
ViewCompat
.
setScaleY
(
content
,
1f
)
ViewCompat
.
animate
(
content
)
.
scaleY
(
0f
)
.
setDuration
(
duration
.
toLong
())
.
setStartDelay
(
delay
.
toLong
())
}
override
fun
animateContentIn
(
delay
:
Int
,
duration
:
Int
)
{
ViewCompat
.
setScaleY
(
content
,
0f
)
ViewCompat
.
animate
(
content
)
.
scaleY
(
1f
).
setDuration
(
duration
.
toLong
())
.
setStartDelay
(
delay
.
toLong
())
}
}
}
\ 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