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(
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);

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
*/
TopicAdapter(Context context, List<Post> 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<RecyclerView.ViewHolder> {
viewProperties.add(new boolean[3]);
}
this.topicTask = topicTask;
this.prepareForEditTask = prepareForEditTask;
}
ArrayList<Integer> getToQuoteList() {
@ -137,6 +136,10 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
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<RecyclerView.ViewHolder> {
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);
}

Loading…
Cancel
Save