From 86b9feda4a2000f64cb796eff76b330e298bce8b Mon Sep 17 00:00:00 2001 From: Ammar Githam Date: Sun, 16 Aug 2020 06:02:46 +0900 Subject: [PATCH] organize code for readability --- .../activities/DirectMessageThread.java | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/activities/DirectMessageThread.java b/app/src/main/java/awais/instagrabber/activities/DirectMessageThread.java index 030b61e1..9e0c0ff8 100644 --- a/app/src/main/java/awais/instagrabber/activities/DirectMessageThread.java +++ b/app/src/main/java/awais/instagrabber/activities/DirectMessageThread.java @@ -37,10 +37,15 @@ import awais.instagrabber.utils.Utils; public final class DirectMessageThread extends BaseLanguageActivity { private DirectItemModel directItemModel; - private final ProfileModel myProfileHolder = ProfileModel.getDefaultProfileModel(); - private final ArrayList users = new ArrayList<>(), leftusers = new ArrayList<>(); - private final ArrayList directItemModels = new ArrayList<>(); private String threadid; + private String endCursor; + private ActivityDmsBinding dmsBinding; + private MessageItemsAdapter messageItemsAdapter; + + private final ProfileModel myProfileHolder = ProfileModel.getDefaultProfileModel(); + private final ArrayList users = new ArrayList<>(); + private final ArrayList leftusers = new ArrayList<>(); + private final ArrayList directItemModels = new ArrayList<>(); private final FetchListener fetchListener = new FetchListener() { @Override public void doBefore() { @@ -80,9 +85,25 @@ public final class DirectMessageThread extends BaseLanguageActivity { dmsBinding.swipeRefreshLayout.setRefreshing(false); } }; - private String endCursor; - private ActivityDmsBinding dmsBinding; - private MessageItemsAdapter messageItemsAdapter; + private final View.OnClickListener newCommentListener = v -> { + if (Utils.isEmpty(dmsBinding.commentText.getText().toString()) && v == dmsBinding.commentSend) + Toast.makeText(getApplicationContext(), R.string.comment_send_empty_comment, Toast.LENGTH_SHORT).show(); + else if (v == dmsBinding.commentSend) { + 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(); + } + }; @Override protected void onCreate(@Nullable final Bundle savedInstanceState) { @@ -194,25 +215,4 @@ public final class DirectMessageThread extends BaseLanguageActivity { private void searchUsername(final String text) { startActivity(new Intent(getApplicationContext(), ProfileViewer.class).putExtra(Constants.EXTRAS_USERNAME, text)); } - - private final View.OnClickListener newCommentListener = v -> { - if (Utils.isEmpty(dmsBinding.commentText.getText().toString()) && v == dmsBinding.commentSend) - Toast.makeText(getApplicationContext(), R.string.comment_send_empty_comment, Toast.LENGTH_SHORT).show(); - else if (v == dmsBinding.commentSend) { - 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(); - } - }; - } \ No newline at end of file