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
50fa7847
Commit
50fa7847
authored
Feb 08, 2018
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More refactoring
parent
7cd40441
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
14 deletions
+13
-14
BottomSheetMenu.kt
...rocket/android/chatroom/ui/bottomsheet/BottomSheetMenu.kt
+5
-2
ActionListAdapter.kt
...roid/chatroom/ui/bottomsheet/adapter/ActionListAdapter.kt
+5
-8
ListBottomSheetAdapter.kt
...chatroom/ui/bottomsheet/adapter/ListBottomSheetAdapter.kt
+2
-4
colors.xml
app/src/main/res/values/colors.xml
+1
-0
No files found.
app/src/main/java/chat/rocket/android/chatroom/ui/bottomsheet/BottomSheetMenu.kt
View file @
50fa7847
...
...
@@ -14,8 +14,11 @@ class BottomSheetMenu(adapter: MenuAdapter) : SheetMenu(adapter = adapter) {
layoutManager
=
LinearLayoutManager
(
recycler
.
context
,
LinearLayoutManager
.
VERTICAL
,
false
)
}
val
callback
=
adapter
?.
callback
adapter
?.
callback
=
MenuItem
.
OnMenuItemClickListener
{
// Superclass SheetMenu adapter property is nullable MenuAdapter? but this class enforces
// passing one at the constructor, so we assume it's always non-null.
val
adapter
=
adapter
!!
val
callback
=
adapter
.
callback
adapter
.
callback
=
MenuItem
.
OnMenuItemClickListener
{
callback
?.
onMenuItemClick
(
it
)
dialog
.
cancel
()
true
...
...
app/src/main/java/chat/rocket/android/chatroom/ui/bottomsheet/adapter/ActionListAdapter.kt
View file @
50fa7847
package
chat.rocket.android.chatroom.ui.bottomsheet.adapter
import
android.graphics.Color
import
android.view.MenuItem
import
android.view.View
import
chat.rocket.android.R
import
chat.rocket.android.util.setVisible
/**
* An adapter for bottomsheet menu that lists all the actions that could be taken over a chat message.
...
...
@@ -15,13 +15,9 @@ class ActionListAdapter(menuItems: List<MenuItem> = emptyList(), callback: MenuI
val
item
=
menuItems
[
position
]
if
(
showIcons
)
{
if
(
item
.
icon
==
null
)
{
holder
.
imageIcon
.
visibility
=
View
.
GONE
holder
.
imageIcon
.
setVisible
(
item
.
icon
==
null
)
}
else
{
holder
.
imageIcon
.
visibility
=
View
.
VISIBLE
}
}
else
{
holder
.
imageIcon
.
visibility
=
View
.
GONE
holder
.
imageIcon
.
setVisible
(
false
)
}
holder
.
imageIcon
.
setImageDrawable
(
item
.
icon
)
...
...
@@ -29,7 +25,8 @@ class ActionListAdapter(menuItems: List<MenuItem> = emptyList(), callback: MenuI
holder
.
itemView
.
setOnClickListener
{
callback
?.
onMenuItemClick
(
item
)
}
val
color
=
if
(
item
.
itemId
==
R
.
id
.
action_menu_msg_delete
)
Color
.
RED
else
textColors
.
get
(
item
.
itemId
)
val
deleteTextColor
=
holder
.
itemView
.
context
.
resources
.
getColor
(
R
.
color
.
red
)
val
color
=
if
(
item
.
itemId
==
R
.
id
.
action_menu_msg_delete
)
deleteTextColor
else
textColors
.
get
(
item
.
itemId
)
holder
.
textTitle
.
setTextColor
(
color
)
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatroom/ui/bottomsheet/adapter/ListBottomSheetAdapter.kt
View file @
50fa7847
...
...
@@ -30,8 +30,7 @@ open class ListBottomSheetAdapter(menuItems: List<MenuItem> = emptyList(), callb
* @param itemId The id of the menu item to disable and hide.
*/
fun
hideMenuItem
(
@IdRes
itemId
:
Int
)
{
val
item
=
menuItems
.
firstOrNull
{
it
.
itemId
==
itemId
}
item
?.
apply
{
menuItems
.
firstOrNull
{
it
.
itemId
==
itemId
}
?.
apply
{
setVisible
(
false
)
setEnabled
(
false
)
}
...
...
@@ -43,8 +42,7 @@ open class ListBottomSheetAdapter(menuItems: List<MenuItem> = emptyList(), callb
* @param itemId The id of the menu item to enable and show.
*/
fun
showMenuItem
(
@IdRes
itemId
:
Int
)
{
val
item
=
menuItems
.
firstOrNull
{
it
.
itemId
==
itemId
}
item
?.
apply
{
menuItems
.
firstOrNull
{
it
.
itemId
==
itemId
}
?.
apply
{
setVisible
(
true
)
setEnabled
(
true
)
}
...
...
app/src/main/res/values/colors.xml
View file @
50fa7847
...
...
@@ -17,6 +17,7 @@
<color
name=
"white"
>
#FFFFFFFF
</color>
<color
name=
"black"
>
#FF000000
</color>
<color
name=
"red"
>
#FFFF0000
</color>
<color
name=
"darkGray"
>
#a0a0a0
</color>
<color
name=
"actionMenuColor"
>
#727272
</color>
...
...
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