mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-02-11 00:48:43 +01:00
Fix wrong colors in CommentIndentationView.
This commit is contained in:
parent
bc27f077d6
commit
ad78aebf67
@ -1896,11 +1896,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
((CommentViewHolder) holder).downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
((CommentViewHolder) holder).downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
((CommentViewHolder) holder).replyButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
((CommentViewHolder) holder).replyButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
((CommentViewHolder) holder).itemView.setBackgroundColor(mCommentBackgroundColor);
|
((CommentViewHolder) holder).itemView.setBackgroundColor(mCommentBackgroundColor);
|
||||||
((CommentViewHolder) holder).commentIndentationView.setLevelAndColors(0, verticalBlockColors);
|
|
||||||
} else if (holder instanceof CommentFullyCollapsedViewHolder) {
|
} else if (holder instanceof CommentFullyCollapsedViewHolder) {
|
||||||
((CommentFullyCollapsedViewHolder) holder).commentIndentationView.setLevelAndColors(0, verticalBlockColors);
|
|
||||||
} else if (holder instanceof LoadMoreChildCommentsViewHolder) {
|
} else if (holder instanceof LoadMoreChildCommentsViewHolder) {
|
||||||
((LoadMoreChildCommentsViewHolder) holder).commentIndentationView.setLevelAndColors(0, verticalBlockColors);
|
|
||||||
} else if (holder instanceof PostDetailBaseViewHolder) {
|
} else if (holder instanceof PostDetailBaseViewHolder) {
|
||||||
((PostDetailBaseViewHolder) holder).mUpvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
((PostDetailBaseViewHolder) holder).mUpvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
((PostDetailBaseViewHolder) holder).mScoreTextView.setTextColor(mPostIconAndInfoColor);
|
((PostDetailBaseViewHolder) holder).mScoreTextView.setTextColor(mPostIconAndInfoColor);
|
||||||
|
@ -2,9 +2,7 @@ package ml.docilealligator.infinityforreddit.customviews;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.DashPathEffect;
|
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.Path;
|
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
@ -19,7 +17,7 @@ public class CommentIndentationView extends LinearLayout {
|
|||||||
private final Paint paint;
|
private final Paint paint;
|
||||||
private int level;
|
private int level;
|
||||||
private int[] colors;
|
private int[] colors;
|
||||||
private ArrayList<Path> paths;
|
private ArrayList<Integer> startXs;
|
||||||
private final int spacing;
|
private final int spacing;
|
||||||
private final int pathWidth;
|
private final int pathWidth;
|
||||||
|
|
||||||
@ -30,9 +28,8 @@ public class CommentIndentationView extends LinearLayout {
|
|||||||
pathWidth = (int) Utils.convertDpToPixel(2, context);
|
pathWidth = (int) Utils.convertDpToPixel(2, context);
|
||||||
spacing = pathWidth * 6;
|
spacing = pathWidth * 6;
|
||||||
paint.setStrokeWidth(pathWidth);
|
paint.setStrokeWidth(pathWidth);
|
||||||
paint.setStyle(Paint.Style.FILL_AND_STROKE);
|
paint.setStyle(Paint.Style.STROKE);
|
||||||
paint.setPathEffect(new DashPathEffect(new float[] { pathWidth * 2, pathWidth * 2 }, 0));
|
startXs = new ArrayList<>();
|
||||||
paths = new ArrayList<>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -40,11 +37,7 @@ public class CommentIndentationView extends LinearLayout {
|
|||||||
super.onLayout(changed, left, top, right, bottom);
|
super.onLayout(changed, left, top, right, bottom);
|
||||||
|
|
||||||
for (int i = 0; i < level; i++) {
|
for (int i = 0; i < level; i++) {
|
||||||
float startX = spacing * (i + 1) + pathWidth;
|
startXs.add(spacing * (i + 1) + pathWidth);
|
||||||
Path path = new Path();
|
|
||||||
path.moveTo(startX, 0);
|
|
||||||
path.lineTo(startX, getHeight());
|
|
||||||
paths.add(path);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,17 +45,17 @@ public class CommentIndentationView extends LinearLayout {
|
|||||||
protected void onDraw(Canvas canvas) {
|
protected void onDraw(Canvas canvas) {
|
||||||
super.onDraw(canvas);
|
super.onDraw(canvas);
|
||||||
|
|
||||||
for (int i = 0; i < paths.size(); i++) {
|
for (int i = 0; i < startXs.size(); i++) {
|
||||||
paint.setColor(colors[i % 7]);
|
paint.setColor(colors[i % 7]);
|
||||||
canvas.drawPath(paths.get(i), paint);
|
canvas.drawLine(startXs.get(i), 0, startXs.get(i), getHeight(), paint);
|
||||||
}
|
}
|
||||||
|
startXs.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLevelAndColors(int level, int[] colors) {
|
public void setLevelAndColors(int level, int[] colors) {
|
||||||
paths.clear();
|
|
||||||
this.colors = colors;
|
this.colors = colors;
|
||||||
this.level = level;
|
this.level = level;
|
||||||
int indentationSpacing = (int) (level * spacing + pathWidth);
|
int indentationSpacing = (level * spacing + pathWidth);
|
||||||
setPaddingRelative(indentationSpacing, 0, pathWidth, 0);
|
setPaddingRelative(indentationSpacing, 0, pathWidth, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user