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
9b9fd45a
Commit
9b9fd45a
authored
Sep 28, 2017
by
Lucio Maciel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disable message input while saving the message...
Also debounce clicks on MessageFormLayout
parent
9d8197a7
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
61 additions
and
6 deletions
+61
-6
RoomContract.java
...a/chat/rocket/android/fragment/chatroom/RoomContract.java
+4
-0
RoomFragment.java
...a/chat/rocket/android/fragment/chatroom/RoomFragment.java
+10
-0
RoomPresenter.java
.../chat/rocket/android/fragment/chatroom/RoomPresenter.java
+12
-2
DebouncingOnClickListener.java
...cket/android/widget/helper/DebouncingOnClickListener.java
+30
-0
MessageFormLayout.java
...chat/rocket/android/widget/message/MessageFormLayout.java
+5
-4
No files found.
app/src/main/java/chat/rocket/android/fragment/chatroom/RoomContract.java
View file @
9b9fd45a
...
...
@@ -22,6 +22,10 @@ public interface RoomContract {
void
onMessageSendSuccessfully
();
void
disableMessageInput
();
void
enableMessageInput
();
void
showUnreadCount
(
int
count
);
void
showMessages
(
List
<
Message
>
messages
);
...
...
app/src/main/java/chat/rocket/android/fragment/chatroom/RoomFragment.java
View file @
9b9fd45a
...
...
@@ -607,6 +607,16 @@ public class RoomFragment extends AbstractChatRoomFragment implements
edittingMessage
=
null
;
}
@Override
public
void
disableMessageInput
()
{
messageFormManager
.
enableComposingText
(
false
);
}
@Override
public
void
enableMessageInput
()
{
messageFormManager
.
enableComposingText
(
true
);
}
@Override
public
void
showUnreadCount
(
int
count
)
{
newMessageIndicatorManager
.
updateNewMessageCount
(
count
);
...
...
app/src/main/java/chat/rocket/android/fragment/chatroom/RoomPresenter.java
View file @
9b9fd45a
...
...
@@ -119,6 +119,7 @@ public class RoomPresenter extends BasePresenter<RoomContract.View>
@Override
public
void
sendMessage
(
String
messageText
)
{
view
.
disableMessageInput
();
final
Disposable
subscription
=
getRoomUserPair
()
.
flatMap
(
pair
->
messageInteractor
.
send
(
pair
.
first
,
pair
.
second
,
messageText
))
.
subscribeOn
(
AndroidSchedulers
.
from
(
BackgroundLooper
.
get
()))
...
...
@@ -128,8 +129,12 @@ public class RoomPresenter extends BasePresenter<RoomContract.View>
if
(
success
)
{
view
.
onMessageSendSuccessfully
();
}
view
.
enableMessageInput
();
},
Logger:
:
report
throwable
->
{
view
.
enableMessageInput
();
Logger
.
report
(
throwable
);
}
);
addSubscription
(
subscription
);
...
...
@@ -148,6 +153,7 @@ public class RoomPresenter extends BasePresenter<RoomContract.View>
@Override
public
void
updateMessage
(
Message
message
,
String
content
)
{
view
.
disableMessageInput
();
final
Disposable
subscription
=
getCurrentUser
()
.
flatMap
(
user
->
messageInteractor
.
update
(
message
,
user
,
content
))
.
subscribeOn
(
AndroidSchedulers
.
from
(
BackgroundLooper
.
get
()))
...
...
@@ -157,8 +163,12 @@ public class RoomPresenter extends BasePresenter<RoomContract.View>
if
(
success
)
{
view
.
onMessageSendSuccessfully
();
}
view
.
enableMessageInput
();
},
Logger:
:
report
throwable
->
{
view
.
enableMessageInput
();
Logger
.
report
(
throwable
);
}
);
addSubscription
(
subscription
);
...
...
rocket-chat-android-widgets/src/main/java/chat/rocket/android/widget/helper/DebouncingOnClickListener.java
0 → 100644
View file @
9b9fd45a
package
chat
.
rocket
.
android
.
widget
.
helper
;
import
android.view.View
;
/**
* A {@linkplain View.OnClickListener click listener} that debounces multiple clicks posted in the
* same frame. A click on one button disables all buttons for that frame.
*
* Shamelessly copied from butterknife -> https://github.com/JakeWharton/butterknife/blob/master/butterknife/src/main/java/butterknife/internal/DebouncingOnClickListener.java
*/
public
abstract
class
DebouncingOnClickListener
implements
View
.
OnClickListener
{
static
boolean
enabled
=
true
;
private
static
final
Runnable
ENABLE_AGAIN
=
new
Runnable
()
{
@Override
public
void
run
()
{
enabled
=
true
;
}
};
@Override
public
final
void
onClick
(
View
v
)
{
if
(
enabled
)
{
enabled
=
false
;
v
.
post
(
ENABLE_AGAIN
);
doClick
(
v
);
}
}
public
abstract
void
doClick
(
View
v
);
}
rocket-chat-android-widgets/src/main/java/chat/rocket/android/widget/message/MessageFormLayout.java
View file @
9b9fd45a
...
...
@@ -18,6 +18,7 @@ import android.widget.ImageButton;
import
android.widget.LinearLayout
;
import
chat.rocket.android.widget.R
;
import
chat.rocket.android.widget.helper.DebouncingOnClickListener
;
public
class
MessageFormLayout
extends
LinearLayout
{
...
...
@@ -57,18 +58,18 @@ public class MessageFormLayout extends LinearLayout {
attachButton
=
composer
.
findViewById
(
R
.
id
.
button_attach
);
attachButton
.
setOnClickListener
(
new
OnClickListener
()
{
attachButton
.
setOnClickListener
(
new
Debouncing
OnClickListener
()
{
@Override
public
void
on
Click
(
View
view
)
{
public
void
do
Click
(
View
view
)
{
onExtraActionSelectionClick
();
}
});
sendButton
=
composer
.
findViewById
(
R
.
id
.
button_send
);
sendButton
.
setOnClickListener
(
new
OnClickListener
()
{
sendButton
.
setOnClickListener
(
new
Debouncing
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
public
void
doClick
(
View
v
)
{
String
messageText
=
getText
();
if
(
messageText
.
length
()
>
0
&&
submitTextListener
!=
null
)
{
submitTextListener
.
onSubmitText
(
messageText
);
...
...
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