Fix spoiler overlap with onClickListener in CommentsListingRecyclerViewAdapter. Fix spoiler text color in comments in CommentAndPostRecyclerViewAdapter.

This commit is contained in:
Alex Ning 2020-08-17 11:27:02 +08:00
parent 400b8b5274
commit 44a4fa16dc
2 changed files with 13 additions and 10 deletions

View File

@ -242,6 +242,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
mRedditDataRoomDatabase = redditDataRoomDatabase;
mGlide = glide;
mSecondaryTextColor = customThemeWrapper.getSecondaryTextColor();
mCommentTextColor = customThemeWrapper.getCommentColor();
int markdownColor = customThemeWrapper.getPostContentColor();
int linkColor = customThemeWrapper.getLinkColor();
mPostDetailMarkwon = Markwon.builder(mActivity)
@ -372,10 +373,10 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
public void updateDrawState(@NonNull TextPaint ds) {
if (isShowing) {
super.updateDrawState(ds);
ds.setColor(markdownColor);
ds.setColor(mCommentTextColor);
} else {
ds.bgColor = Color.BLACK;
ds.setColor(markdownColor);
ds.setColor(mCommentTextColor);
}
ds.setUnderlineText(false);
}
@ -480,7 +481,6 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
mCardViewColor = customThemeWrapper.getCardViewBackgroundColor();
mPostTitleColor = customThemeWrapper.getPostTitleColor();
mPrimaryTextColor = customThemeWrapper.getPrimaryTextColor();
mCommentTextColor = customThemeWrapper.getCommentColor();
mDividerColor = customThemeWrapper.getDividerColor();
mCommentBackgroundColor = customThemeWrapper.getCommentBackgroundColor();
mPostTypeBackgroundColor = customThemeWrapper.getPostTypeBackgroundColor();

View File

@ -10,9 +10,9 @@ import android.os.Bundle;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.TextPaint;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.text.style.SuperscriptSpan;
import android.text.style.URLSpan;
import android.text.util.Linkify;
import android.view.LayoutInflater;
import android.view.View;
@ -155,10 +155,8 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
@Override
public void onClick(@NonNull View view) {
if (!(isShowing && markdownStringBuilder.getSpans(matcherStart, matcherEnd - 4, URLSpan.class).length > 0)) {
isShowing = !isShowing;
view.invalidate();
}
isShowing = !isShowing;
view.invalidate();
}
};
markdownStringBuilder.setSpan(clickableSpan, matcherStart, matcherEnd - 4, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
@ -315,8 +313,11 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
((CommentViewHolder) holder).verticalBlock.setVisibility(View.GONE);
((CommentViewHolder) holder).commentMarkdownView.setOnClickListener(view ->
((CommentViewHolder) holder).linearLayout.callOnClick());
((CommentViewHolder) holder).commentMarkdownView.setOnClickListener(view -> {
if (((CommentViewHolder) holder).commentMarkdownView.getSelectionStart() == -1 && ((CommentViewHolder) holder).commentMarkdownView.getSelectionEnd() == -1) {
((CommentViewHolder) holder).linearLayout.callOnClick();
}
});
((CommentViewHolder) holder).upvoteButton.setOnClickListener(view -> {
if (mAccessToken == null) {
@ -607,6 +608,8 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
saveButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
replyButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
commentDivider.setBackgroundColor(mDividerColor);
commentMarkdownView.setMovementMethod(LinkMovementMethod.getInstance());
}
}