diff --git a/app/src/main/java/org/libre/agosto/p2play/adapters/VideosAdapter.kt b/app/src/main/java/org/libre/agosto/p2play/adapters/VideosAdapter.kt index 169fa9f..6e75709 100644 --- a/app/src/main/java/org/libre/agosto/p2play/adapters/VideosAdapter.kt +++ b/app/src/main/java/org/libre/agosto/p2play/adapters/VideosAdapter.kt @@ -9,7 +9,9 @@ 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 import java.io.Serializable @@ -27,6 +29,7 @@ class VideosAdapter(private val myDataset: ArrayList) : val tittle: TextView val description: TextView val context: Context + val duration: TextView init { // Define click listener for the ViewHolder's View @@ -35,6 +38,7 @@ class VideosAdapter(private val myDataset: ArrayList) : thumb = view.findViewById(R.id.thumb) userImg = view.findViewById(R.id.userImg) context = view.context + duration = view.duration } } @@ -71,19 +75,12 @@ class VideosAdapter(private val myDataset: ArrayList) : Picasso.get().load(R.drawable.default_avatar).into(holder.userImg) 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(); - if(seconds > 60 && seconds < (60 * 60)){ - 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() - } + val timeString = mapSeconds(seconds) - 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 } diff --git a/app/src/main/java/org/libre/agosto/p2play/helpers/mapSeconds.kt b/app/src/main/java/org/libre/agosto/p2play/helpers/mapSeconds.kt new file mode 100644 index 0000000..fd99d08 --- /dev/null +++ b/app/src/main/java/org/libre/agosto/p2play/helpers/mapSeconds.kt @@ -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 +} \ No newline at end of file diff --git a/app/src/main/res/drawable/round_text.xml b/app/src/main/res/drawable/round_text.xml new file mode 100644 index 0000000..be16090 --- /dev/null +++ b/app/src/main/res/drawable/round_text.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + diff --git a/app/src/main/res/layout/view_video.xml b/app/src/main/res/layout/view_video.xml index da37fc6..2a69422 100644 --- a/app/src/main/res/layout/view_video.xml +++ b/app/src/main/res/layout/view_video.xml @@ -14,11 +14,34 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent"> - + android:layout_height="match_parent"> + + + + + #FF3C9100 #ec020e #262626 + + #88000000 + #ffffff #f16805 #9F4200