Rename videoViews to formatShort.

This commit is contained in:
FireMasterK 2022-02-14 20:56:32 +00:00
parent a7f4472a5a
commit 24e31c4efb
No known key found for this signature in database
GPG Key ID: 49451E4482CC5BCD
8 changed files with 13 additions and 49 deletions

View File

@ -191,7 +191,7 @@ class ChannelFragment : Fragment() {
isLoading=false
runOnUiThread {
view.findViewById<TextView>(R.id.channel_name).text=response.name
view.findViewById<TextView>(R.id.channel_subs).text=response.subscriberCount.videoViews() + " subscribers"
view.findViewById<TextView>(R.id.channel_subs).text=response.subscriberCount.formatShort() + " subscribers"
view.findViewById<TextView>(R.id.channel_description).text=response.description
val bannerImage = view.findViewById<ImageView>(R.id.channel_banner)
val channelImage = view.findViewById<ImageView>(R.id.channel_image)

View File

@ -1,7 +1,5 @@
package com.github.libretube
import android.R.attr
import android.R.attr.*
import android.annotation.SuppressLint
import android.os.Bundle
import androidx.fragment.app.Fragment
@ -9,18 +7,14 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.constraintlayout.motion.widget.MotionLayout
import androidx.constraintlayout.widget.ConstraintSet
import androidx.recyclerview.widget.RecyclerView
import com.google.android.exoplayer2.ExoPlayer
import com.google.android.exoplayer2.MediaItem
import com.google.android.exoplayer2.MediaItem.SubtitleConfiguration
import com.google.android.exoplayer2.source.MediaSource
import com.google.android.exoplayer2.ui.PlayerView
import com.google.android.exoplayer2.ui.StyledPlayerControlView
import com.google.android.exoplayer2.ui.StyledPlayerView
import okhttp3.*
import java.io.IOException
import kotlin.math.abs
import com.google.android.exoplayer2.util.MimeTypes
@ -29,26 +23,17 @@ import android.app.ActionBar
import android.app.Activity
import android.content.Context
import android.content.DialogInterface
import android.content.Intent
import android.content.pm.ActivityInfo
import android.graphics.Color
import android.widget.*
import androidx.core.net.toUri
import com.google.android.exoplayer2.C.SELECTION_FLAG_DEFAULT
import com.google.android.exoplayer2.MediaItem.fromUri
import com.google.android.exoplayer2.Player.REPEAT_MODE_ONE
import com.google.android.exoplayer2.source.MergingMediaSource
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector
import com.google.android.exoplayer2.source.ProgressiveMediaSource
import com.google.android.exoplayer2.upstream.DataSource
import com.google.android.exoplayer2.upstream.DefaultHttpDataSource
import android.widget.PopupWindow
import android.widget.TextView
import android.graphics.drawable.Drawable
import com.google.android.exoplayer2.util.Util
import android.graphics.drawable.ColorDrawable
import android.os.Build
import android.text.Html
import android.util.Log
@ -56,27 +41,14 @@ import android.util.TypedValue
import androidx.appcompat.app.AlertDialog
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.os.bundleOf
import androidx.core.text.PrecomputedTextCompat
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import com.google.android.exoplayer2.Player
import com.google.android.exoplayer2.Player.STATE_IDLE
import com.google.android.exoplayer2.source.DefaultMediaSourceFactory
import com.google.android.exoplayer2.util.RepeatModeUtil
import com.google.android.exoplayer2.ui.TimeBar
import com.google.android.exoplayer2.ui.TimeBar.OnScrubListener
import com.squareup.picasso.Picasso
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import retrofit2.HttpException
import retrofit2.Retrofit
import retrofit2.converter.jackson.JacksonConverterFactory
import retrofit2.http.GET
import retrofit2.http.Path
import com.github.libretube.adapters.TrendingAdapter
import com.github.libretube.obj.PipedStream
import com.github.libretube.obj.Subscribe
@ -372,8 +344,8 @@ class PlayerFragment : Fragment() {
} else {
Html.fromHtml(response.description)
}
view.findViewById<TextView>(R.id.player_sub).text = response.views.videoViews() + " views • "+response.uploadDate
view.findViewById<TextView>(R.id.textLike).text = response.likes.videoViews()
view.findViewById<TextView>(R.id.player_sub).text = response.views.formatShort() + " views • "+response.uploadDate
view.findViewById<TextView>(R.id.textLike).text = response.likes.formatShort()
val channelImage = view.findViewById<ImageView>(R.id.player_channelImage)
Picasso.get().load(response.uploaderAvatar).into(channelImage)
view.findViewById<TextView>(R.id.player_channelName).text=response.uploader

View File

@ -3,7 +3,7 @@ package com.github.libretube
import java.math.BigDecimal
import java.math.RoundingMode
fun Long?.videoViews(): String = when {
fun Long?.formatShort(): String = when {
this!!<1000 -> {
this.toString()
}

View File

@ -8,14 +8,12 @@ import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.core.os.bundleOf
import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.MainActivity
import com.squareup.picasso.Picasso
import com.github.libretube.PlayerFragment
import com.github.libretube.R
import com.github.libretube.obj.StreamItem
import com.github.libretube.videoViews
import com.github.libretube.formatShort
class ChannelAdapter(private val videoFeed: MutableList<StreamItem>): RecyclerView.Adapter<ChannelViewHolder>() {
override fun getItemCount(): Int {
@ -36,7 +34,7 @@ class ChannelAdapter(private val videoFeed: MutableList<StreamItem>): RecyclerVi
override fun onBindViewHolder(holder: ChannelViewHolder, position: Int) {
val trending = videoFeed[position]
holder.v.findViewById<TextView>(R.id.channel_description).text = trending.title
holder.v.findViewById<TextView>(R.id.channel_views).text = trending.views.videoViews()+""+ DateUtils.getRelativeTimeSpanString(trending.uploaded!!)
holder.v.findViewById<TextView>(R.id.channel_views).text = trending.views.formatShort()+""+ DateUtils.getRelativeTimeSpanString(trending.uploaded!!)
holder.v.findViewById<TextView>(R.id.channel_duration).text = DateUtils.formatElapsedTime(trending.duration!!)
val thumbnailImage = holder.v.findViewById<ImageView>(R.id.channel_thumbnail)
Picasso.get().load(trending.thumbnail).into(thumbnailImage)

View File

@ -8,14 +8,11 @@ import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.core.os.bundleOf
import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.MainActivity
import com.squareup.picasso.Picasso
import com.github.libretube.PlayerFragment
import com.github.libretube.R
import com.github.libretube.obj.StreamItem
import com.github.libretube.videoViews
class PlaylistAdapter(private val videoFeed: MutableList<StreamItem>): RecyclerView.Adapter<PlaylistViewHolder>() {
override fun getItemCount(): Int {

View File

@ -7,9 +7,7 @@ import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import android.widget.VideoView
import androidx.appcompat.app.AppCompatActivity
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.os.bundleOf
import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.MainActivity
@ -17,8 +15,7 @@ import com.squareup.picasso.Picasso
import com.github.libretube.PlayerFragment
import com.github.libretube.R
import com.github.libretube.obj.SearchItem
import com.github.libretube.obj.StreamItem
import com.github.libretube.videoViews
import com.github.libretube.formatShort
class SearchAdapter(private val searchItems: List<SearchItem>): RecyclerView.Adapter<CustomViewHolder1>() {
@ -61,7 +58,7 @@ class CustomViewHolder1(private val v: View): RecyclerView.ViewHolder(v){
val title = v.findViewById<TextView>(R.id.search_description)
title.text = item.title
val views = v.findViewById<TextView>(R.id.search_views)
views.text = item.views.videoViews() +""+item.uploadedDate
views.text = item.views.formatShort() +""+item.uploadedDate
val channelName = v.findViewById<TextView>(R.id.search_channel_name)
channelName.text = item.uploaderName
v.setOnClickListener{
@ -89,7 +86,7 @@ class CustomViewHolder1(private val v: View): RecyclerView.ViewHolder(v){
val channelName = v.findViewById<TextView>(R.id.search_channel_name)
channelName.text = item.name
val channelViews = v.findViewById<TextView>(R.id.search_views)
channelViews.text = item.subscribers.videoViews() + "subscribers • "+ item.videos + " videos"
channelViews.text = item.subscribers.formatShort() + "subscribers • "+ item.videos + " videos"
v.setOnClickListener {
val activity = v.context as MainActivity
val bundle = bundleOf("channel_id" to item.url)

View File

@ -16,7 +16,7 @@ import com.squareup.picasso.Picasso
import com.github.libretube.PlayerFragment
import com.github.libretube.R
import com.github.libretube.obj.StreamItem
import com.github.libretube.videoViews
import com.github.libretube.formatShort
class SubscriptionAdapter(private val videoFeed: List<StreamItem>): RecyclerView.Adapter<SubscriptionViewHolder>() {
//private var limitedVideoFeed: MutableList<String> = [""].toMutableList()
@ -43,7 +43,7 @@ class SubscriptionAdapter(private val videoFeed: List<StreamItem>): RecyclerView
override fun onBindViewHolder(holder: SubscriptionViewHolder, position: Int) {
val trending = videoFeed[position]
holder.v.findViewById<TextView>(R.id.textView_title).text = trending.title
holder.v.findViewById<TextView>(R.id.textView_channel).text = trending.uploaderName +""+ trending.views.videoViews()+""+ DateUtils.getRelativeTimeSpanString(trending.uploaded!!)
holder.v.findViewById<TextView>(R.id.textView_channel).text = trending.uploaderName +""+ trending.views.formatShort()+""+ DateUtils.getRelativeTimeSpanString(trending.uploaded!!)
val thumbnailImage = holder.v.findViewById<ImageView>(R.id.thumbnail)
holder.v.findViewById<TextView>(R.id.thumbnail_duration).text = DateUtils.formatElapsedTime(trending.duration!!)
val channelImage = holder.v.findViewById<ImageView>(R.id.channel_image)

View File

@ -16,7 +16,7 @@ import com.squareup.picasso.Picasso
import com.github.libretube.PlayerFragment
import com.github.libretube.R
import com.github.libretube.obj.StreamItem
import com.github.libretube.videoViews
import com.github.libretube.formatShort
class TrendingAdapter(private val videoFeed: List<StreamItem>): RecyclerView.Adapter<CustomViewHolder>() {
override fun getItemCount(): Int {
@ -32,7 +32,7 @@ class TrendingAdapter(private val videoFeed: List<StreamItem>): RecyclerView.Ada
override fun onBindViewHolder(holder: CustomViewHolder, position: Int) {
val trending = videoFeed[position]
holder.v.findViewById<TextView>(R.id.textView_title).text = trending.title
holder.v.findViewById<TextView>(R.id.textView_channel).text = trending.uploaderName +""+ trending.views.videoViews()+""+DateUtils.getRelativeTimeSpanString(trending.uploaded!!)
holder.v.findViewById<TextView>(R.id.textView_channel).text = trending.uploaderName +""+ trending.views.formatShort()+""+DateUtils.getRelativeTimeSpanString(trending.uploaded!!)
val thumbnailImage = holder.v.findViewById<ImageView>(R.id.thumbnail)
holder.v.findViewById<TextView>(R.id.thumbnail_duration).text = DateUtils.formatElapsedTime(trending.duration!!)
val channelImage = holder.v.findViewById<ImageView>(R.id.channel_image)