Browse Source

maybe fix parallel posting

pull/61/merge
Thodoris1999 6 years ago
parent
commit
be481ed4a0
  1. 6
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java
  2. 12
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java
  3. 5
      app/src/main/java/gr/thmmy/mthmmy/model/Post.java

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

@ -522,15 +522,11 @@ public class TopicActivity extends BaseActivity implements TopicAdapter.OnPostFo
String message = replyHolder.replyEditor.getText().toString();
Runnable addReply = () -> {
viewModel.setWritingReply(true);
topicItems.add(Post.newQuickReply());
topicItems.add(Post.newQuickReply(subject, message));
topicAdapter.notifyItemInserted(topicItems.size());
recyclerView.scrollToPosition(topicItems.size() - 1);
replyFAB.hide();
bottomNavBar.setVisibility(View.GONE);
TopicAdapter.QuickReplyViewHolder newReplyHolder = (TopicAdapter.QuickReplyViewHolder)
recyclerView.findViewHolderForAdapterPosition(topicItems.size() - 1);
newReplyHolder.quickReplySubject.setText(subject);
newReplyHolder.replyEditor.setText(message);
AlertDialog.Builder builder = new AlertDialog.Builder(TopicActivity.this,
R.style.AppCompatAlertDialogStyleAccent);
builder.setMessage("A new reply was posted before you completed your new post." +

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

@ -572,6 +572,7 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
}
} else if (currentHolder instanceof QuickReplyViewHolder) {
final QuickReplyViewHolder holder = (QuickReplyViewHolder) currentHolder;
Post reply = (Post) topicItems.get(position);
//noinspection ConstantConditions
Picasso.with(context)
@ -585,7 +586,11 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
.transform(new CircleTransform())
.into(holder.thumbnail);
holder.username.setText(getSessionManager().getUsername());
if (reply.getSubject() != null) {
holder.quickReplySubject.setText(reply.getSubject());
} else {
holder.quickReplySubject.setText("Re: " + viewModel.getTopicTitle().getValue());
}
holder.quickReplySubject.setRawInputType(InputType.TYPE_CLASS_TEXT);
holder.quickReplySubject.setImeOptions(EditorInfo.IME_ACTION_DONE);
@ -593,7 +598,6 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
holder.replyEditor.requestEditTextFocus();
emojiKeyboard.registerEmojiInputField(holder.replyEditor);
holder.replyEditor.setText(viewModel.getBuildedQuotes());
holder.replyEditor.setOnSubmitListener(view -> {
if (holder.quickReplySubject.getText().toString().isEmpty()) return;
if (holder.replyEditor.getText().toString().isEmpty()) {
@ -611,6 +615,12 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
});
holder.replyEditor.setOnClickListener(view -> holder.replyEditor.setError(null));
if (reply.getContent() != null) {
holder.replyEditor.setText(reply.getContent());
} else {
holder.replyEditor.setText(viewModel.getBuildedQuotes());
}
if (backPressHidden) {
holder.replyEditor.requestFocus();
backPressHidden = false;

5
app/src/main/java/gr/thmmy/mthmmy/model/Post.java

@ -185,6 +185,11 @@ public class Post extends TopicItem {
0, null, null, null, null, null, false, TYPE_QUICK_REPLY);
}
public static Post newQuickReply(String subject, String content) {
return new Post(null, null, subject, content, 0, 0, null,
0, null, null, null, null, null, false, TYPE_QUICK_REPLY);
}
//Getters
/**

Loading…
Cancel
Save