Browse Source

serially execute topic's UI changing tasks

pull/61/merge
oogee 6 years ago
parent
commit
627f5210b2
  1. 2
      app/src/main/java/gr/thmmy/mthmmy/activities/shoutbox/ShoutboxFragment.java
  2. 8
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java
  3. 2
      app/src/main/java/gr/thmmy/mthmmy/viewmodel/ShoutboxViewModel.java
  4. 6
      app/src/main/java/gr/thmmy/mthmmy/viewmodel/TopicViewModel.java

2
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"); Timber.i("Shout was sent successfully");
editorView.getEditText().getText().clear(); editorView.getEditText().getText().clear();
shoutboxTask = new ShoutboxTask(ShoutboxFragment.this::onShoutboxTaskSarted, ShoutboxFragment.this::onShoutboxTaskFinished); 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) { } else if (resultCode == NetworkResultCodes.NETWORK_ERROR) {
Timber.w("Failed to send shout"); Timber.w("Failed to send shout");
Toast.makeText(getContext(), "NetworkError", Toast.LENGTH_SHORT).show(); Toast.makeText(getContext(), "NetworkError", Toast.LENGTH_SHORT).show();

8
app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java

@ -762,12 +762,12 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
@Override @Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
((Post) topicItems.get(holder.getAdapterPosition())).setSubject(charSequence.toString());
} }
@Override @Override
public void afterTextChanged(Editable editable) { public void afterTextChanged(Editable editable) {
((Post) topicItems.get(holder.getAdapterPosition())).setSubject(editable.toString());
} }
}); });
holder.editEditor.getEditText().addTextChangedListener(new TextWatcher() { holder.editEditor.getEditText().addTextChangedListener(new TextWatcher() {
@ -778,12 +778,12 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
@Override @Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
((Post) topicItems.get(holder.getAdapterPosition())).setBbContent(charSequence.toString());
} }
@Override @Override
public void afterTextChanged(Editable editable) { public void afterTextChanged(Editable editable) {
((Post) topicItems.get(holder.getAdapterPosition())).setBbContent(editable.toString());
} }
}); });
if (backPressHidden) { if (backPressHidden) {

2
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) if (shoutboxTask != null && shoutboxTask.getStatus() == AsyncTask.Status.RUNNING)
shoutboxTask.cancel(true); shoutboxTask.cancel(true);
shoutboxTask = new ShoutboxTask(onShoutboxTaskStarted, onShoutboxTaskFinished); shoutboxTask = new ShoutboxTask(onShoutboxTaskStarted, onShoutboxTaskFinished);
shoutboxTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, SessionManager.shoutboxUrl.toString()); shoutboxTask.execute(SessionManager.shoutboxUrl.toString());
} }
public void sendShout(String shout) { public void sendShout(String shout) {

6
app/src/main/java/gr/thmmy/mthmmy/viewmodel/TopicViewModel.java

@ -95,7 +95,7 @@ public class TopicViewModel extends BaseViewModel implements TopicTask.OnTopicTa
stopLoading(); stopLoading();
topicUrl = pageUrl; topicUrl = pageUrl;
currentTopicTask = new TopicTask(topicTaskObserver, this); currentTopicTask = new TopicTask(topicTaskObserver, this);
currentTopicTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, pageUrl); currentTopicTask.execute(pageUrl);
} }
public void reloadPage() { public void reloadPage() {
@ -122,7 +122,7 @@ public class TopicViewModel extends BaseViewModel implements TopicTask.OnTopicTa
TopicViewModel.this.onTopicTaskCompleted(result); TopicViewModel.this.onTopicTaskCompleted(result);
runnable.run(); 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() { public void loadPageIndicated() {
@ -210,7 +210,7 @@ public class TopicViewModel extends BaseViewModel implements TopicTask.OnTopicTa
Timber.i("Preparing for edit"); Timber.i("Preparing for edit");
currentPrepareForEditTask = new PrepareForEditTask(prepareForEditCallbacks, this, position, currentPrepareForEditTask = new PrepareForEditTask(prepareForEditCallbacks, this, position,
replyPageUrl.getValue()); replyPageUrl.getValue());
currentPrepareForEditTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, postEditURL); currentPrepareForEditTask.execute(postEditURL);
} }
public void editPost(int position, String subject, String message) { public void editPost(int position, String subject, String message) {

Loading…
Cancel
Save