remove findviewbyid

This commit is contained in:
Bnyro 2022-09-20 16:51:38 +02:00
parent 5d4364eb95
commit 076c1523d4
4 changed files with 29 additions and 29 deletions

View File

@ -13,12 +13,9 @@ import android.view.View
import android.view.WindowInsets
import android.view.WindowInsetsController
import android.view.WindowManager
import android.widget.LinearLayout
import android.widget.Toast
import androidx.activity.OnBackPressedCallback
import androidx.appcompat.widget.SearchView
import androidx.constraintlayout.motion.widget.MotionLayout
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.os.bundleOf
import androidx.lifecycle.ViewModelProvider
import androidx.navigation.NavController
@ -394,24 +391,34 @@ class MainActivity : BaseActivity() {
.replace(R.id.container, frag)
.commitNow()
Handler(Looper.getMainLooper()).postDelayed({
val motionLayout = findViewById<MotionLayout>(R.id.playerMotionLayout)
motionLayout.transitionToEnd()
motionLayout.transitionToStart()
supportFragmentManager.fragments.forEach { fragment ->
(fragment as? PlayerFragment)
?.binding?.playerMotionLayout?.apply {
transitionToEnd()
transitionToStart()
}
}
}, 100)
}
private fun minimizePlayer() {
binding.mainMotionLayout.transitionToEnd()
findViewById<ConstraintLayout>(R.id.main_container).isClickable = false
val motionLayout = findViewById<MotionLayout>(R.id.playerMotionLayout)
supportFragmentManager.fragments.forEach { fragment ->
(fragment as? PlayerFragment)?.binding?.apply {
mainContainer.isClickable = false
linLayout.visibility = View.VISIBLE
}
}
supportFragmentManager.fragments.forEach { fragment ->
(fragment as? PlayerFragment)?.binding?.playerMotionLayout?.apply {
// set the animation duration
motionLayout.setTransitionDuration(250)
motionLayout.transitionToEnd()
with(motionLayout) {
setTransitionDuration(250)
transitionToEnd()
getConstraintSet(R.id.start).constrainHeight(R.id.player, 0)
enableTransition(R.id.yt_transition, true)
}
findViewById<LinearLayout>(R.id.linLayout).visibility = View.VISIBLE
}
val playerViewModel = ViewModelProvider(this)[PlayerViewModel::class.java]
playerViewModel.isFullscreen.value = false
requestedOrientation = if (autoRotationEnabled) {

View File

@ -107,7 +107,7 @@ import kotlin.math.abs
class PlayerFragment : BaseFragment() {
private lateinit var binding: FragmentPlayerBinding
lateinit var binding: FragmentPlayerBinding
private lateinit var playerBinding: ExoStyledPlayerControlViewBinding
private lateinit var doubleTapOverlayBinding: DoubleTapOverlayBinding
private val viewModel: PlayerViewModel by activityViewModels()

View File

@ -3,7 +3,6 @@ package com.github.libretube.util
import android.content.Context
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.constraintlayout.motion.widget.MotionLayout
import androidx.core.os.bundleOf
import com.github.libretube.R
import com.github.libretube.activities.MainActivity
@ -21,14 +20,14 @@ object NavigationHelper {
val bundle = bundleOf(IntentData.channelId to channelId)
activity.navController.navigate(R.id.channelFragment, bundle)
try {
val mainMotionLayout =
activity.findViewById<MotionLayout>(R.id.mainMotionLayout)
if (mainMotionLayout.progress == 0.toFloat()) {
mainMotionLayout.transitionToEnd()
activity.findViewById<MotionLayout>(R.id.playerMotionLayout)
.transitionToEnd()
if (activity.binding.mainMotionLayout.progress == 0.toFloat()) {
activity.binding.mainMotionLayout.transitionToEnd()
activity.supportFragmentManager.fragments.forEach {
(it as PlayerFragment?)?.binding?.playerMotionLayout?.transitionToEnd()
}
}
} catch (e: Exception) {
e.printStackTrace()
}
}
}

View File

@ -10,12 +10,6 @@ import android.view.View
import androidx.constraintlayout.motion.widget.MotionLayout
import com.github.libretube.R
/**
*
* Created by Arman Chatikyan on 05 Sep 2018
*
*/
class SingleViewTouchableMotionLayout(context: Context, attributeSet: AttributeSet? = null) :
MotionLayout(context, attributeSet) {