From caf8bb32d4bad0ea4dcad24969d7dc037655edb0 Mon Sep 17 00:00:00 2001 From: Kosh Sergani Date: Tue, 22 Aug 2017 12:00:22 +0200 Subject: [PATCH] displaying reviews comments without replies! --- .../fastaccess/data/dao/CommentRequestModel.java | 4 +--- .../data/dao/timeline/PullRequestReviewModel.java | 2 ++ .../adapter/viewholder/ReviewCommentsViewHolder.kt | 14 ++++++++++---- .../com/fastaccess/ui/widgets/DiffLineSpan.java | 2 +- .../layout/review_timeline_row_item.xml | 5 ++++- 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/fastaccess/data/dao/CommentRequestModel.java b/app/src/main/java/com/fastaccess/data/dao/CommentRequestModel.java index 83f38a57..caf42eed 100644 --- a/app/src/main/java/com/fastaccess/data/dao/CommentRequestModel.java +++ b/app/src/main/java/com/fastaccess/data/dao/CommentRequestModel.java @@ -5,8 +5,6 @@ import android.os.Parcelable; import com.google.gson.annotations.SerializedName; -import java.util.Objects; - import lombok.Getter; import lombok.Setter; @@ -27,7 +25,7 @@ import lombok.Setter; if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; CommentRequestModel that = (CommentRequestModel) o; - return Objects.equals(position, that.position) && (path != null ? path.equals(that.path) : that.path == null); + return position == that.position && (path != null ? path.equals(that.path) : that.path == null); } @Override public int hashCode() { diff --git a/app/src/main/java/com/fastaccess/data/dao/timeline/PullRequestReviewModel.java b/app/src/main/java/com/fastaccess/data/dao/timeline/PullRequestReviewModel.java index 9a6bc029..63889376 100644 --- a/app/src/main/java/com/fastaccess/data/dao/timeline/PullRequestReviewModel.java +++ b/app/src/main/java/com/fastaccess/data/dao/timeline/PullRequestReviewModel.java @@ -4,6 +4,7 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; import com.fastaccess.data.dao.ReactionsModel; +import com.fastaccess.helper.Logger; import com.fastaccess.helper.ParseDateFormat; import java.util.ArrayList; @@ -60,6 +61,7 @@ public class PullRequestReviewModel { comments.add(comment); } } + Logger.e(comments.size()); model.comments = comments; } } else { diff --git a/app/src/main/java/com/fastaccess/ui/adapter/viewholder/ReviewCommentsViewHolder.kt b/app/src/main/java/com/fastaccess/ui/adapter/viewholder/ReviewCommentsViewHolder.kt index 471cd7ce..6438185c 100644 --- a/app/src/main/java/com/fastaccess/ui/adapter/viewholder/ReviewCommentsViewHolder.kt +++ b/app/src/main/java/com/fastaccess/ui/adapter/viewholder/ReviewCommentsViewHolder.kt @@ -13,15 +13,13 @@ import com.fastaccess.data.dao.ReactionsModel import com.fastaccess.data.dao.timeline.PullRequestReviewModel import com.fastaccess.helper.InputHelper import com.fastaccess.helper.ParseDateFormat +import com.fastaccess.helper.ViewHelper import com.fastaccess.provider.scheme.LinkParserHelper import com.fastaccess.provider.timeline.CommentsHelper import com.fastaccess.provider.timeline.HtmlHelper import com.fastaccess.provider.timeline.handler.drawable.DrawableGetter import com.fastaccess.ui.adapter.callback.OnToggleView -import com.fastaccess.ui.widgets.AvatarLayout -import com.fastaccess.ui.widgets.FontTextView -import com.fastaccess.ui.widgets.ForegroundImageView -import com.fastaccess.ui.widgets.SpannableBuilder +import com.fastaccess.ui.widgets.* import com.fastaccess.ui.widgets.recyclerview.BaseRecyclerAdapter import com.fastaccess.ui.widgets.recyclerview.BaseViewHolder import pr.type.ReactionContent @@ -33,6 +31,8 @@ class ReviewCommentsViewHolder private constructor(view: View, adapter: BaseRecy val viewGroup: ViewGroup, val onToggleView: OnToggleView) : BaseViewHolder(view, adapter) { + + init { itemView.setOnClickListener(null) itemView.setOnLongClickListener(null) @@ -71,6 +71,7 @@ class ReviewCommentsViewHolder private constructor(view: View, adapter: BaseRecy @BindView(R.id.comment) lateinit var comment: FontTextView @BindView(R.id.reactionsText) lateinit var reactionsText: FontTextView @BindView(R.id.owner) lateinit var owner: FontTextView + @BindView(R.id.pathText) lateinit var pathText: FontTextView override fun onClick(v: View) { if (v.id == R.id.toggle || v.id == R.id.toggleHolder) { @@ -86,6 +87,11 @@ class ReviewCommentsViewHolder private constructor(view: View, adapter: BaseRecy override fun bind(t: PullRequestReviewModel) { val commentsModel = t.node val author3 = commentsModel.author() + pathText.visibility = View.VISIBLE + pathText.text = DiffLineSpan.getSpannable(commentsModel.diffHunk(), + ViewHelper.getPatchAdditionColor(itemView.context), + ViewHelper.getPatchDeletionColor(itemView.context), + ViewHelper.getPatchRefColor(itemView.context), true) owner.visibility = View.VISIBLE owner.text = if ("none".equals(commentsModel.authorAssociation().name.toLowerCase(), ignoreCase = true)) "" else commentsModel.authorAssociation().name.toLowerCase() diff --git a/app/src/main/java/com/fastaccess/ui/widgets/DiffLineSpan.java b/app/src/main/java/com/fastaccess/ui/widgets/DiffLineSpan.java index d3a70f1b..7c7d3432 100644 --- a/app/src/main/java/com/fastaccess/ui/widgets/DiffLineSpan.java +++ b/app/src/main/java/com/fastaccess/ui/widgets/DiffLineSpan.java @@ -71,7 +71,7 @@ public class DiffLineSpan extends MetricAffectingSpan implements LineBackgroundS int lines = split.length; int index = -1; for (int i = 0; i < lines; i++) { - if (truncate && (lines - i) > 3) continue; + if (truncate && (lines - i) > 2) continue; String token = split[i]; if (i < (lines - 1)) { token = token.concat("\n"); diff --git a/app/src/main/res/layouts/row_layouts/layout/review_timeline_row_item.xml b/app/src/main/res/layouts/row_layouts/layout/review_timeline_row_item.xml index 6f1a31d5..a444c0fb 100644 --- a/app/src/main/res/layouts/row_layouts/layout/review_timeline_row_item.xml +++ b/app/src/main/res/layouts/row_layouts/layout/review_timeline_row_item.xml @@ -4,6 +4,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" + xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_marginBottom="@dimen/spacing_normal" android:layout_marginEnd="@dimen/layout_margin" android:layout_marginStart="@dimen/layout_margin" @@ -100,7 +101,9 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/reviewHolder" - android:layout_marginBottom="@dimen/spacing_normal" + app:layoutManager="@string/linear_layout_manager" + android:layout_marginBottom="@dimen/spacing_micro" + android:layout_marginTop="@dimen/spacing_micro" android:visibility="gone" tools:visibility="visible"/>