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
1023ed18
Commit
1023ed18
authored
Feb 16, 2018
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add padding to last row items
parent
e9d4c98e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
7 deletions
+18
-7
CategoryPagerAdapter.kt
.../chat/rocket/android/widget/emoji/CategoryPagerAdapter.kt
+15
-7
dimens.xml
app/src/main/res/values/dimens.xml
+3
-0
No files found.
app/src/main/java/chat/rocket/android/widget/emoji/CategoryPagerAdapter.kt
View file @
1023ed18
...
@@ -9,9 +9,10 @@ import android.view.View
...
@@ -9,9 +9,10 @@ import android.view.View
import
android.view.ViewGroup
import
android.view.ViewGroup
import
android.widget.TextView
import
android.widget.TextView
import
chat.rocket.android.R
import
chat.rocket.android.R
import
chat.rocket.android.widget.emoji.EmojiBottomPicker.OnEmojiClickCallback
import
java.util.*
import
java.util.*
class
CategoryPagerAdapter
(
val
callback
:
EmojiBottomPicker
.
OnEmojiClickCallback
)
:
PagerAdapter
()
{
class
CategoryPagerAdapter
(
val
callback
:
OnEmojiClickCallback
)
:
PagerAdapter
()
{
override
fun
isViewFromObject
(
view
:
View
,
obj
:
Any
):
Boolean
{
override
fun
isViewFromObject
(
view
:
View
,
obj
:
Any
):
Boolean
{
return
view
==
obj
return
view
==
obj
}
}
...
@@ -19,9 +20,9 @@ class CategoryPagerAdapter(val callback: EmojiBottomPicker.OnEmojiClickCallback)
...
@@ -19,9 +20,9 @@ class CategoryPagerAdapter(val callback: EmojiBottomPicker.OnEmojiClickCallback)
override
fun
instantiateItem
(
container
:
ViewGroup
,
position
:
Int
):
Any
{
override
fun
instantiateItem
(
container
:
ViewGroup
,
position
:
Int
):
Any
{
val
view
=
LayoutInflater
.
from
(
container
.
context
)
val
view
=
LayoutInflater
.
from
(
container
.
context
)
.
inflate
(
R
.
layout
.
emoji_category_layout
,
container
,
false
)
.
inflate
(
R
.
layout
.
emoji_category_layout
,
container
,
false
)
val
recycler
=
view
.
findViewById
(
R
.
id
.
emojiRecyclerView
)
as
RecyclerView
val
layoutManager
=
GridLayoutManager
(
view
.
context
,
5
)
val
layoutManager
=
GridLayoutManager
(
view
.
context
,
5
)
val
adapter
=
EmojiAdapter
(
callback
)
val
recycler
=
view
.
findViewById
(
R
.
id
.
emojiRecyclerView
)
as
RecyclerView
val
adapter
=
EmojiAdapter
(
layoutManager
.
spanCount
,
callback
)
val
category
=
EmojiCategory
.
values
().
get
(
position
)
val
category
=
EmojiCategory
.
values
().
get
(
position
)
val
emojis
=
if
(
category
!=
EmojiCategory
.
RECENTS
)
val
emojis
=
if
(
category
!=
EmojiCategory
.
RECENTS
)
EmojiLoader
.
getEmojisByCategory
(
category
)
EmojiLoader
.
getEmojisByCategory
(
category
)
...
@@ -45,7 +46,7 @@ class CategoryPagerAdapter(val callback: EmojiBottomPicker.OnEmojiClickCallback)
...
@@ -45,7 +46,7 @@ class CategoryPagerAdapter(val callback: EmojiBottomPicker.OnEmojiClickCallback)
override
fun
getPageTitle
(
position
:
Int
)
=
EmojiCategory
.
values
()[
position
].
icon
()
override
fun
getPageTitle
(
position
:
Int
)
=
EmojiCategory
.
values
()[
position
].
icon
()
class
EmojiAdapter
(
val
callback
:
EmojiBottomPicker
.
OnEmojiClickCallback
)
:
RecyclerView
.
Adapter
<
EmojiRowViewHolder
>()
{
class
EmojiAdapter
(
val
spanCount
:
Int
,
val
callback
:
OnEmojiClickCallback
)
:
RecyclerView
.
Adapter
<
EmojiRowViewHolder
>()
{
private
var
emojis
:
List
<
Emoji
>
=
Collections
.
emptyList
()
private
var
emojis
:
List
<
Emoji
>
=
Collections
.
emptyList
()
fun
addEmojis
(
emojis
:
List
<
Emoji
>)
{
fun
addEmojis
(
emojis
:
List
<
Emoji
>)
{
...
@@ -59,19 +60,26 @@ class CategoryPagerAdapter(val callback: EmojiBottomPicker.OnEmojiClickCallback)
...
@@ -59,19 +60,26 @@ class CategoryPagerAdapter(val callback: EmojiBottomPicker.OnEmojiClickCallback)
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
):
EmojiRowViewHolder
{
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
):
EmojiRowViewHolder
{
val
view
=
LayoutInflater
.
from
(
parent
.
context
).
inflate
(
R
.
layout
.
emoji_row_item
,
parent
,
false
)
val
view
=
LayoutInflater
.
from
(
parent
.
context
).
inflate
(
R
.
layout
.
emoji_row_item
,
parent
,
false
)
return
EmojiRowViewHolder
(
view
,
callback
)
return
EmojiRowViewHolder
(
view
,
itemCount
,
spanCount
,
callback
)
}
}
override
fun
getItemCount
():
Int
=
emojis
.
size
override
fun
getItemCount
():
Int
=
emojis
.
size
}
}
class
EmojiRowViewHolder
(
itemView
:
View
,
val
onEmojiClickCallback
:
EmojiBottomPicker
.
OnEmojiClickCallback
)
:
RecyclerView
.
ViewHolder
(
itemView
)
{
class
EmojiRowViewHolder
(
itemView
:
View
,
val
itemCount
:
Int
,
val
spanCount
:
Int
,
val
callback
:
OnEmojiClickCallback
)
:
RecyclerView
.
ViewHolder
(
itemView
)
{
private
val
emojiView
:
TextView
=
itemView
.
findViewById
(
R
.
id
.
emoji
)
private
val
emojiView
:
TextView
=
itemView
.
findViewById
(
R
.
id
.
emoji
)
fun
bind
(
emoji
:
Emoji
)
{
fun
bind
(
emoji
:
Emoji
)
{
val
context
=
itemView
.
context
emojiView
.
text
=
EmojiParser
.
parse
(
emoji
.
unicode
)
emojiView
.
text
=
EmojiParser
.
parse
(
emoji
.
unicode
)
val
remainder
=
itemCount
%
spanCount
val
lastLineItemCount
=
if
(
remainder
==
0
)
spanCount
else
remainder
val
paddingBottom
=
context
.
resources
.
getDimensionPixelSize
(
R
.
dimen
.
picker_padding_bottom
)
if
(
adapterPosition
>=
itemCount
-
lastLineItemCount
)
{
itemView
.
setPadding
(
0
,
0
,
0
,
paddingBottom
)
}
itemView
.
setOnClickListener
{
itemView
.
setOnClickListener
{
onEmojiClickC
allback
.
onEmojiAdded
(
emoji
)
c
allback
.
onEmojiAdded
(
emoji
)
}
}
}
}
}
}
...
...
app/src/main/res/values/dimens.xml
View file @
1023ed18
...
@@ -11,4 +11,7 @@
...
@@ -11,4 +11,7 @@
<dimen
name=
"message_time_text_size"
>
12sp
</dimen>
<dimen
name=
"message_time_text_size"
>
12sp
</dimen>
<!-- Emoji -->
<dimen
name=
"picker_padding_bottom"
>
16dp
</dimen>
</resources>
</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