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