From 6ccedc781c68299f7f75059e0511d46db7c86303 Mon Sep 17 00:00:00 2001 From: Thodoris1999 Date: Wed, 18 Jul 2018 12:31:39 +0300 Subject: [PATCH] create new PrepareForEdit for each new edit + minor stuff --- .../gr/thmmy/mthmmy/activities/topic/TopicActivity.java | 7 ++++--- .../gr/thmmy/mthmmy/activities/topic/TopicAdapter.java | 9 ++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java index 1cf3939b..284510c7 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java @@ -262,7 +262,7 @@ public class TopicActivity extends BaseActivity { CustomLinearLayoutManager layoutManager = new CustomLinearLayoutManager( getApplicationContext(), loadedPageUrl); recyclerView.setLayoutManager(layoutManager); - topicAdapter = new TopicAdapter(this, postsList, base_url, topicTask, new PrepareForEdit()); + topicAdapter = new TopicAdapter(this, postsList, base_url, topicTask); recyclerView.setAdapter(topicAdapter); replyFAB = findViewById(R.id.topic_fab); @@ -676,6 +676,7 @@ public class TopicActivity extends BaseActivity { postsList.addAll(localPostsList); topicAdapter.notifyItemRangeInserted(0, postsList.size()); topicAdapter.prepareForDelete(new DeleteTask()); + topicAdapter.prepareForPrepareForEdit(new PrepareForEdit()); progressBar.setVisibility(ProgressBar.INVISIBLE); if (replyPageUrl == null) { @@ -1064,7 +1065,7 @@ public class TopicActivity extends BaseActivity { document = Jsoup.parse(response.body().string()); Element message = document.select("textarea").first(); - postText = message.html(); + postText = message.text(); commitEditURL = document.select("form").first().attr("action"); numReplies = replyPageUrl.substring(replyPageUrl.indexOf("num_replies=") + 12); @@ -1153,7 +1154,7 @@ public class TopicActivity extends BaseActivity { bottomNavBar.setVisibility(View.VISIBLE); if (!result) - Toast.makeText(TopicActivity.this, "Post failed!", Toast.LENGTH_SHORT).show(); + Toast.makeText(TopicActivity.this, "Edit failed!", Toast.LENGTH_SHORT).show(); paginationEnabled(true); replyFAB.setEnabled(true); 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 cb93afe5..d1bd96cd 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 @@ -104,7 +104,7 @@ class TopicAdapter extends RecyclerView.Adapter { * @param postsList List of {@link Post} objects to use */ TopicAdapter(Context context, List postsList, String baseUrl, - TopicActivity.TopicTask topicTask, TopicActivity.PrepareForEdit prepareForEditTask) { + TopicActivity.TopicTask topicTask) { this.context = context; this.postsList = postsList; this.baseUrl = baseUrl; @@ -115,7 +115,6 @@ class TopicAdapter extends RecyclerView.Adapter { viewProperties.add(new boolean[3]); } this.topicTask = topicTask; - this.prepareForEditTask = prepareForEditTask; } ArrayList getToQuoteList() { @@ -137,6 +136,10 @@ class TopicAdapter extends RecyclerView.Adapter { this.deleteTask = deleteTask; } + void prepareForPrepareForEdit(TopicActivity.PrepareForEdit prepareForEditTask) { + this.prepareForEditTask = prepareForEditTask; + } + void prepareForEdit(TopicActivity.EditTask editTask, String commitEditURL, String numReplies, String seqnum, String sc, String topic, String postText) { this.commitEditURL = commitEditURL; @@ -587,7 +590,7 @@ class TopicAdapter extends RecyclerView.Adapter { holder.quickReply.getText().toString(), numReplies, seqnum, sc, topic)); holder.quickReplySubject.getText().clear(); - //holder.quickReplySubject.setText("Re: " + topicTitle); + holder.quickReplySubject.setText(postsList.get(position).getSubject()); holder.quickReply.getText().clear(); holder.submitButton.setEnabled(true); }