From d0a0e763fad1deca255ee13568da6651bb0b17ce Mon Sep 17 00:00:00 2001 From: Apostolof Date: Mon, 17 Jun 2019 09:49:05 +0300 Subject: [PATCH] Fix post icons getting messed up --- .../create_content/NewTopicTask.java | 1 + .../activities/topic/tasks/EditTask.java | 1 + .../topic/tasks/PrepareForEditResult.java | 9 ++++++-- .../topic/tasks/PrepareForEditTask.java | 22 +++++++++++-------- .../activities/topic/tasks/ReplyTask.java | 1 + .../mthmmy/viewmodel/TopicViewModel.java | 2 +- 6 files changed, 24 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/create_content/NewTopicTask.java b/app/src/main/java/gr/thmmy/mthmmy/activities/create_content/NewTopicTask.java index 985e0930..0749d367 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/create_content/NewTopicTask.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/create_content/NewTopicTask.java @@ -61,6 +61,7 @@ public class NewTopicTask extends AsyncTask { .addFormDataPart("sc", sc) .addFormDataPart("subject", strings[1]) .addFormDataPart("topic", topic) + .addFormDataPart("icon", "xx") .build(); Request post = new Request.Builder() diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/EditTask.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/EditTask.java index 3b5b46f0..c54d661c 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/EditTask.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/EditTask.java @@ -38,6 +38,7 @@ public class EditTask extends AsyncTask { .addFormDataPart("sc", strings[4]) .addFormDataPart("subject", strings[5]) .addFormDataPart("topic", strings[6]) + .addFormDataPart("icon", strings[7]) .build(); Request post = new Request.Builder() .url(strings[0]) diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/PrepareForEditResult.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/PrepareForEditResult.java index a8176072..1a74caa3 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/PrepareForEditResult.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/PrepareForEditResult.java @@ -1,18 +1,19 @@ package gr.thmmy.mthmmy.activities.topic.tasks; public class PrepareForEditResult { - private final String postText, commitEditUrl, numReplies, seqnum, sc, topic; + private final String postText, commitEditUrl, numReplies, seqnum, sc, topic, icon; private int position; private boolean successful; public PrepareForEditResult(String postText, String commitEditUrl, String numReplies, String seqnum, - String sc, String topic, int position, boolean successful) { + String sc, String topic, String icon, int position, boolean successful) { this.postText = postText; this.commitEditUrl = commitEditUrl; this.numReplies = numReplies; this.seqnum = seqnum; this.sc = sc; this.topic = topic; + this.icon = icon; this.position = position; this.successful = successful; } @@ -41,6 +42,10 @@ public class PrepareForEditResult { return topic; } + public String getIcon() { + return icon; + } + public int getPosition() { return position; } diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/PrepareForEditTask.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/PrepareForEditTask.java index 6efc2c03..09206a1c 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/PrepareForEditTask.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/PrepareForEditTask.java @@ -38,28 +38,32 @@ public class PrepareForEditTask extends AsyncTaskoption[selected]").first().attr("value"); - return new PrepareForEditResult(postText, commitEditURL, numReplies, seqnum, sc, topic, position, true); + return new PrepareForEditResult(postText, commitEditURL, numReplies, seqnum, sc, topic, icon, position, true); } catch (IOException | Selector.SelectorParseException e) { Timber.e(e, "Prepare failed."); - return new PrepareForEditResult(null, null, null, null, null, null, position, false); + return new PrepareForEditResult(null, null, null, null, null, null, null, position, false); } } diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/ReplyTask.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/ReplyTask.java index 13ad66d9..7ae2595c 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/ReplyTask.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/tasks/ReplyTask.java @@ -42,6 +42,7 @@ public class ReplyTask extends AsyncTask { .addFormDataPart("sc", args[4]) .addFormDataPart("subject", args[0]) .addFormDataPart("topic", args[5]) + .addFormDataPart("icon", "xx") .build(); Request post = new Request.Builder() .url("https://www.thmmy.gr/smf/index.php?action=post2") 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 a7e72883..c15e46db 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/viewmodel/TopicViewModel.java +++ b/app/src/main/java/gr/thmmy/mthmmy/viewmodel/TopicViewModel.java @@ -219,7 +219,7 @@ public class TopicViewModel extends BaseViewModel implements TopicTask.OnTopicTa PrepareForEditResult editResult = prepareForEditResult.getValue(); Timber.i("Editing post"); new EditTask(editTaskCallbacks, position).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, editResult.getCommitEditUrl(), message, - editResult.getNumReplies(), editResult.getSeqnum(), editResult.getSc(), subject, editResult.getTopic()); + editResult.getNumReplies(), editResult.getSeqnum(), editResult.getSc(), subject, editResult.getTopic(), editResult.getIcon()); } /**