From 27c175648b0d255ccb381e60af24d13d3230eca5 Mon Sep 17 00:00:00 2001 From: FineFindus Date: Wed, 15 Nov 2023 19:03:35 +0100 Subject: [PATCH 1/2] fix(comment): only show highlight for owner Fixes a problem where, due to the way recycler views work, the show highlight was not reset properly, causing the highlight to be displayed on the wrong users. --- .../java/com/github/libretube/ui/adapters/CommentsAdapter.kt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/adapters/CommentsAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/CommentsAdapter.kt index 844738bcc..66543465a 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/CommentsAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/CommentsAdapter.kt @@ -73,9 +73,7 @@ class CommentsAdapter( val comment = comments[position] holder.binding.apply { commentAuthor.text = comment.author - if (comment.channelOwner) { - commentAuthor.setBackgroundResource(R.drawable.comment_channel_owner_bg) - } + commentAuthor.setBackgroundResource(if (comment.channelOwner) R.drawable.comment_channel_owner_bg else 0) commentInfos.text = TextUtils.SEPARATOR + comment.commentedTime commentText.movementMethod = LinkMovementMethodCompat.getInstance() From 20e30b5bb050c95cbe12fc281598159a8114cd80 Mon Sep 17 00:00:00 2001 From: FineFindus Date: Wed, 15 Nov 2023 19:04:04 +0100 Subject: [PATCH 2/2] style: run ktlint --- .../com/github/libretube/db/DatabaseHelper.kt | 5 ++++- .../libretube/ui/adapters/CommentsAdapter.kt | 4 +++- .../libretube/ui/fragments/PlayerFragment.kt | 1 - .../com/github/libretube/util/PlayingQueue.kt | 15 ++++++++------- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/github/libretube/db/DatabaseHelper.kt b/app/src/main/java/com/github/libretube/db/DatabaseHelper.kt index 1907b712b..7897a00a4 100644 --- a/app/src/main/java/com/github/libretube/db/DatabaseHelper.kt +++ b/app/src/main/java/com/github/libretube/db/DatabaseHelper.kt @@ -77,7 +77,10 @@ object DatabaseHelper { } } - suspend fun filterByWatchStatus(streams: List, unfinished: Boolean = true): List { + suspend fun filterByWatchStatus( + streams: List, + unfinished: Boolean = true + ): List { return streams.filter { withContext(Dispatchers.IO) { val historyItem = Database.watchPositionDao() diff --git a/app/src/main/java/com/github/libretube/ui/adapters/CommentsAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/CommentsAdapter.kt index 66543465a..38e662c41 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/CommentsAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/CommentsAdapter.kt @@ -73,7 +73,9 @@ class CommentsAdapter( val comment = comments[position] holder.binding.apply { commentAuthor.text = comment.author - commentAuthor.setBackgroundResource(if (comment.channelOwner) R.drawable.comment_channel_owner_bg else 0) + commentAuthor.setBackgroundResource( + if (comment.channelOwner) R.drawable.comment_channel_owner_bg else 0 + ) commentInfos.text = TextUtils.SEPARATOR + comment.commentedTime commentText.movementMethod = LinkMovementMethodCompat.getInstance() diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt index 05ec6377a..7d44ecacc 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt @@ -37,7 +37,6 @@ import androidx.fragment.app.commit import androidx.lifecycle.Lifecycle import androidx.lifecycle.lifecycleScope import androidx.media3.common.C -import androidx.media3.common.C.WakeMode import androidx.media3.common.MediaItem import androidx.media3.common.MediaItem.SubtitleConfiguration import androidx.media3.common.MimeTypes diff --git a/app/src/main/java/com/github/libretube/util/PlayingQueue.kt b/app/src/main/java/com/github/libretube/util/PlayingQueue.kt index a5773344f..9ba41587a 100644 --- a/app/src/main/java/com/github/libretube/util/PlayingQueue.kt +++ b/app/src/main/java/com/github/libretube/util/PlayingQueue.kt @@ -145,15 +145,16 @@ object PlayingQueue { } } - private fun fetchMoreFromPlaylist(playlistId: String, nextPage: String?, isMainList: Boolean) = runCatchingIO { - var playlistNextPage = nextPage - while (playlistNextPage != null) { - RetrofitInstance.authApi.getPlaylistNextPage(playlistId, playlistNextPage).run { - addToQueueAsync(relatedStreams, isMainList = isMainList) - playlistNextPage = this.nextpage + private fun fetchMoreFromPlaylist(playlistId: String, nextPage: String?, isMainList: Boolean) = + runCatchingIO { + var playlistNextPage = nextPage + while (playlistNextPage != null) { + RetrofitInstance.authApi.getPlaylistNextPage(playlistId, playlistNextPage).run { + addToQueueAsync(relatedStreams, isMainList = isMainList) + playlistNextPage = this.nextpage + } } } - } fun insertPlaylist(playlistId: String, newCurrentStream: StreamItem?) = runCatchingIO { val playlist = PlaylistsHelper.getPlaylist(playlistId)