From bfac73b992dd65e8e34838e412409bf600f5d229 Mon Sep 17 00:00:00 2001 From: Kalle Struik Date: Tue, 27 Jul 2021 22:34:59 +0200 Subject: [PATCH] Make heart visible in android studio and move logic to the right file. --- .../newpipe/info_list/holder/CommentsInfoItemHolder.java | 6 ++++++ .../info_list/holder/CommentsMiniInfoItemHolder.java | 9 --------- app/src/main/res/layout/list_comments_item.xml | 1 + 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/info_list/holder/CommentsInfoItemHolder.java b/app/src/main/java/org/schabi/newpipe/info_list/holder/CommentsInfoItemHolder.java index 842d9c455..fb144574a 100644 --- a/app/src/main/java/org/schabi/newpipe/info_list/holder/CommentsInfoItemHolder.java +++ b/app/src/main/java/org/schabi/newpipe/info_list/holder/CommentsInfoItemHolder.java @@ -1,6 +1,8 @@ package org.schabi.newpipe.info_list.holder; +import android.view.View; import android.view.ViewGroup; +import android.widget.ImageView; import android.widget.TextView; import org.schabi.newpipe.R; @@ -31,11 +33,13 @@ import org.schabi.newpipe.local.history.HistoryRecordManager; public class CommentsInfoItemHolder extends CommentsMiniInfoItemHolder { public final TextView itemTitleView; + private final ImageView itemHeartView; public CommentsInfoItemHolder(final InfoItemBuilder infoItemBuilder, final ViewGroup parent) { super(infoItemBuilder, R.layout.list_comments_item, parent); itemTitleView = itemView.findViewById(R.id.itemTitleView); + itemHeartView = itemView.findViewById(R.id.detail_heart_image_view); } @Override @@ -49,5 +53,7 @@ public class CommentsInfoItemHolder extends CommentsMiniInfoItemHolder { final CommentsInfoItem item = (CommentsInfoItem) infoItem; itemTitleView.setText(item.getUploaderName()); + + itemHeartView.setVisibility(item.isHeartedByUploader() ? View.VISIBLE : View.GONE); } } diff --git a/app/src/main/java/org/schabi/newpipe/info_list/holder/CommentsMiniInfoItemHolder.java b/app/src/main/java/org/schabi/newpipe/info_list/holder/CommentsMiniInfoItemHolder.java index 7c4f67267..629240dc6 100644 --- a/app/src/main/java/org/schabi/newpipe/info_list/holder/CommentsMiniInfoItemHolder.java +++ b/app/src/main/java/org/schabi/newpipe/info_list/holder/CommentsMiniInfoItemHolder.java @@ -7,7 +7,6 @@ import android.text.style.URLSpan; import android.text.util.Linkify; import android.view.View; import android.view.ViewGroup; -import android.widget.ImageView; import android.widget.RelativeLayout; import android.widget.TextView; @@ -46,7 +45,6 @@ public class CommentsMiniInfoItemHolder extends InfoItemHolder { private final TextView itemContentView; private final TextView itemLikesCountView; private final TextView itemDislikesCountView; - private final ImageView itemHeartView; private final TextView itemPublishedTime; private String commentText; @@ -82,7 +80,6 @@ public class CommentsMiniInfoItemHolder extends InfoItemHolder { itemDislikesCountView = itemView.findViewById(R.id.detail_thumbs_down_count_view); itemPublishedTime = itemView.findViewById(R.id.itemPublishedTime); itemContentView = itemView.findViewById(R.id.itemCommentContentView); - itemHeartView = itemView.findViewById(R.id.detail_heart_image_view); downloadThumbnailKey = infoItemBuilder.getContext(). getString(R.string.download_thumbnail_key); @@ -155,12 +152,6 @@ public class CommentsMiniInfoItemHolder extends InfoItemHolder { itemPublishedTime.setText(item.getTextualUploadDate()); } - if (item.isHeartedByUploader()) { - itemHeartView.setVisibility(View.VISIBLE); - } else { - itemHeartView.setVisibility(View.GONE); - } - itemView.setOnClickListener(view -> { toggleEllipsize(); if (itemBuilder.getOnCommentsSelectedListener() != null) { diff --git a/app/src/main/res/layout/list_comments_item.xml b/app/src/main/res/layout/list_comments_item.xml index af81cbd98..fb526aa06 100644 --- a/app/src/main/res/layout/list_comments_item.xml +++ b/app/src/main/res/layout/list_comments_item.xml @@ -80,6 +80,7 @@ android:layout_toRightOf="@+id/detail_thumbs_up_count_view" android:contentDescription="@string/detail_heart_img_view_description" android:visibility="gone" + tools:visibility="visible" app:srcCompat="@drawable/ic_heart" />