From 2a068c4feb84a37306e6e998d6e5a0ad5471bed4 Mon Sep 17 00:00:00 2001 From: Ammar Githam Date: Sun, 16 Aug 2020 06:06:14 +0900 Subject: [PATCH] remove view check as listener attached only to that view --- .../activities/DirectMessageThread.java | 32 +++++++++---------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/activities/DirectMessageThread.java b/app/src/main/java/awais/instagrabber/activities/DirectMessageThread.java index 50c65708..abe771da 100644 --- a/app/src/main/java/awais/instagrabber/activities/DirectMessageThread.java +++ b/app/src/main/java/awais/instagrabber/activities/DirectMessageThread.java @@ -86,25 +86,23 @@ public final class DirectMessageThread extends BaseLanguageActivity { } }; private final View.OnClickListener newCommentListener = v -> { - if (v == dmsBinding.commentSend) { - if (Utils.isEmpty(dmsBinding.commentText.getText().toString())) { - Toast.makeText(getApplicationContext(), R.string.comment_send_empty_comment, Toast.LENGTH_SHORT).show(); + if (Utils.isEmpty(dmsBinding.commentText.getText().toString())) { + 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; } - 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; - } - dmsBinding.commentText.setText(""); - dmsBinding.commentText.clearFocus(); - directItemModels.clear(); - messageItemsAdapter.notifyDataSetChanged(); - new UserInboxFetcher(threadid, UserInboxDirection.OLDER, null, fetchListener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); - }); - action.execute(); - } + dmsBinding.commentText.setText(""); + dmsBinding.commentText.clearFocus(); + directItemModels.clear(); + messageItemsAdapter.notifyDataSetChanged(); + new UserInboxFetcher(threadid, UserInboxDirection.OLDER, null, fetchListener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + }); + action.execute(); }; @Override