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
81005547
Commit
81005547
authored
Mar 07, 2018
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set top decorator for suggestions menu
parent
a2ee46cf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
1 deletion
+45
-1
SuggestionsView.kt
...ocket/android/widget/autocompletion/ui/SuggestionsView.kt
+32
-0
suggestions_menu_decorator.xml
app/src/main/res/drawable/suggestions_menu_decorator.xml
+7
-0
suggestion_member_item.xml
app/src/main/res/layout/suggestion_member_item.xml
+6
-1
No files found.
app/src/main/java/chat/rocket/android/widget/autocompletion/ui/SuggestionsView.kt
View file @
81005547
package
chat.rocket.android.widget.autocompletion.ui
package
chat.rocket.android.widget.autocompletion.ui
import
android.content.Context
import
android.content.Context
import
android.graphics.Canvas
import
android.graphics.Rect
import
android.graphics.drawable.Drawable
import
android.support.annotation.DrawableRes
import
android.support.transition.Slide
import
android.support.transition.Slide
import
android.support.transition.TransitionManager
import
android.support.transition.TransitionManager
import
android.support.v4.content.ContextCompat
import
android.support.v7.widget.DefaultItemAnimator
import
android.support.v7.widget.DefaultItemAnimator
import
android.support.v7.widget.LinearLayoutManager
import
android.support.v7.widget.LinearLayoutManager
import
android.support.v7.widget.RecyclerView
import
android.support.v7.widget.RecyclerView
...
@@ -14,6 +19,7 @@ import android.view.Gravity
...
@@ -14,6 +19,7 @@ import android.view.Gravity
import
android.view.View
import
android.view.View
import
android.widget.EditText
import
android.widget.EditText
import
android.widget.FrameLayout
import
android.widget.FrameLayout
import
chat.rocket.android.R
import
chat.rocket.android.widget.autocompletion.model.SuggestionModel
import
chat.rocket.android.widget.autocompletion.model.SuggestionModel
import
java.lang.ref.WeakReference
import
java.lang.ref.WeakReference
import
java.util.concurrent.atomic.AtomicInteger
import
java.util.concurrent.atomic.AtomicInteger
...
@@ -43,6 +49,7 @@ class SuggestionsView : FrameLayout, TextWatcher {
...
@@ -43,6 +49,7 @@ class SuggestionsView : FrameLayout, TextWatcher {
val
layoutManager
=
LinearLayoutManager
(
context
,
LinearLayoutManager
.
VERTICAL
,
val
layoutManager
=
LinearLayoutManager
(
context
,
LinearLayoutManager
.
VERTICAL
,
false
)
false
)
recyclerView
.
itemAnimator
=
DefaultItemAnimator
()
recyclerView
.
itemAnimator
=
DefaultItemAnimator
()
recyclerView
.
addItemDecoration
(
TopItemDecoration
(
context
,
R
.
drawable
.
suggestions_menu_decorator
))
recyclerView
.
layoutManager
=
layoutManager
recyclerView
.
layoutManager
=
layoutManager
recyclerView
.
visibility
=
View
.
GONE
recyclerView
.
visibility
=
View
.
GONE
addView
(
recyclerView
)
addView
(
recyclerView
)
...
@@ -191,4 +198,29 @@ class SuggestionsView : FrameLayout, TextWatcher {
...
@@ -191,4 +198,29 @@ class SuggestionsView : FrameLayout, TextWatcher {
TransitionManager
.
beginDelayedTransition
(
this
,
SLIDE_TRANSITION
)
TransitionManager
.
beginDelayedTransition
(
this
,
SLIDE_TRANSITION
)
recyclerView
.
visibility
=
View
.
VISIBLE
recyclerView
.
visibility
=
View
.
VISIBLE
}
}
private
class
TopItemDecoration
()
:
RecyclerView
.
ItemDecoration
()
{
private
lateinit
var
divider
:
Drawable
private
val
padding
=
Rect
()
// Custom divider will be used.
constructor
(
context
:
Context
,
@DrawableRes
drawableResId
:
Int
)
:
this
()
{
val
customDrawable
=
ContextCompat
.
getDrawable
(
context
,
drawableResId
)
if
(
customDrawable
!=
null
)
{
divider
=
customDrawable
}
}
override
fun
onDrawOver
(
c
:
Canvas
,
parent
:
RecyclerView
,
state
:
RecyclerView
.
State
)
{
val
left
=
parent
.
paddingLeft
val
right
=
(
parent
.
width
-
parent
.
paddingRight
)
val
parentParams
=
parent
.
layoutParams
as
FrameLayout
.
LayoutParams
val
top
=
parent
.
top
-
parentParams
.
topMargin
-
parent
.
paddingTop
val
bottom
=
top
+
divider
.
intrinsicHeight
divider
.
setBounds
(
left
,
top
,
right
,
bottom
)
divider
.
draw
(
c
)
}
}
}
}
\ No newline at end of file
app/src/main/res/drawable/suggestions_menu_decorator.xml
0 → 100644
View file @
81005547
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:shape=
"rectangle"
>
<solid
android:color=
"#10000000"
/>
<corners
android:radius=
"5dp"
/>
<size
android:height=
"2dp"
/>
</shape>
\ No newline at end of file
app/src/main/res/layout/suggestion_member_item.xml
View file @
81005547
...
@@ -4,7 +4,12 @@
...
@@ -4,7 +4,12 @@
xmlns:tools=
"http://schemas.android.com/tools"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_margin=
"2dp"
android:layout_marginBottom=
"2dp"
android:layout_marginEnd=
"2dp"
android:layout_marginLeft=
"4dp"
android:layout_marginRight=
"2dp"
android:layout_marginStart=
"4dp"
android:layout_marginTop=
"2dp"
android:background=
"@color/suggestion_background_color"
>
android:background=
"@color/suggestion_background_color"
>
<FrameLayout
<FrameLayout
...
...
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