Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,19 @@
import android.widget.ImageView;
import android.widget.TextView;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import org.schabi.newpipe.R;
import org.schabi.newpipe.extractor.InfoItem;
import org.schabi.newpipe.extractor.comments.CommentsInfoItem;
import org.schabi.newpipe.info_list.InfoItemBuilder;
import org.schabi.newpipe.info_list.InfoListAdapter;
import org.schabi.newpipe.local.history.HistoryRecordManager;

import java.util.List;
import java.util.Objects;

/*
* Created by Christian Schabesberger on 12.02.17.
*
Expand All @@ -35,11 +42,34 @@ public class CommentsInfoItemHolder extends CommentsMiniInfoItemHolder {
public final TextView itemTitleView;
private final ImageView itemHeartView;

private final TextView showReplies;
private final RecyclerView repliesView;

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);

showReplies = itemView.findViewById(R.id.showReplies);
repliesView = itemView.findViewById(R.id.replyRecycleView);
repliesView.setAdapter(new InfoListAdapter(repliesView.getContext()));
repliesView.setLayoutManager(new LinearLayoutManager(repliesView.getContext()));
}

public void addReplies(final View buttonView, final CommentsInfoItem comment) {

final List<CommentsInfoItem> replies = comment.getRepliesInfoList();
((InfoListAdapter) Objects.requireNonNull(repliesView.getAdapter()))
.setInfoItemList(replies);

final ViewGroup.MarginLayoutParams params =
(ViewGroup.MarginLayoutParams) repliesView.getLayoutParams();
params.topMargin = 45;

repliesView.setMinimumHeight(100);
repliesView.setHasFixedSize(true);
buttonView.setVisibility(View.GONE);
}

@Override
Expand All @@ -55,5 +85,13 @@ public void updateFromItem(final InfoItem infoItem,
itemTitleView.setText(item.getUploaderName());

itemHeartView.setVisibility(item.isHeartedByUploader() ? View.VISIBLE : View.GONE);

if (item.getReplies() == null) {
showReplies.setVisibility(View.GONE);
} else {
showReplies.setVisibility(View.VISIBLE);
showReplies.setOnClickListener(v -> addReplies(v, item));
}

}
}
34 changes: 32 additions & 2 deletions app/src/main/res/layout/list_comments_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@
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" />
app:srcCompat="@drawable/ic_heart"
tools:visibility="visible" />


<!--we can uncomment below code if we need dislike button and count in future-->
Expand Down Expand Up @@ -123,4 +123,34 @@
android:textSize="@dimen/video_item_search_upload_date_text_size"
tools:text="1 year ago" />

<TextView
android:id="@+id/showReplies"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/itemCommentContentView"
android:layout_alignEnd="@+id/itemCommentContentView"
android:layout_alignBottom="@+id/itemPublishedTime"
android:layout_marginStart="21dp"
android:layout_marginTop="0sp"
android:layout_marginEnd="0sp"
android:layout_marginBottom="0sp"
android:layout_toEndOf="@+id/itemPublishedTime"
android:text="Show Replies"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textSize="@dimen/video_item_search_upload_date_text_size" />

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/replyRecycleView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/showReplies"
android:layout_alignStart="@+id/itemCommentContentView"
android:layout_alignEnd="@+id/itemCommentContentView"
android:layout_marginStart="0dp"
android:layout_marginTop="0dp"
android:layout_marginEnd="0dp"
android:layout_marginBottom="0dp">

</androidx.recyclerview.widget.RecyclerView>

</RelativeLayout>