Browse Source

create new PrepareForEdit for each new edit + minor stuff

pull/30/head
Thodoris1999 7 years ago
parent
commit
6ccedc781c
  1. 7
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java
  2. 9
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java

7
app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java

@ -262,7 +262,7 @@ public class TopicActivity extends BaseActivity {
CustomLinearLayoutManager layoutManager = new CustomLinearLayoutManager( CustomLinearLayoutManager layoutManager = new CustomLinearLayoutManager(
getApplicationContext(), loadedPageUrl); getApplicationContext(), loadedPageUrl);
recyclerView.setLayoutManager(layoutManager); recyclerView.setLayoutManager(layoutManager);
topicAdapter = new TopicAdapter(this, postsList, base_url, topicTask, new PrepareForEdit()); topicAdapter = new TopicAdapter(this, postsList, base_url, topicTask);
recyclerView.setAdapter(topicAdapter); recyclerView.setAdapter(topicAdapter);
replyFAB = findViewById(R.id.topic_fab); replyFAB = findViewById(R.id.topic_fab);
@ -676,6 +676,7 @@ public class TopicActivity extends BaseActivity {
postsList.addAll(localPostsList); postsList.addAll(localPostsList);
topicAdapter.notifyItemRangeInserted(0, postsList.size()); topicAdapter.notifyItemRangeInserted(0, postsList.size());
topicAdapter.prepareForDelete(new DeleteTask()); topicAdapter.prepareForDelete(new DeleteTask());
topicAdapter.prepareForPrepareForEdit(new PrepareForEdit());
progressBar.setVisibility(ProgressBar.INVISIBLE); progressBar.setVisibility(ProgressBar.INVISIBLE);
if (replyPageUrl == null) { if (replyPageUrl == null) {
@ -1064,7 +1065,7 @@ public class TopicActivity extends BaseActivity {
document = Jsoup.parse(response.body().string()); document = Jsoup.parse(response.body().string());
Element message = document.select("textarea").first(); Element message = document.select("textarea").first();
postText = message.html(); postText = message.text();
commitEditURL = document.select("form").first().attr("action"); commitEditURL = document.select("form").first().attr("action");
numReplies = replyPageUrl.substring(replyPageUrl.indexOf("num_replies=") + 12); numReplies = replyPageUrl.substring(replyPageUrl.indexOf("num_replies=") + 12);
@ -1153,7 +1154,7 @@ public class TopicActivity extends BaseActivity {
bottomNavBar.setVisibility(View.VISIBLE); bottomNavBar.setVisibility(View.VISIBLE);
if (!result) if (!result)
Toast.makeText(TopicActivity.this, "Post failed!", Toast.LENGTH_SHORT).show(); Toast.makeText(TopicActivity.this, "Edit failed!", Toast.LENGTH_SHORT).show();
paginationEnabled(true); paginationEnabled(true);
replyFAB.setEnabled(true); replyFAB.setEnabled(true);

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

@ -104,7 +104,7 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
* @param postsList List of {@link Post} objects to use * @param postsList List of {@link Post} objects to use
*/ */
TopicAdapter(Context context, List<Post> postsList, String baseUrl, TopicAdapter(Context context, List<Post> postsList, String baseUrl,
TopicActivity.TopicTask topicTask, TopicActivity.PrepareForEdit prepareForEditTask) { TopicActivity.TopicTask topicTask) {
this.context = context; this.context = context;
this.postsList = postsList; this.postsList = postsList;
this.baseUrl = baseUrl; this.baseUrl = baseUrl;
@ -115,7 +115,6 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
viewProperties.add(new boolean[3]); viewProperties.add(new boolean[3]);
} }
this.topicTask = topicTask; this.topicTask = topicTask;
this.prepareForEditTask = prepareForEditTask;
} }
ArrayList<Integer> getToQuoteList() { ArrayList<Integer> getToQuoteList() {
@ -137,6 +136,10 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
this.deleteTask = deleteTask; this.deleteTask = deleteTask;
} }
void prepareForPrepareForEdit(TopicActivity.PrepareForEdit prepareForEditTask) {
this.prepareForEditTask = prepareForEditTask;
}
void prepareForEdit(TopicActivity.EditTask editTask, String commitEditURL, String numReplies, String seqnum, String sc, void prepareForEdit(TopicActivity.EditTask editTask, String commitEditURL, String numReplies, String seqnum, String sc,
String topic, String postText) { String topic, String postText) {
this.commitEditURL = commitEditURL; this.commitEditURL = commitEditURL;
@ -587,7 +590,7 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
holder.quickReply.getText().toString(), numReplies, seqnum, sc, topic)); holder.quickReply.getText().toString(), numReplies, seqnum, sc, topic));
holder.quickReplySubject.getText().clear(); holder.quickReplySubject.getText().clear();
//holder.quickReplySubject.setText("Re: " + topicTitle); holder.quickReplySubject.setText(postsList.get(position).getSubject());
holder.quickReply.getText().clear(); holder.quickReply.getText().clear();
holder.submitButton.setEnabled(true); holder.submitButton.setEnabled(true);
} }

Loading…
Cancel
Save