remove view check as listener attached only to that view

This commit is contained in:
Ammar Githam 2020-08-16 06:06:14 +09:00
parent 1a57969abe
commit 2a068c4feb
1 changed files with 15 additions and 17 deletions

View File

@ -86,25 +86,23 @@ public final class DirectMessageThread extends BaseLanguageActivity {
} }
}; };
private final View.OnClickListener newCommentListener = v -> { private final View.OnClickListener newCommentListener = v -> {
if (v == dmsBinding.commentSend) { if (Utils.isEmpty(dmsBinding.commentText.getText().toString())) {
if (Utils.isEmpty(dmsBinding.commentText.getText().toString())) { Toast.makeText(getApplicationContext(), R.string.comment_send_empty_comment, Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(), R.string.comment_send_empty_comment, Toast.LENGTH_SHORT).show(); return;
}
final CommentAction action = new CommentAction(dmsBinding.commentText.getText().toString(), threadid);
action.setOnTaskCompleteListener(result -> {
if (!result) {
Toast.makeText(getApplicationContext(), R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
return; return;
} }
final CommentAction action = new CommentAction(dmsBinding.commentText.getText().toString(), threadid); dmsBinding.commentText.setText("");
action.setOnTaskCompleteListener(result -> { dmsBinding.commentText.clearFocus();
if (!result) { directItemModels.clear();
Toast.makeText(getApplicationContext(), R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show(); messageItemsAdapter.notifyDataSetChanged();
return; new UserInboxFetcher(threadid, UserInboxDirection.OLDER, null, fetchListener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} });
dmsBinding.commentText.setText(""); action.execute();
dmsBinding.commentText.clearFocus();
directItemModels.clear();
messageItemsAdapter.notifyDataSetChanged();
new UserInboxFetcher(threadid, UserInboxDirection.OLDER, null, fetchListener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
});
action.execute();
}
}; };
@Override @Override