Merge pull request #2554 from Bnyro/master

Fix that the last few comments can't be seen
This commit is contained in:
Bnyro 2023-01-01 18:18:16 +01:00 committed by GitHub
commit edbd40bb26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 9 deletions

View File

@ -42,5 +42,5 @@ fun View?.setWatchProgressLength(videoId: String, duration: Long): Boolean {
}
})
return (progress ?: 0f) / duration.toFloat() > 0.9
return progress / duration.toFloat() > 0.9
}

View File

@ -107,15 +107,15 @@ import com.google.android.exoplayer2.ui.StyledPlayerView
import com.google.android.exoplayer2.upstream.DefaultDataSource
import com.google.android.exoplayer2.util.MimeTypes
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import java.io.IOException
import java.util.*
import java.util.concurrent.Executors
import kotlin.math.abs
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import org.chromium.net.CronetEngine
import retrofit2.HttpException
import java.io.IOException
import java.util.*
import java.util.concurrent.Executors
import kotlin.math.abs
class PlayerFragment : BaseFragment(), OnlinePlayerOptions {

View File

@ -4,10 +4,12 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.ViewTreeObserver
import androidx.fragment.app.activityViewModels
import androidx.recyclerview.widget.LinearLayoutManager
import com.github.libretube.R
import com.github.libretube.databinding.CommentsSheetBinding
import com.github.libretube.extensions.toPixel
import com.github.libretube.ui.adapters.CommentsAdapter
import com.github.libretube.ui.models.CommentsViewModel
@ -24,14 +26,22 @@ class CommentsSheet : ExpandedBottomSheet() {
savedInstanceState: Bundle?
): View {
binding = CommentsSheetBinding.inflate(layoutInflater)
// set a fixed maximum height
binding.root.maxHeight = viewModel.maxHeight
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.dragHandle.viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener {
override fun onGlobalLayout() {
binding.dragHandle.viewTreeObserver.removeOnGlobalLayoutListener(this)
// limit the recyclerview height to not cover the video
binding.commentsRV.layoutParams = binding.commentsRV.layoutParams.apply {
height = viewModel.maxHeight - (binding.dragHandle.height + (20).toPixel().toInt())
}
}
})
binding.commentsRV.layoutManager = LinearLayoutManager(requireContext())
binding.commentsRV.setItemViewCacheSize(20)