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
b0e53901
Commit
b0e53901
authored
Feb 23, 2018
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds divider item decorator bounds to dimens.xml (as a value in dp).
parent
45b8b6de
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
6 deletions
+11
-6
ChatRoomsFragment.kt
...ava/chat/rocket/android/chatrooms/ui/ChatRoomsFragment.kt
+3
-1
DividerItemDecoration.kt
.../java/chat/rocket/android/widget/DividerItemDecoration.kt
+5
-5
dimens.xml
app/src/main/res/values/dimens.xml
+3
-0
No files found.
app/src/main/java/chat/rocket/android/chatrooms/ui/ChatRoomsFragment.kt
View file @
b0e53901
...
...
@@ -103,7 +103,9 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
private
fun
setupRecyclerView
()
{
activity
?.
apply
{
recycler_view
.
layoutManager
=
LinearLayoutManager
(
this
,
LinearLayoutManager
.
VERTICAL
,
false
)
recycler_view
.
addItemDecoration
(
DividerItemDecoration
(
this
,
144
,
0
))
recycler_view
.
addItemDecoration
(
DividerItemDecoration
(
this
,
resources
.
getDimensionPixelSize
(
R
.
dimen
.
divider_item_decorator_bound_start
),
resources
.
getDimensionPixelSize
(
R
.
dimen
.
divider_item_decorator_bound_end
)))
recycler_view
.
itemAnimator
=
DefaultItemAnimator
()
recycler_view
.
adapter
=
ChatRoomsAdapter
(
this
)
{
chatRoom
->
presenter
.
loadChatRoom
(
chatRoom
)
...
...
app/src/main/java/chat/rocket/android/widget/DividerItemDecoration.kt
View file @
b0e53901
...
...
@@ -14,7 +14,7 @@ import android.support.v7.widget.RecyclerView
class
DividerItemDecoration
()
:
RecyclerView
.
ItemDecoration
()
{
private
lateinit
var
divider
:
Drawable
private
var
boundStart
=
0
private
var
bound
Right
=
0
private
var
bound
End
=
0
// Default divider will be used.
constructor
(
context
:
Context
)
:
this
()
{
...
...
@@ -24,15 +24,15 @@ class DividerItemDecoration() : RecyclerView.ItemDecoration() {
styledAttributes
.
recycle
()
}
// Default divider with custom boundaries (start and
right
) will be used.
constructor
(
context
:
Context
,
boundStart
:
Int
,
bound
Right
:
Int
)
:
this
()
{
// Default divider with custom boundaries (start and
end
) will be used.
constructor
(
context
:
Context
,
boundStart
:
Int
,
bound
End
:
Int
)
:
this
()
{
val
attrs
=
intArrayOf
(
android
.
R
.
attr
.
listDivider
)
val
styledAttributes
=
context
.
obtainStyledAttributes
(
attrs
)
divider
=
styledAttributes
.
getDrawable
(
0
)
styledAttributes
.
recycle
()
this
.
boundStart
=
boundStart
this
.
bound
Right
=
boundRight
this
.
bound
End
=
boundEnd
}
// Custom divider will be used.
...
...
@@ -45,7 +45,7 @@ class DividerItemDecoration() : RecyclerView.ItemDecoration() {
override
fun
onDraw
(
c
:
Canvas
,
parent
:
RecyclerView
,
state
:
RecyclerView
.
State
)
{
val
left
=
parent
.
paddingLeft
+
boundStart
val
right
=
(
parent
.
width
-
parent
.
paddingRight
)
-
bound
Right
val
right
=
(
parent
.
width
-
parent
.
paddingRight
)
-
bound
End
val
childCount
=
parent
.
childCount
for
(
i
in
0
until
childCount
)
{
...
...
app/src/main/res/values/dimens.xml
View file @
b0e53901
...
...
@@ -9,6 +9,9 @@
<dimen
name=
"fab_elevation"
>
6dp
</dimen>
<dimen
name=
"divider_item_decorator_bound_start"
>
72dp
</dimen>
<dimen
name=
"divider_item_decorator_bound_end"
>
0dp
</dimen>
<dimen
name=
"message_time_text_size"
>
12sp
</dimen>
</resources>
\ 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