mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 22:30:30 +05:30
Use visibility extensions.
This commit is contained in:
parent
25fd905c54
commit
cab21d0abe
@ -147,8 +147,7 @@ class LibraryFragment : Fragment() {
|
||||
playlistsAdapter.registerAdapterDataObserver(object :
|
||||
RecyclerView.AdapterDataObserver() {
|
||||
override fun onItemRangeRemoved(positionStart: Int, itemCount: Int) {
|
||||
binding.nothingHere.visibility =
|
||||
if (playlistsAdapter.itemCount == 0) View.VISIBLE else View.GONE
|
||||
binding.nothingHere.isVisible = playlistsAdapter.itemCount == 0
|
||||
super.onItemRangeRemoved(positionStart, itemCount)
|
||||
}
|
||||
})
|
||||
|
@ -31,6 +31,7 @@ import androidx.core.net.toUri
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.core.os.postDelayed
|
||||
import androidx.core.text.parseAsHtml
|
||||
import androidx.core.view.isInvisible
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.activityViewModels
|
||||
@ -389,8 +390,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
||||
|
||||
// FullScreen button trigger
|
||||
// hide fullscreen button if auto rotation enabled
|
||||
playerBinding.fullscreen.visibility =
|
||||
if (PlayerHelper.autoRotationEnabled) View.INVISIBLE else View.VISIBLE
|
||||
playerBinding.fullscreen.isInvisible = PlayerHelper.autoRotationEnabled
|
||||
playerBinding.fullscreen.setOnClickListener {
|
||||
// hide player controller
|
||||
binding.player.hideController()
|
||||
@ -1129,20 +1129,9 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
||||
if (!PlayerHelper.skipButtonsEnabled) return
|
||||
|
||||
// toggle the visibility of next and prev buttons based on queue and whether the player view is locked
|
||||
playerBinding.skipPrev.visibility = if (
|
||||
PlayingQueue.hasPrev() && !binding.player.isPlayerLocked
|
||||
) {
|
||||
View.VISIBLE
|
||||
} else {
|
||||
View.INVISIBLE
|
||||
}
|
||||
playerBinding.skipNext.visibility = if (
|
||||
PlayingQueue.hasNext() && !binding.player.isPlayerLocked
|
||||
) {
|
||||
View.VISIBLE
|
||||
} else {
|
||||
View.INVISIBLE
|
||||
}
|
||||
val isPlayerLocked = binding.player.isPlayerLocked
|
||||
playerBinding.skipPrev.isInvisible = !PlayingQueue.hasPrev() || isPlayerLocked
|
||||
playerBinding.skipNext.isInvisible = !PlayingQueue.hasNext() || isPlayerLocked
|
||||
|
||||
handler.postDelayed(this::syncQueueButtons, 100)
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Toast
|
||||
import androidx.core.view.isGone
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.activityViewModels
|
||||
@ -196,10 +197,10 @@ class SubscriptionsFragment : Fragment() {
|
||||
}
|
||||
|
||||
binding.subChannelsContainer.visibility = View.GONE
|
||||
binding.subFeedContainer.visibility =
|
||||
if (viewModel.videoFeed.value!!.isEmpty()) View.GONE else View.VISIBLE
|
||||
binding.emptyFeed.visibility =
|
||||
if (viewModel.videoFeed.value!!.isEmpty()) View.VISIBLE else View.GONE
|
||||
|
||||
val notLoaded = viewModel.videoFeed.value.isNullOrEmpty()
|
||||
binding.subFeedContainer.isGone = notLoaded
|
||||
binding.emptyFeed.isVisible = notLoaded
|
||||
|
||||
binding.subProgress.visibility = View.GONE
|
||||
subscriptionsAdapter = VideosAdapter(
|
||||
@ -257,10 +258,10 @@ class SubscriptionsFragment : Fragment() {
|
||||
}
|
||||
|
||||
binding.subFeedContainer.visibility = View.GONE
|
||||
binding.subChannelsContainer.visibility =
|
||||
if (viewModel.subscriptions.value!!.isEmpty()) View.GONE else View.VISIBLE
|
||||
binding.emptyFeed.visibility =
|
||||
if (viewModel.subscriptions.value!!.isEmpty()) View.VISIBLE else View.GONE
|
||||
|
||||
val notLoaded = viewModel.subscriptions.value.isNullOrEmpty()
|
||||
binding.subChannelsContainer.isGone = notLoaded
|
||||
binding.emptyFeed.isVisible = notLoaded
|
||||
}
|
||||
|
||||
private fun isShowingFeed(): Boolean {
|
||||
|
@ -17,6 +17,7 @@ import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.os.postDelayed
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.core.view.marginStart
|
||||
import androidx.core.view.updateLayoutParams
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
@ -365,18 +366,16 @@ internal class CustomExoPlayerView(
|
||||
// lock the player
|
||||
private fun lockPlayer(isLocked: Boolean) {
|
||||
// isLocked is the current (old) state of the player lock
|
||||
val visibility = if (isLocked) View.VISIBLE else View.GONE
|
||||
|
||||
binding.exoTopBarRight.visibility = visibility
|
||||
binding.exoCenterControls.visibility = visibility
|
||||
binding.bottomBar.visibility = visibility
|
||||
binding.closeImageButton.visibility = visibility
|
||||
binding.exoTitle.visibility = visibility
|
||||
binding.playPauseBTN.visibility = visibility
|
||||
binding.exoTopBarRight.isVisible = isLocked
|
||||
binding.exoCenterControls.isVisible = isLocked
|
||||
binding.bottomBar.isVisible = isLocked
|
||||
binding.closeImageButton.isVisible = isLocked
|
||||
binding.exoTitle.isVisible = isLocked
|
||||
binding.playPauseBTN.isVisible = isLocked
|
||||
|
||||
if (!PlayerHelper.doubleTapToSeek) {
|
||||
binding.rewindBTN.visibility = visibility
|
||||
binding.forwardBTN.visibility = visibility
|
||||
binding.rewindBTN.isVisible = isLocked
|
||||
binding.forwardBTN.isVisible = isLocked
|
||||
}
|
||||
|
||||
// hide the dimming background overlay if locked
|
||||
|
Loading…
Reference in New Issue
Block a user