diff options
Diffstat (limited to 'app/src/main/java/ml')
2 files changed, 8 insertions, 18 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java index 06e0ee52..306b607a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java @@ -1896,11 +1896,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy ((CommentViewHolder) holder).downvoteButton.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).commentIndentationView.setLevelAndColors(0, verticalBlockColors); } else if (holder instanceof CommentFullyCollapsedViewHolder) { - ((CommentFullyCollapsedViewHolder) holder).commentIndentationView.setLevelAndColors(0, verticalBlockColors); } else if (holder instanceof LoadMoreChildCommentsViewHolder) { - ((LoadMoreChildCommentsViewHolder) holder).commentIndentationView.setLevelAndColors(0, verticalBlockColors); } else if (holder instanceof PostDetailBaseViewHolder) { ((PostDetailBaseViewHolder) holder).mUpvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN); ((PostDetailBaseViewHolder) holder).mScoreTextView.setTextColor(mPostIconAndInfoColor); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/CommentIndentationView.java b/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/CommentIndentationView.java index 1887702b..9d504b34 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/CommentIndentationView.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/CommentIndentationView.java @@ -2,9 +2,7 @@ package ml.docilealligator.infinityforreddit.customviews; import android.content.Context; import android.graphics.Canvas; -import android.graphics.DashPathEffect; import android.graphics.Paint; -import android.graphics.Path; import android.util.AttributeSet; import android.widget.LinearLayout; @@ -19,7 +17,7 @@ public class CommentIndentationView extends LinearLayout { private final Paint paint; private int level; private int[] colors; - private ArrayList<Path> paths; + private ArrayList<Integer> startXs; private final int spacing; private final int pathWidth; @@ -30,9 +28,8 @@ public class CommentIndentationView extends LinearLayout { pathWidth = (int) Utils.convertDpToPixel(2, context); spacing = pathWidth * 6; paint.setStrokeWidth(pathWidth); - paint.setStyle(Paint.Style.FILL_AND_STROKE); - paint.setPathEffect(new DashPathEffect(new float[] { pathWidth * 2, pathWidth * 2 }, 0)); - paths = new ArrayList<>(); + paint.setStyle(Paint.Style.STROKE); + startXs = new ArrayList<>(); } @Override @@ -40,11 +37,7 @@ public class CommentIndentationView extends LinearLayout { super.onLayout(changed, left, top, right, bottom); for (int i = 0; i < level; i++) { - float startX = spacing * (i + 1) + pathWidth; - Path path = new Path(); - path.moveTo(startX, 0); - path.lineTo(startX, getHeight()); - paths.add(path); + startXs.add(spacing * (i + 1) + pathWidth); } } @@ -52,17 +45,17 @@ public class CommentIndentationView extends LinearLayout { protected void onDraw(Canvas 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]); - 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) { - paths.clear(); this.colors = colors; this.level = level; - int indentationSpacing = (int) (level * spacing + pathWidth); + int indentationSpacing = (level * spacing + pathWidth); setPaddingRelative(indentationSpacing, 0, pathWidth, 0); } } |