mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-13 13:50:30 +05:30
Basic Comments Impletation
This commit is contained in:
parent
d58725495b
commit
8b09b6ad42
@ -31,7 +31,9 @@ import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.preference.PreferenceManager
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.github.libretube.adapters.CommentsAdapter
|
||||
import com.github.libretube.adapters.TrendingAdapter
|
||||
import com.github.libretube.obj.PipedStream
|
||||
import com.github.libretube.obj.Subscribe
|
||||
@ -75,6 +77,7 @@ class PlayerFragment : Fragment() {
|
||||
var isSubscribed: Boolean = false
|
||||
|
||||
private lateinit var relatedRecView: RecyclerView
|
||||
private lateinit var commentsRecView: RecyclerView
|
||||
private lateinit var exoPlayerView: StyledPlayerView
|
||||
private lateinit var motionLayout: MotionLayout
|
||||
private lateinit var exoPlayer: ExoPlayer
|
||||
@ -221,6 +224,9 @@ class PlayerFragment : Fragment() {
|
||||
isFullScreen = false
|
||||
}
|
||||
}
|
||||
commentsRecView = view.findViewById(R.id.comments_recView)
|
||||
commentsRecView.layoutManager = LinearLayoutManager(view.context)
|
||||
|
||||
relatedRecView = view.findViewById(R.id.player_recView)
|
||||
relatedRecView.layoutManager =
|
||||
GridLayoutManager(view.context, resources.getInteger(R.integer.grid_items))
|
||||
@ -265,7 +271,6 @@ class PlayerFragment : Fragment() {
|
||||
Toast.makeText(context, R.string.server_error, Toast.LENGTH_SHORT).show()
|
||||
return@launchWhenCreated
|
||||
}
|
||||
Toast.makeText(context, commentsResponse.disabled.toString(), Toast.LENGTH_LONG).show()
|
||||
var videosNameArray: Array<CharSequence> = arrayOf()
|
||||
videosNameArray += "HLS"
|
||||
for (vid in response.videoStreams!!) {
|
||||
@ -489,6 +494,7 @@ class PlayerFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
})
|
||||
commentsRecView.adapter = CommentsAdapter(commentsResponse.comments)
|
||||
relatedRecView.adapter = TrendingAdapter(response.relatedStreams!!)
|
||||
view.findViewById<TextView>(R.id.player_description).text =
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
|
@ -0,0 +1,37 @@
|
||||
package com.github.libretube.adapters
|
||||
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.github.libretube.R
|
||||
import com.github.libretube.obj.Comment
|
||||
import com.squareup.picasso.Picasso
|
||||
|
||||
class CommentsAdapter(private val comments: List<Comment>): RecyclerView.Adapter<ViewHolder>(){
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
var commentsView = LayoutInflater.from(parent.context).inflate(R.layout.comments_row, parent, false)
|
||||
return ViewHolder(commentsView)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
holder.v.findViewById<TextView>(R.id.comment_author).text = comments[position].author.toString()
|
||||
holder.v.findViewById<TextView>(R.id.comment_text).text = comments[position].commentText.toString()
|
||||
val thumbnailImage = holder.v.findViewById<ImageView>(R.id.commentor_image)
|
||||
Picasso.get().load(comments[position].thumbnail).into(thumbnailImage)
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return comments.size
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class ViewHolder(val v: View): RecyclerView.ViewHolder(v){
|
||||
init {
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
data class CommentsPage(
|
||||
val comments: List<Comment>? = listOf(),
|
||||
val comments: List<Comment> = listOf(),
|
||||
val disabled: Boolean? = null,
|
||||
val nextpage: String? = "",
|
||||
){
|
||||
|
47
app/src/main/res/layout/comments_row.xml
Normal file
47
app/src/main/res/layout/comments_row.xml
Normal file
@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<de.hdodenhof.circleimageview.CircleImageView
|
||||
android:id="@+id/commentor_image"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
app:srcCompat="@mipmap/ic_launcher" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/comment_author"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
android:text="Author"
|
||||
android:textSize="15sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/comment_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="16dp"
|
||||
android:text="Comment Text" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -254,19 +254,26 @@
|
||||
android:id="@+id/tv_suggestion"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:text="More like that"
|
||||
android:textSize="17sp"
|
||||
android:visibility="gone"/>
|
||||
android:layout_margin="10dp"
|
||||
android:text="@string/comments"
|
||||
android:textSize="17sp" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/comments_recView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="10dp"
|
||||
android:layout_below="@id/tv_suggestion" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/player_recView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/tv_suggestion"
|
||||
android:layout_margin="10dp"
|
||||
android:layout_below="@id/comments_recView"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:nestedScrollingEnabled="false" />
|
||||
</RelativeLayout>
|
||||
|
||||
|
@ -63,4 +63,5 @@
|
||||
<string name="lightTheme">Light Theme</string>
|
||||
<string name="darkTheme">Dark Theme</string>
|
||||
<string name="subscribers">%1$s subscribers</string>
|
||||
<string name="comments">Comments</string>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user