Add isLive indicator
This commit is contained in:
parent
eeb20f1f9d
commit
2fcd3b21f8
|
@ -9,7 +9,6 @@ import android.view.ViewGroup
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import com.squareup.picasso.Picasso
|
import com.squareup.picasso.Picasso
|
||||||
import kotlinx.android.synthetic.main.view_video.view.duration
|
|
||||||
import org.libre.agosto.p2play.*
|
import org.libre.agosto.p2play.*
|
||||||
import org.libre.agosto.p2play.helpers.mapSeconds
|
import org.libre.agosto.p2play.helpers.mapSeconds
|
||||||
import org.libre.agosto.p2play.models.VideoModel
|
import org.libre.agosto.p2play.models.VideoModel
|
||||||
|
@ -30,6 +29,7 @@ class VideosAdapter(private val myDataset: ArrayList<VideoModel>) :
|
||||||
val description: TextView
|
val description: TextView
|
||||||
val context: Context
|
val context: Context
|
||||||
val duration: TextView
|
val duration: TextView
|
||||||
|
val isLive: TextView
|
||||||
|
|
||||||
init {
|
init {
|
||||||
// Define click listener for the ViewHolder's View
|
// 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)
|
thumb = view.findViewById(R.id.thumb)
|
||||||
userImg = view.findViewById(R.id.userImg)
|
userImg = view.findViewById(R.id.userImg)
|
||||||
context = view.context
|
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
|
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)
|
// Return the size of your dataset (invoked by the layout manager)
|
||||||
|
|
|
@ -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()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,7 +17,9 @@ class VideoModel(
|
||||||
var views: Number = 0,
|
var views: Number = 0,
|
||||||
var userUuid: String = "",
|
var userUuid: String = "",
|
||||||
var userHost: String = "",
|
var userHost: String = "",
|
||||||
var nameChannel: String = ""
|
var nameChannel: String = "",
|
||||||
|
var isLive: Boolean = false,
|
||||||
|
var streamingData: StreamingModel? = null
|
||||||
):Serializable {
|
):Serializable {
|
||||||
fun getChannel(): String {
|
fun getChannel(): String {
|
||||||
return "$nameChannel@$userHost"
|
return "$nameChannel@$userHost"
|
||||||
|
@ -55,6 +57,18 @@ class VideoModel(
|
||||||
"views"->{
|
"views"->{
|
||||||
this.views = data.nextInt()
|
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"->{
|
"channel"->{
|
||||||
data.beginObject()
|
data.beginObject()
|
||||||
while (data.hasNext()){
|
while (data.hasNext()){
|
||||||
|
|
|
@ -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>
|
|
@ -30,6 +30,23 @@
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:srcCompat="@android:drawable/ic_menu_gallery" />
|
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
|
<TextView
|
||||||
android:id="@+id/duration"
|
android:id="@+id/duration"
|
||||||
android:layout_width="65dp"
|
android:layout_width="65dp"
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
<string name="timeMin_text">minutos</string>
|
<string name="timeMin_text">minutos</string>
|
||||||
<string name="timeHrs_text">horas</string>
|
<string name="timeHrs_text">horas</string>
|
||||||
<string name="nav_header_title">Inicia session</string>
|
<string name="nav_header_title">Inicia session</string>
|
||||||
|
<string name="is_live_video">En vivo</string>
|
||||||
<!-- Toast msg -->
|
<!-- Toast msg -->
|
||||||
<string name="logout_msg">Te has desconectado</string>
|
<string name="logout_msg">Te has desconectado</string>
|
||||||
<!-- End Main strings -->
|
<!-- End Main strings -->
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
<string name="charging">Loading…</string>
|
<string name="charging">Loading…</string>
|
||||||
<!-- End Global string -->
|
<!-- End Global string -->
|
||||||
|
|
||||||
|
|
||||||
<!-- Start About strings -->
|
<!-- Start About strings -->
|
||||||
<string name="aboutGitUrl" translatable="false">https://gitlab.com/agosto182/p2play/</string>
|
<string name="aboutGitUrl" translatable="false">https://gitlab.com/agosto182/p2play/</string>
|
||||||
<string name="aboutGnuUrl" translatable="false">https://personaljournal.ca/p2play/</string>
|
<string name="aboutGnuUrl" translatable="false">https://personaljournal.ca/p2play/</string>
|
||||||
|
@ -60,6 +59,7 @@
|
||||||
<string name="timeHrs_text">hours</string>
|
<string name="timeHrs_text">hours</string>
|
||||||
<string name="nav_header_title">Log In</string>
|
<string name="nav_header_title">Log In</string>
|
||||||
<string name="nav_header_subtitle" translatable="false">P2Play</string>
|
<string name="nav_header_subtitle" translatable="false">P2Play</string>
|
||||||
|
<string name="is_live_video">Live</string>
|
||||||
<!-- Toast msg -->
|
<!-- Toast msg -->
|
||||||
<string name="logout_msg">You are now disconnected</string>
|
<string name="logout_msg">You are now disconnected</string>
|
||||||
<!-- End Main strings -->
|
<!-- End Main strings -->
|
||||||
|
|
Loading…
Reference in New Issue