From 627f5210b21e1b0c0fdb303ce5382f8d6cda612c Mon Sep 17 00:00:00 2001 From: oogee Date: Thu, 13 Dec 2018 18:04:03 +0200 Subject: [PATCH] serially execute topic's UI changing tasks --- .../mthmmy/activities/shoutbox/ShoutboxFragment.java | 2 +- .../gr/thmmy/mthmmy/activities/topic/TopicAdapter.java | 8 ++++---- .../java/gr/thmmy/mthmmy/viewmodel/ShoutboxViewModel.java | 2 +- .../java/gr/thmmy/mthmmy/viewmodel/TopicViewModel.java | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/shoutbox/ShoutboxFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/shoutbox/ShoutboxFragment.java index 4c2590b5..0c2d8ae5 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/shoutbox/ShoutboxFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/shoutbox/ShoutboxFragment.java @@ -138,7 +138,7 @@ public class ShoutboxFragment extends Fragment { Timber.i("Shout was sent successfully"); editorView.getEditText().getText().clear(); shoutboxTask = new ShoutboxTask(ShoutboxFragment.this::onShoutboxTaskSarted, ShoutboxFragment.this::onShoutboxTaskFinished); - shoutboxTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, SessionManager.shoutboxUrl.toString()); + shoutboxTask.execute(SessionManager.shoutboxUrl.toString()); } else if (resultCode == NetworkResultCodes.NETWORK_ERROR) { Timber.w("Failed to send shout"); Toast.makeText(getContext(), "NetworkError", Toast.LENGTH_SHORT).show(); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java index c45a7524..f3557d8e 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java @@ -762,12 +762,12 @@ class TopicAdapter extends RecyclerView.Adapter { @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { - + ((Post) topicItems.get(holder.getAdapterPosition())).setSubject(charSequence.toString()); } @Override public void afterTextChanged(Editable editable) { - ((Post) topicItems.get(holder.getAdapterPosition())).setSubject(editable.toString()); + } }); holder.editEditor.getEditText().addTextChangedListener(new TextWatcher() { @@ -778,12 +778,12 @@ class TopicAdapter extends RecyclerView.Adapter { @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { - + ((Post) topicItems.get(holder.getAdapterPosition())).setBbContent(charSequence.toString()); } @Override public void afterTextChanged(Editable editable) { - ((Post) topicItems.get(holder.getAdapterPosition())).setBbContent(editable.toString()); + } }); if (backPressHidden) { diff --git a/app/src/main/java/gr/thmmy/mthmmy/viewmodel/ShoutboxViewModel.java b/app/src/main/java/gr/thmmy/mthmmy/viewmodel/ShoutboxViewModel.java index 88e34386..5aa92f65 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/viewmodel/ShoutboxViewModel.java +++ b/app/src/main/java/gr/thmmy/mthmmy/viewmodel/ShoutboxViewModel.java @@ -21,7 +21,7 @@ public class ShoutboxViewModel extends ViewModel { if (shoutboxTask != null && shoutboxTask.getStatus() == AsyncTask.Status.RUNNING) shoutboxTask.cancel(true); shoutboxTask = new ShoutboxTask(onShoutboxTaskStarted, onShoutboxTaskFinished); - shoutboxTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, SessionManager.shoutboxUrl.toString()); + shoutboxTask.execute(SessionManager.shoutboxUrl.toString()); } public void sendShout(String shout) { diff --git a/app/src/main/java/gr/thmmy/mthmmy/viewmodel/TopicViewModel.java b/app/src/main/java/gr/thmmy/mthmmy/viewmodel/TopicViewModel.java index 4c6310d6..a7e72883 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/viewmodel/TopicViewModel.java +++ b/app/src/main/java/gr/thmmy/mthmmy/viewmodel/TopicViewModel.java @@ -95,7 +95,7 @@ public class TopicViewModel extends BaseViewModel implements TopicTask.OnTopicTa stopLoading(); topicUrl = pageUrl; currentTopicTask = new TopicTask(topicTaskObserver, this); - currentTopicTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, pageUrl); + currentTopicTask.execute(pageUrl); } public void reloadPage() { @@ -122,7 +122,7 @@ public class TopicViewModel extends BaseViewModel implements TopicTask.OnTopicTa TopicViewModel.this.onTopicTaskCompleted(result); runnable.run(); }); - currentTopicTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, ParseHelpers.getBaseURL(topicUrl) + "." + String.valueOf(currentPageIndex * 15)); + currentTopicTask.execute(ParseHelpers.getBaseURL(topicUrl) + "." + String.valueOf(currentPageIndex * 15)); } public void loadPageIndicated() { @@ -210,7 +210,7 @@ public class TopicViewModel extends BaseViewModel implements TopicTask.OnTopicTa Timber.i("Preparing for edit"); currentPrepareForEditTask = new PrepareForEditTask(prepareForEditCallbacks, this, position, replyPageUrl.getValue()); - currentPrepareForEditTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, postEditURL); + currentPrepareForEditTask.execute(postEditURL); } public void editPost(int position, String subject, String message) {