Skip to content

Commit

Permalink
Prevent multiple enter or send keypresses from sending duplicate mess…
Browse files Browse the repository at this point in the history
…ages
  • Loading branch information
c99koder committed Dec 11, 2013
1 parent 8d04c9a commit 4b979c9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/com/irccloud/android/activity/MessageActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,9 @@ public void onCreate(Bundle savedInstanceState) {
messageTxt.setOnKeyListener(new OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if(event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_ENTER && messageTxt.getText() != null && messageTxt.getText().length() > 0) {
new SendTask().execute((Void)null);
if(sendBtn.isEnabled() && NetworkConnection.getInstance().getState() == NetworkConnection.STATE_CONNECTED && event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_ENTER && messageTxt.getText() != null && messageTxt.getText().length() > 0) {
sendBtn.setEnabled(false);
new SendTask().execute((Void)null);
}
return false;
}
Expand All @@ -175,7 +176,8 @@ public void onClick(View v) {
});
messageTxt.setOnEditorActionListener(new OnEditorActionListener() {
public boolean onEditorAction(TextView view, int actionId, KeyEvent event) {
if(NetworkConnection.getInstance().getState() == NetworkConnection.STATE_CONNECTED && actionId == EditorInfo.IME_ACTION_SEND && messageTxt.getText() != null && messageTxt.getText().length() > 0) {
if(sendBtn.isEnabled() && NetworkConnection.getInstance().getState() == NetworkConnection.STATE_CONNECTED && actionId == EditorInfo.IME_ACTION_SEND && messageTxt.getText() != null && messageTxt.getText().length() > 0) {
sendBtn.setEnabled(false);
new SendTask().execute((Void)null);
}
return true;
Expand Down

0 comments on commit 4b979c9

Please sign in to comment.