aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2020-08-14 03:50:36 +0000
committerAlex Ning <chineseperson5@gmail.com>2020-08-14 03:50:36 +0000
commit362932460f787ef9af958e764fcf5bde12449b07 (patch)
tree5711453498685cb22a7c5c2a67c1d64c50c8365a
parent04d1079ad717914c2cfae78f5a6a1d51f692f8f9 (diff)
downloadinfinity-for-reddit-362932460f787ef9af958e764fcf5bde12449b07.tar
infinity-for-reddit-362932460f787ef9af958e764fcf5bde12449b07.tar.gz
infinity-for-reddit-362932460f787ef9af958e764fcf5bde12449b07.tar.bz2
infinity-for-reddit-362932460f787ef9af958e764fcf5bde12449b07.tar.lz
infinity-for-reddit-362932460f787ef9af958e764fcf5bde12449b07.tar.xz
infinity-for-reddit-362932460f787ef9af958e764fcf5bde12449b07.tar.zst
infinity-for-reddit-362932460f787ef9af958e764fcf5bde12449b07.zip
Make spoiler text hide when clicking after unhiding.
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java15
1 files changed, 10 insertions, 5 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
index a530d2b6..defa4363 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
@@ -18,7 +18,6 @@ import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.TextPaint;
import android.text.method.LinkMovementMethod;
-import android.text.style.BackgroundColorSpan;
import android.text.style.ClickableSpan;
import android.text.style.SuperscriptSpan;
import android.text.util.Linkify;
@@ -275,21 +274,27 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
markdownStringBuilder.delete(matcher.start(), matcher.start() + 2);
Spannable spannableCopy = new SpannableString(markdownStringBuilder);
- BackgroundColorSpan backgroundColorSpan = new BackgroundColorSpan(Color.BLACK);
ClickableSpan clickableSpan = new ClickableSpan() {
+ private boolean isShowing = false;
@Override
public void updateDrawState(@NonNull TextPaint ds) {
+ if (isShowing) {
+ super.updateDrawState(ds);
+ ds.setColor(markdownColor);
+ } else {
+ ds.bgColor = Color.BLACK;
+ ds.setColor(markdownColor);
+ }
ds.setUnderlineText(false);
}
@Override
public void onClick(@NonNull View view) {
- spannableCopy.removeSpan(backgroundColorSpan);
- spannableCopy.removeSpan(this);
+ isShowing = !isShowing;
+ view.invalidate();
}
};
spannableCopy.setSpan(clickableSpan, matcher.start(), matcher.end() - 4, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
- spannableCopy.setSpan(backgroundColorSpan, matcher.start(), matcher.end() - 4, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
spannable = spannableCopy;
start = matcher.end() - 4;