Fixes a bug where if the send or report buttons are mashed they can send several copies of the same thing.
This commit is contained in:
parent
4fdeba248a
commit
c18186f135
|
@ -101,6 +101,7 @@ public class ComposeActivity extends BaseActivity {
|
|||
private boolean statusMarkSensitive; // to the status being composed.
|
||||
private boolean statusHideText; //
|
||||
private View contentWarningBar;
|
||||
private boolean statusAlreadyInFlight; // to prevent duplicate sends by mashing the send button
|
||||
|
||||
private static class QueuedMedia {
|
||||
enum Type {
|
||||
|
@ -370,12 +371,17 @@ public class ComposeActivity extends BaseActivity {
|
|||
final EditText contentWarningEditor = (EditText) findViewById(R.id.field_content_warning);
|
||||
showContentWarning(false);
|
||||
|
||||
statusAlreadyInFlight = false;
|
||||
final Button sendButton = (Button) findViewById(R.id.button_send);
|
||||
sendButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (statusAlreadyInFlight) {
|
||||
return;
|
||||
}
|
||||
Editable editable = textEditor.getText();
|
||||
if (editable.length() <= STATUS_CHARACTER_LIMIT) {
|
||||
statusAlreadyInFlight = true;
|
||||
String spoilerText = "";
|
||||
if (statusHideText) {
|
||||
spoilerText = contentWarningEditor.getText().toString();
|
||||
|
@ -524,6 +530,7 @@ public class ComposeActivity extends BaseActivity {
|
|||
|
||||
private void onSendFailure() {
|
||||
textEditor.setError(getString(R.string.error_sending_status));
|
||||
statusAlreadyInFlight = false;
|
||||
}
|
||||
|
||||
private void readyStatus(final String content, final String visibility, final boolean sensitive,
|
||||
|
@ -557,6 +564,7 @@ public class ComposeActivity extends BaseActivity {
|
|||
@Override
|
||||
protected void onCancelled() {
|
||||
removeAllMediaFromQueue();
|
||||
statusAlreadyInFlight = false;
|
||||
super.onCancelled();
|
||||
}
|
||||
};
|
||||
|
@ -581,6 +589,7 @@ public class ComposeActivity extends BaseActivity {
|
|||
readyStatus(content, visibility, sensitive, spoilerText);
|
||||
}
|
||||
});
|
||||
statusAlreadyInFlight = false;
|
||||
}
|
||||
|
||||
private void onMediaPick() {
|
||||
|
|
|
@ -55,6 +55,7 @@ public class ReportActivity extends BaseActivity {
|
|||
private String accessToken;
|
||||
private View anyView; // what Snackbar will use to find the root view
|
||||
private ReportAdapter adapter;
|
||||
private boolean reportAlreadyInFlight;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
|
@ -102,11 +103,16 @@ public class ReportActivity extends BaseActivity {
|
|||
|
||||
final EditText comment = (EditText) findViewById(R.id.report_comment);
|
||||
Button send = (Button) findViewById(R.id.report_send);
|
||||
reportAlreadyInFlight = false;
|
||||
send.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (reportAlreadyInFlight) {
|
||||
return;
|
||||
}
|
||||
String[] statusIds = adapter.getCheckedStatusIds();
|
||||
if (statusIds.length > 0) {
|
||||
reportAlreadyInFlight = true;
|
||||
sendReport(accountId, statusIds, comment.getText().toString());
|
||||
} else {
|
||||
comment.setError(getString(R.string.error_report_too_few_statuses));
|
||||
|
@ -187,6 +193,7 @@ public class ReportActivity extends BaseActivity {
|
|||
}
|
||||
})
|
||||
.show();
|
||||
reportAlreadyInFlight = false;
|
||||
}
|
||||
|
||||
private void fetchRecentStatuses(String accountId) {
|
||||
|
|
Loading…
Reference in New Issue