mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-13 05:52:48 +01:00
Make spoiler text hide when clicking after unhiding.
This commit is contained in:
parent
04d1079ad7
commit
362932460f
@ -18,7 +18,6 @@ import android.text.SpannableStringBuilder;
|
|||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
import android.text.TextPaint;
|
import android.text.TextPaint;
|
||||||
import android.text.method.LinkMovementMethod;
|
import android.text.method.LinkMovementMethod;
|
||||||
import android.text.style.BackgroundColorSpan;
|
|
||||||
import android.text.style.ClickableSpan;
|
import android.text.style.ClickableSpan;
|
||||||
import android.text.style.SuperscriptSpan;
|
import android.text.style.SuperscriptSpan;
|
||||||
import android.text.util.Linkify;
|
import android.text.util.Linkify;
|
||||||
@ -275,21 +274,27 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
markdownStringBuilder.delete(matcher.start(), matcher.start() + 2);
|
markdownStringBuilder.delete(matcher.start(), matcher.start() + 2);
|
||||||
|
|
||||||
Spannable spannableCopy = new SpannableString(markdownStringBuilder);
|
Spannable spannableCopy = new SpannableString(markdownStringBuilder);
|
||||||
BackgroundColorSpan backgroundColorSpan = new BackgroundColorSpan(Color.BLACK);
|
|
||||||
ClickableSpan clickableSpan = new ClickableSpan() {
|
ClickableSpan clickableSpan = new ClickableSpan() {
|
||||||
|
private boolean isShowing = false;
|
||||||
@Override
|
@Override
|
||||||
public void updateDrawState(@NonNull TextPaint ds) {
|
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);
|
ds.setUnderlineText(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(@NonNull View view) {
|
public void onClick(@NonNull View view) {
|
||||||
spannableCopy.removeSpan(backgroundColorSpan);
|
isShowing = !isShowing;
|
||||||
spannableCopy.removeSpan(this);
|
view.invalidate();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
spannableCopy.setSpan(clickableSpan, matcher.start(), matcher.end() - 4, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
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;
|
spannable = spannableCopy;
|
||||||
start = matcher.end() - 4;
|
start = matcher.end() - 4;
|
||||||
|
Loading…
Reference in New Issue
Block a user