From a4bd808f6b57c78a1c540ebc75e047720379b337 Mon Sep 17 00:00:00 2001 From: FireMasterK <20838718+FireMasterK@users.noreply.github.com> Date: Mon, 14 Feb 2022 20:11:52 +0000 Subject: [PATCH 1/5] Update dependencies. --- app/build.gradle | 6 +++--- build.gradle | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 0374a8db3..9f3729ba5 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -38,10 +38,10 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.4.1' implementation 'androidx.constraintlayout:constraintlayout:2.1.3' implementation 'com.google.android.material:material:1.6.0-alpha02' - implementation 'androidx.navigation:navigation-fragment-ktx:2.4.0' - implementation 'androidx.navigation:navigation-ui-ktx:2.4.0' + implementation 'androidx.navigation:navigation-fragment-ktx:2.4.1' + implementation 'androidx.navigation:navigation-ui-ktx:2.4.1' implementation 'androidx.legacy:legacy-support-v4:1.0.0' - implementation("androidx.preference:preference-ktx:1.2.0") + implementation 'androidx.preference:preference-ktx:1.2.0' androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' diff --git a/build.gradle b/build.gradle index 8ddcdda65..92704788b 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:7.1.0' + classpath 'com.android.tools.build:gradle:7.1.1' classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10' // NOTE: Do not place your application dependencies here; they belong From 70dab9fd4e0ab5700f6c411469a39672a6856659 Mon Sep 17 00:00:00 2001 From: FireMasterK <20838718+FireMasterK@users.noreply.github.com> Date: Mon, 14 Feb 2022 20:12:10 +0000 Subject: [PATCH 2/5] Change build configs. --- app/build.gradle | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 9f3729ba5..441c044cc 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -18,10 +18,14 @@ android { buildTypes { release { - minifyEnabled false + minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } + debug { + debuggable true + applicationIdSuffix ".debug" + } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 From a7f4472a5ae42bf29f1e5a06cf6267fba012f968 Mon Sep 17 00:00:00 2001 From: FireMasterK <20838718+FireMasterK@users.noreply.github.com> Date: Mon, 14 Feb 2022 20:47:50 +0000 Subject: [PATCH 3/5] Show duration on ImageView. --- .../java/com/github/libretube/adapters/ChannelAdapter.kt | 4 +++- .../com/github/libretube/adapters/PlaylistAdapter.kt | 2 ++ .../com/github/libretube/adapters/SubscriptionAdapter.kt | 4 +++- .../com/github/libretube/adapters/TrendingAdapter.kt | 4 +++- app/src/main/res/layout/trending_row.xml | 9 +++++++++ app/src/main/res/layout/video_channel_row.xml | 9 +++++++++ app/src/main/res/values/colors.xml | 3 +++ 7 files changed, 32 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/github/libretube/adapters/ChannelAdapter.kt b/app/src/main/java/com/github/libretube/adapters/ChannelAdapter.kt index dd6a35b2a..ab4339994 100644 --- a/app/src/main/java/com/github/libretube/adapters/ChannelAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/ChannelAdapter.kt @@ -1,6 +1,7 @@ package com.github.libretube.adapters import android.os.Bundle +import android.text.format.DateUtils import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -35,7 +36,8 @@ class ChannelAdapter(private val videoFeed: MutableList): RecyclerVi override fun onBindViewHolder(holder: ChannelViewHolder, position: Int) { val trending = videoFeed[position] holder.v.findViewById(R.id.channel_description).text = trending.title - holder.v.findViewById(R.id.channel_views).text = trending.views.videoViews()+" • "+trending.uploadedDate + holder.v.findViewById(R.id.channel_views).text = trending.views.videoViews()+" • "+ DateUtils.getRelativeTimeSpanString(trending.uploaded!!) + holder.v.findViewById(R.id.channel_duration).text = DateUtils.formatElapsedTime(trending.duration!!) val thumbnailImage = holder.v.findViewById(R.id.channel_thumbnail) Picasso.get().load(trending.thumbnail).into(thumbnailImage) holder.v.setOnClickListener{ diff --git a/app/src/main/java/com/github/libretube/adapters/PlaylistAdapter.kt b/app/src/main/java/com/github/libretube/adapters/PlaylistAdapter.kt index 0c74af0d2..1577c101d 100644 --- a/app/src/main/java/com/github/libretube/adapters/PlaylistAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/PlaylistAdapter.kt @@ -1,6 +1,7 @@ package com.github.libretube.adapters import android.os.Bundle +import android.text.format.DateUtils import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -36,6 +37,7 @@ class PlaylistAdapter(private val videoFeed: MutableList): RecyclerV val streamItem = videoFeed[position] holder.v.findViewById(R.id.channel_description).text = streamItem.title holder.v.findViewById(R.id.channel_views).text = streamItem.uploaderName + holder.v.findViewById(R.id.channel_duration).text = DateUtils.formatElapsedTime(streamItem.duration!!) val thumbnailImage = holder.v.findViewById(R.id.channel_thumbnail) Picasso.get().load(streamItem.thumbnail).into(thumbnailImage) holder.v.setOnClickListener{ diff --git a/app/src/main/java/com/github/libretube/adapters/SubscriptionAdapter.kt b/app/src/main/java/com/github/libretube/adapters/SubscriptionAdapter.kt index c3a712f23..4ce20afc5 100644 --- a/app/src/main/java/com/github/libretube/adapters/SubscriptionAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/SubscriptionAdapter.kt @@ -1,6 +1,7 @@ package com.github.libretube.adapters import android.os.Bundle +import android.text.format.DateUtils import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -42,8 +43,9 @@ class SubscriptionAdapter(private val videoFeed: List): RecyclerView override fun onBindViewHolder(holder: SubscriptionViewHolder, position: Int) { val trending = videoFeed[position] holder.v.findViewById(R.id.textView_title).text = trending.title - holder.v.findViewById(R.id.textView_channel).text = trending.uploaderName +" • "+ trending.views.videoViews()+" • "+trending.uploadedDate + holder.v.findViewById(R.id.textView_channel).text = trending.uploaderName +" • "+ trending.views.videoViews()+" • "+ DateUtils.getRelativeTimeSpanString(trending.uploaded!!) val thumbnailImage = holder.v.findViewById(R.id.thumbnail) + holder.v.findViewById(R.id.thumbnail_duration).text = DateUtils.formatElapsedTime(trending.duration!!) val channelImage = holder.v.findViewById(R.id.channel_image) channelImage.setOnClickListener{ val activity = holder.v.context as MainActivity diff --git a/app/src/main/java/com/github/libretube/adapters/TrendingAdapter.kt b/app/src/main/java/com/github/libretube/adapters/TrendingAdapter.kt index 409112613..89da2c561 100644 --- a/app/src/main/java/com/github/libretube/adapters/TrendingAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/TrendingAdapter.kt @@ -1,6 +1,7 @@ package com.github.libretube.adapters import android.os.Bundle +import android.text.format.DateUtils import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -31,8 +32,9 @@ class TrendingAdapter(private val videoFeed: List): RecyclerView.Ada override fun onBindViewHolder(holder: CustomViewHolder, position: Int) { val trending = videoFeed[position] holder.v.findViewById(R.id.textView_title).text = trending.title - holder.v.findViewById(R.id.textView_channel).text = trending.uploaderName +" • "+ trending.views.videoViews()+" • "+trending.uploadedDate + holder.v.findViewById(R.id.textView_channel).text = trending.uploaderName +" • "+ trending.views.videoViews()+" • "+DateUtils.getRelativeTimeSpanString(trending.uploaded!!) val thumbnailImage = holder.v.findViewById(R.id.thumbnail) + holder.v.findViewById(R.id.thumbnail_duration).text = DateUtils.formatElapsedTime(trending.duration!!) val channelImage = holder.v.findViewById(R.id.channel_image) channelImage.setOnClickListener{ val activity = holder.v.context as MainActivity diff --git a/app/src/main/res/layout/trending_row.xml b/app/src/main/res/layout/trending_row.xml index 943f33ac6..96b42d93d 100644 --- a/app/src/main/res/layout/trending_row.xml +++ b/app/src/main/res/layout/trending_row.xml @@ -27,6 +27,15 @@ android:layout_width="match_parent" android:layout_height="match_parent" /> + diff --git a/app/src/main/res/layout/video_channel_row.xml b/app/src/main/res/layout/video_channel_row.xml index 667c11440..ef136672c 100644 --- a/app/src/main/res/layout/video_channel_row.xml +++ b/app/src/main/res/layout/video_channel_row.xml @@ -34,6 +34,15 @@ android:layout_width="match_parent" android:layout_height="match_parent" tools:srcCompat="@tools:sample/backgrounds/scenic" /> + #000000 #ffffff + #AA000000 + #EEFFFFFF + #B81B3B #B81B3B #FFFFFF From 24e31c4efbd358cc585ebb94ee243bb1ba95de7c Mon Sep 17 00:00:00 2001 From: FireMasterK <20838718+FireMasterK@users.noreply.github.com> Date: Mon, 14 Feb 2022 20:56:32 +0000 Subject: [PATCH 4/5] Rename videoViews to formatShort. --- .../com/github/libretube/ChannelFragment.kt | 2 +- .../com/github/libretube/PlayerFragment.kt | 32 ++----------------- .../java/com/github/libretube/VideoViews.kt | 2 +- .../libretube/adapters/ChannelAdapter.kt | 6 ++-- .../libretube/adapters/PlaylistAdapter.kt | 3 -- .../libretube/adapters/SearchAdapter.kt | 9 ++---- .../libretube/adapters/SubscriptionAdapter.kt | 4 +-- .../libretube/adapters/TrendingAdapter.kt | 4 +-- 8 files changed, 13 insertions(+), 49 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ChannelFragment.kt b/app/src/main/java/com/github/libretube/ChannelFragment.kt index 9346aa0f0..b2f25cff0 100644 --- a/app/src/main/java/com/github/libretube/ChannelFragment.kt +++ b/app/src/main/java/com/github/libretube/ChannelFragment.kt @@ -191,7 +191,7 @@ class ChannelFragment : Fragment() { isLoading=false runOnUiThread { view.findViewById(R.id.channel_name).text=response.name - view.findViewById(R.id.channel_subs).text=response.subscriberCount.videoViews() + " subscribers" + view.findViewById(R.id.channel_subs).text=response.subscriberCount.formatShort() + " subscribers" view.findViewById(R.id.channel_description).text=response.description val bannerImage = view.findViewById(R.id.channel_banner) val channelImage = view.findViewById(R.id.channel_image) diff --git a/app/src/main/java/com/github/libretube/PlayerFragment.kt b/app/src/main/java/com/github/libretube/PlayerFragment.kt index d5f71ac97..abbe01082 100644 --- a/app/src/main/java/com/github/libretube/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/PlayerFragment.kt @@ -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(R.id.player_sub).text = response.views.videoViews() + " views • "+response.uploadDate - view.findViewById(R.id.textLike).text = response.likes.videoViews() + view.findViewById(R.id.player_sub).text = response.views.formatShort() + " views • "+response.uploadDate + view.findViewById(R.id.textLike).text = response.likes.formatShort() val channelImage = view.findViewById(R.id.player_channelImage) Picasso.get().load(response.uploaderAvatar).into(channelImage) view.findViewById(R.id.player_channelName).text=response.uploader diff --git a/app/src/main/java/com/github/libretube/VideoViews.kt b/app/src/main/java/com/github/libretube/VideoViews.kt index 81c301160..f8f45677c 100644 --- a/app/src/main/java/com/github/libretube/VideoViews.kt +++ b/app/src/main/java/com/github/libretube/VideoViews.kt @@ -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() } diff --git a/app/src/main/java/com/github/libretube/adapters/ChannelAdapter.kt b/app/src/main/java/com/github/libretube/adapters/ChannelAdapter.kt index ab4339994..1144bf460 100644 --- a/app/src/main/java/com/github/libretube/adapters/ChannelAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/ChannelAdapter.kt @@ -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): RecyclerView.Adapter() { override fun getItemCount(): Int { @@ -36,7 +34,7 @@ class ChannelAdapter(private val videoFeed: MutableList): RecyclerVi override fun onBindViewHolder(holder: ChannelViewHolder, position: Int) { val trending = videoFeed[position] holder.v.findViewById(R.id.channel_description).text = trending.title - holder.v.findViewById(R.id.channel_views).text = trending.views.videoViews()+" • "+ DateUtils.getRelativeTimeSpanString(trending.uploaded!!) + holder.v.findViewById(R.id.channel_views).text = trending.views.formatShort()+" • "+ DateUtils.getRelativeTimeSpanString(trending.uploaded!!) holder.v.findViewById(R.id.channel_duration).text = DateUtils.formatElapsedTime(trending.duration!!) val thumbnailImage = holder.v.findViewById(R.id.channel_thumbnail) Picasso.get().load(trending.thumbnail).into(thumbnailImage) diff --git a/app/src/main/java/com/github/libretube/adapters/PlaylistAdapter.kt b/app/src/main/java/com/github/libretube/adapters/PlaylistAdapter.kt index 1577c101d..ecdbe9194 100644 --- a/app/src/main/java/com/github/libretube/adapters/PlaylistAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/PlaylistAdapter.kt @@ -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): RecyclerView.Adapter() { override fun getItemCount(): Int { diff --git a/app/src/main/java/com/github/libretube/adapters/SearchAdapter.kt b/app/src/main/java/com/github/libretube/adapters/SearchAdapter.kt index b3ef217b5..ce17acfb3 100644 --- a/app/src/main/java/com/github/libretube/adapters/SearchAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/SearchAdapter.kt @@ -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): RecyclerView.Adapter() { @@ -61,7 +58,7 @@ class CustomViewHolder1(private val v: View): RecyclerView.ViewHolder(v){ val title = v.findViewById(R.id.search_description) title.text = item.title val views = v.findViewById(R.id.search_views) - views.text = item.views.videoViews() +" • "+item.uploadedDate + views.text = item.views.formatShort() +" • "+item.uploadedDate val channelName = v.findViewById(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(R.id.search_channel_name) channelName.text = item.name val channelViews = v.findViewById(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) diff --git a/app/src/main/java/com/github/libretube/adapters/SubscriptionAdapter.kt b/app/src/main/java/com/github/libretube/adapters/SubscriptionAdapter.kt index 4ce20afc5..5fa6da238 100644 --- a/app/src/main/java/com/github/libretube/adapters/SubscriptionAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/SubscriptionAdapter.kt @@ -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): RecyclerView.Adapter() { //private var limitedVideoFeed: MutableList = [""].toMutableList() @@ -43,7 +43,7 @@ class SubscriptionAdapter(private val videoFeed: List): RecyclerView override fun onBindViewHolder(holder: SubscriptionViewHolder, position: Int) { val trending = videoFeed[position] holder.v.findViewById(R.id.textView_title).text = trending.title - holder.v.findViewById(R.id.textView_channel).text = trending.uploaderName +" • "+ trending.views.videoViews()+" • "+ DateUtils.getRelativeTimeSpanString(trending.uploaded!!) + holder.v.findViewById(R.id.textView_channel).text = trending.uploaderName +" • "+ trending.views.formatShort()+" • "+ DateUtils.getRelativeTimeSpanString(trending.uploaded!!) val thumbnailImage = holder.v.findViewById(R.id.thumbnail) holder.v.findViewById(R.id.thumbnail_duration).text = DateUtils.formatElapsedTime(trending.duration!!) val channelImage = holder.v.findViewById(R.id.channel_image) diff --git a/app/src/main/java/com/github/libretube/adapters/TrendingAdapter.kt b/app/src/main/java/com/github/libretube/adapters/TrendingAdapter.kt index 89da2c561..6fabbd68f 100644 --- a/app/src/main/java/com/github/libretube/adapters/TrendingAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/TrendingAdapter.kt @@ -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): RecyclerView.Adapter() { override fun getItemCount(): Int { @@ -32,7 +32,7 @@ class TrendingAdapter(private val videoFeed: List): RecyclerView.Ada override fun onBindViewHolder(holder: CustomViewHolder, position: Int) { val trending = videoFeed[position] holder.v.findViewById(R.id.textView_title).text = trending.title - holder.v.findViewById(R.id.textView_channel).text = trending.uploaderName +" • "+ trending.views.videoViews()+" • "+DateUtils.getRelativeTimeSpanString(trending.uploaded!!) + holder.v.findViewById(R.id.textView_channel).text = trending.uploaderName +" • "+ trending.views.formatShort()+" • "+DateUtils.getRelativeTimeSpanString(trending.uploaded!!) val thumbnailImage = holder.v.findViewById(R.id.thumbnail) holder.v.findViewById(R.id.thumbnail_duration).text = DateUtils.formatElapsedTime(trending.duration!!) val channelImage = holder.v.findViewById(R.id.channel_image) From 87c52f7e58155367f44eb4bef333478ba41da1cf Mon Sep 17 00:00:00 2001 From: FireMasterK <20838718+FireMasterK@users.noreply.github.com> Date: Mon, 14 Feb 2022 20:57:50 +0000 Subject: [PATCH 5/5] Format file. --- .../java/com/github/libretube/VideoViews.kt | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/com/github/libretube/VideoViews.kt b/app/src/main/java/com/github/libretube/VideoViews.kt index f8f45677c..41c7c4cbe 100644 --- a/app/src/main/java/com/github/libretube/VideoViews.kt +++ b/app/src/main/java/com/github/libretube/VideoViews.kt @@ -4,19 +4,19 @@ import java.math.BigDecimal import java.math.RoundingMode fun Long?.formatShort(): String = when { - this!!<1000 -> { - this.toString() - } - this in 1000..999999 -> { - val decimal = BigDecimal(this/1000).setScale(0, RoundingMode.HALF_EVEN) - decimal.toString()+"K" - } - this in 1000000..10000000 -> { - val decimal = BigDecimal(this/1000000).setScale(0, RoundingMode.HALF_EVEN) - decimal.toString()+"M" - } - else -> { - val decimal = BigDecimal(this/1000000).setScale(0, RoundingMode.HALF_EVEN) - decimal.toString()+"M" - } - } + this!! < 1000 -> { + this.toString() + } + this in 1000..999999 -> { + val decimal = BigDecimal(this / 1000).setScale(0, RoundingMode.HALF_EVEN) + decimal.toString() + "K" + } + this in 1000000..10000000 -> { + val decimal = BigDecimal(this / 1000000).setScale(0, RoundingMode.HALF_EVEN) + decimal.toString() + "M" + } + else -> { + val decimal = BigDecimal(this / 1000000).setScale(0, RoundingMode.HALF_EVEN) + decimal.toString() + "M" + } +}