Update duration data to a floating text
This commit is contained in:
parent
ba0a298ea9
commit
40b193a816
|
@ -9,7 +9,9 @@ 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.models.VideoModel
|
import org.libre.agosto.p2play.models.VideoModel
|
||||||
import java.io.Serializable
|
import java.io.Serializable
|
||||||
|
|
||||||
|
@ -27,6 +29,7 @@ class VideosAdapter(private val myDataset: ArrayList<VideoModel>) :
|
||||||
val tittle: TextView
|
val tittle: TextView
|
||||||
val description: TextView
|
val description: TextView
|
||||||
val context: Context
|
val context: Context
|
||||||
|
val duration: TextView
|
||||||
|
|
||||||
init {
|
init {
|
||||||
// Define click listener for the ViewHolder's View
|
// Define click listener for the ViewHolder's View
|
||||||
|
@ -35,6 +38,7 @@ 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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,19 +75,12 @@ class VideosAdapter(private val myDataset: ArrayList<VideoModel>) :
|
||||||
Picasso.get().load(R.drawable.default_avatar).into(holder.userImg)
|
Picasso.get().load(R.drawable.default_avatar).into(holder.userImg)
|
||||||
|
|
||||||
val viewsText = holder.context.getString(R.string.view_text)
|
val viewsText = holder.context.getString(R.string.view_text)
|
||||||
var timeText = holder.context.getString(R.string.timeSec_text)
|
|
||||||
var timeString = myDataset[position].duration.toString()
|
|
||||||
val seconds = myDataset[position].duration.toInt();
|
val seconds = myDataset[position].duration.toInt();
|
||||||
if(seconds > 60 && seconds < (60 * 60)){
|
val timeString = mapSeconds(seconds)
|
||||||
timeText = holder.context.getString(R.string.timeMin_text)
|
|
||||||
timeString = (seconds / 60).toString() + ":" + (seconds % 60).toString()
|
|
||||||
}
|
|
||||||
else if(seconds > (60 * 60)){
|
|
||||||
timeText = holder.context.getString(R.string.timeHrs_text)
|
|
||||||
timeString = (seconds / 60 / 60).toString() + ":" + (seconds / 60 % 60).toString()
|
|
||||||
}
|
|
||||||
|
|
||||||
holder.description.text = myDataset[position].username+" - "+myDataset[position].views+" "+viewsText+" - "+timeString+" "+timeText
|
holder.duration.text = timeString
|
||||||
|
|
||||||
|
holder.description.text = myDataset[position].username+" - "+myDataset[position].views+" "+viewsText
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
package org.libre.agosto.p2play.helpers
|
||||||
|
|
||||||
|
fun mapSeconds (inputSeconds: Int): String {
|
||||||
|
val seconds = (inputSeconds % 60)
|
||||||
|
var minutes = inputSeconds / 60
|
||||||
|
var hours = 0
|
||||||
|
|
||||||
|
if (minutes > 60) {
|
||||||
|
hours = minutes / 60
|
||||||
|
minutes = minutes % 60
|
||||||
|
}
|
||||||
|
|
||||||
|
var result = minutes.toString().padStart(2, '0') + ":" + seconds.toString().padStart(2, '0')
|
||||||
|
|
||||||
|
if (hours > 0) {
|
||||||
|
result = hours.toString().padStart(2, '0') + ":" + result
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
|
@ -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="?attr/colorSecondary" />
|
||||||
|
|
||||||
|
</shape>
|
|
@ -14,11 +14,34 @@
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent">
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
<ImageView
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:id="@+id/thumb"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="230dp"
|
android:layout_height="match_parent">
|
||||||
app:srcCompat="@android:drawable/ic_menu_gallery" />
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/thumb"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="230dp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:srcCompat="@android:drawable/ic_menu_gallery" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/duration"
|
||||||
|
android:layout_width="65dp"
|
||||||
|
android:layout_height="19dp"
|
||||||
|
android:layout_marginEnd="8dp"
|
||||||
|
android:layout_marginBottom="16dp"
|
||||||
|
android:textColor="?attr/colorOnSecondary"
|
||||||
|
android:background="@drawable/round_text"
|
||||||
|
android:ems="10"
|
||||||
|
android:text="00:00"
|
||||||
|
android:paddingHorizontal="3dp"
|
||||||
|
android:textAlignment="center"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -11,6 +11,9 @@
|
||||||
<color name="colorDislike">#ec020e</color>
|
<color name="colorDislike">#ec020e</color>
|
||||||
<color name="colorProfile">#262626</color>
|
<color name="colorProfile">#262626</color>
|
||||||
|
|
||||||
|
<color name="durationBackground">#88000000</color>
|
||||||
|
<color name="durationColor">#ffffff</color>
|
||||||
|
|
||||||
<color name="seed">#f16805</color>
|
<color name="seed">#f16805</color>
|
||||||
<color name="md_theme_light_primary">#9F4200</color>
|
<color name="md_theme_light_primary">#9F4200</color>
|
||||||
<color name="md_theme_light_onPrimary">#FFFFFF</color>
|
<color name="md_theme_light_onPrimary">#FFFFFF</color>
|
||||||
|
|
Loading…
Reference in New Issue