Commit 31b29aba authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Adds subscribeTextMessage funtion.

for a better in class modularization.
parent 4a86cd34
...@@ -255,21 +255,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView { ...@@ -255,21 +255,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView {
text_room_is_read_only.setVisible(true) text_room_is_read_only.setVisible(true)
input_container.setVisible(false) input_container.setVisible(false)
} else { } else {
var playAnimation = true subscribeTextMessage()
text_message.asObservable(0)
.subscribe({ t ->
if (t.isNotEmpty() && playAnimation) {
button_show_attachment_options.fadeInOrOut(1F, 0F, 120)
button_send.fadeInOrOut(0F, 1F, 120)
playAnimation = false
}
if (t.isEmpty()) {
button_send.fadeInOrOut(1F, 0F, 120)
button_show_attachment_options.fadeInOrOut(0F, 1F, 120)
playAnimation = true
}
})
button_send.setOnClickListener { button_send.setOnClickListener {
var message = citation ?: "" var message = citation ?: ""
...@@ -277,7 +263,6 @@ class ChatRoomFragment : Fragment(), ChatRoomView { ...@@ -277,7 +263,6 @@ class ChatRoomFragment : Fragment(), ChatRoomView {
sendMessage(message) sendMessage(message)
} }
button_show_attachment_options.setOnClickListener { button_show_attachment_options.setOnClickListener {
if (layout_message_attachment_options.isShown) { if (layout_message_attachment_options.isShown) {
hideAttachmentOptions() hideAttachmentOptions()
...@@ -286,7 +271,9 @@ class ChatRoomFragment : Fragment(), ChatRoomView { ...@@ -286,7 +271,9 @@ class ChatRoomFragment : Fragment(), ChatRoomView {
} }
} }
view_dim.setOnClickListener { hideAttachmentOptions() } view_dim.setOnClickListener {
hideAttachmentOptions()
}
button_files.setOnClickListener { button_files.setOnClickListener {
handler.postDelayed({ handler.postDelayed({
...@@ -307,6 +294,24 @@ class ChatRoomFragment : Fragment(), ChatRoomView { ...@@ -307,6 +294,24 @@ class ChatRoomFragment : Fragment(), ChatRoomView {
}) })
} }
private fun subscribeTextMessage() {
var playAnimation = true
text_message.asObservable(0)
.subscribe({ t ->
if (t.isNotEmpty() && playAnimation) {
button_show_attachment_options.fadeInOrOut(1F, 0F, 120)
button_send.fadeInOrOut(0F, 1F, 120)
playAnimation = false
}
if (t.isEmpty()) {
button_send.fadeInOrOut(1F, 0F, 120)
button_show_attachment_options.fadeInOrOut(0F, 1F, 120)
playAnimation = true
}
})
}
private fun showAttachmentOptions() { private fun showAttachmentOptions() {
view_dim.setVisible(true) view_dim.setVisible(true)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment