Add isLive indicator

This commit is contained in:
Ivan Agosto 2024-03-25 19:57:49 -06:00
parent eeb20f1f9d
commit 2fcd3b21f8
7 changed files with 91 additions and 16 deletions

View File

@ -9,7 +9,6 @@ import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import com.squareup.picasso.Picasso
import kotlinx.android.synthetic.main.view_video.view.duration
import org.libre.agosto.p2play.*
import org.libre.agosto.p2play.helpers.mapSeconds
import org.libre.agosto.p2play.models.VideoModel
@ -30,6 +29,7 @@ class VideosAdapter(private val myDataset: ArrayList<VideoModel>) :
val description: TextView
val context: Context
val duration: TextView
val isLive: TextView
init {
// Define click listener for the ViewHolder's View
@ -38,7 +38,8 @@ class VideosAdapter(private val myDataset: ArrayList<VideoModel>) :
thumb = view.findViewById(R.id.thumb)
userImg = view.findViewById(R.id.userImg)
context = view.context
duration = view.duration
duration = view.findViewById(R.id.duration)
isLive = view.findViewById(R.id.isLive)
}
}
@ -83,6 +84,9 @@ class VideosAdapter(private val myDataset: ArrayList<VideoModel>) :
holder.description.text = myDataset[position].username+" - "+myDataset[position].views+" "+viewsText
if (myDataset[position].isLive) {
holder.isLive.visibility = View.VISIBLE
}
}
// Return the size of your dataset (invoked by the layout manager)

View File

@ -0,0 +1,25 @@
package org.libre.agosto.p2play.models
import android.util.JsonReader
class StreamingModel(
var playlistUrl: String = "",
var segmentsSha256Url: String = "",
// TODO: Download Files
) {
fun parse(data: JsonReader) {
data.beginObject()
while (data.hasNext()) {
val key = data.nextName()
when (key.toString()) {
"playlistUrl"->{
this.playlistUrl = data.nextString()
}
"segmentsSha256Url"->{
this.segmentsSha256Url = data.nextString()
}
else -> data.skipValue()
}
}
}
}

View File

@ -5,19 +5,21 @@ import android.util.JsonToken
import java.io.Serializable
class VideoModel(
var id: Int = 0,
var uuid: String = "",
var name: String = "",
var description: String = "",
var thumbUrl: String = "",
var userImageUrl: String = "",
var embedUrl: String = "",
var duration: Number = 0,
var username: String = "",
var views: Number = 0,
var userUuid: String = "",
var userHost: String = "",
var nameChannel: String = ""
var id: Int = 0,
var uuid: String = "",
var name: String = "",
var description: String = "",
var thumbUrl: String = "",
var userImageUrl: String = "",
var embedUrl: String = "",
var duration: Number = 0,
var username: String = "",
var views: Number = 0,
var userUuid: String = "",
var userHost: String = "",
var nameChannel: String = "",
var isLive: Boolean = false,
var streamingData: StreamingModel? = null
):Serializable {
fun getChannel(): String {
return "$nameChannel@$userHost"
@ -55,6 +57,18 @@ class VideoModel(
"views"->{
this.views = data.nextInt()
}
"isLive"-> {
this.isLive = data.nextBoolean()
}
"streamingPlaylists"-> {
data.beginArray()
if (data.hasNext()) {
val streamingData = StreamingModel()
streamingData.parse(data)
this.streamingData = streamingData
}
data.endArray()
}
"channel"->{
data.beginObject()
while (data.hasNext()){

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="5dp" />
<!-- This is the border color -->
<!--- This is the background color -->
<solid android:color="@color/colorDislike" />
</shape>

View File

@ -30,6 +30,23 @@
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@android:drawable/ic_menu_gallery" />
<TextView
android:id="@+id/isLive"
android:layout_width="65dp"
android:layout_height="19dp"
android:layout_marginStart="8dp"
android:layout_marginBottom="16dp"
android:background="@drawable/live_shape"
android:ems="10"
android:paddingHorizontal="3dp"
android:text="@string/is_live_video"
android:textAlignment="center"
android:textColor="@color/durationColor"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:visibility="invisible" />
<TextView
android:id="@+id/duration"
android:layout_width="65dp"

View File

@ -48,6 +48,7 @@
<string name="timeMin_text">minutos</string>
<string name="timeHrs_text">horas</string>
<string name="nav_header_title">Inicia session</string>
<string name="is_live_video">En vivo</string>
<!-- Toast msg -->
<string name="logout_msg">Te has desconectado</string>
<!-- End Main strings -->

View File

@ -9,7 +9,6 @@
<string name="charging">Loading…</string>
<!-- End Global string -->
<!-- Start About strings -->
<string name="aboutGitUrl" translatable="false">https://gitlab.com/agosto182/p2play/</string>
<string name="aboutGnuUrl" translatable="false">https://personaljournal.ca/p2play/</string>
@ -60,6 +59,7 @@
<string name="timeHrs_text">hours</string>
<string name="nav_header_title">Log In</string>
<string name="nav_header_subtitle" translatable="false">P2Play</string>
<string name="is_live_video">Live</string>
<!-- Toast msg -->
<string name="logout_msg">You are now disconnected</string>
<!-- End Main strings -->