mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 14:20:30 +05:30
remove findviewbyid
This commit is contained in:
parent
5d4364eb95
commit
076c1523d4
@ -13,12 +13,9 @@ import android.view.View
|
|||||||
import android.view.WindowInsets
|
import android.view.WindowInsets
|
||||||
import android.view.WindowInsetsController
|
import android.view.WindowInsetsController
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import android.widget.LinearLayout
|
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.activity.OnBackPressedCallback
|
import androidx.activity.OnBackPressedCallback
|
||||||
import androidx.appcompat.widget.SearchView
|
import androidx.appcompat.widget.SearchView
|
||||||
import androidx.constraintlayout.motion.widget.MotionLayout
|
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
|
||||||
import androidx.core.os.bundleOf
|
import androidx.core.os.bundleOf
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
import androidx.navigation.NavController
|
import androidx.navigation.NavController
|
||||||
@ -394,24 +391,34 @@ class MainActivity : BaseActivity() {
|
|||||||
.replace(R.id.container, frag)
|
.replace(R.id.container, frag)
|
||||||
.commitNow()
|
.commitNow()
|
||||||
Handler(Looper.getMainLooper()).postDelayed({
|
Handler(Looper.getMainLooper()).postDelayed({
|
||||||
val motionLayout = findViewById<MotionLayout>(R.id.playerMotionLayout)
|
supportFragmentManager.fragments.forEach { fragment ->
|
||||||
motionLayout.transitionToEnd()
|
(fragment as? PlayerFragment)
|
||||||
motionLayout.transitionToStart()
|
?.binding?.playerMotionLayout?.apply {
|
||||||
|
transitionToEnd()
|
||||||
|
transitionToStart()
|
||||||
|
}
|
||||||
|
}
|
||||||
}, 100)
|
}, 100)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun minimizePlayer() {
|
private fun minimizePlayer() {
|
||||||
binding.mainMotionLayout.transitionToEnd()
|
binding.mainMotionLayout.transitionToEnd()
|
||||||
findViewById<ConstraintLayout>(R.id.main_container).isClickable = false
|
supportFragmentManager.fragments.forEach { fragment ->
|
||||||
val motionLayout = findViewById<MotionLayout>(R.id.playerMotionLayout)
|
(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
|
// set the animation duration
|
||||||
motionLayout.setTransitionDuration(250)
|
setTransitionDuration(250)
|
||||||
motionLayout.transitionToEnd()
|
transitionToEnd()
|
||||||
with(motionLayout) {
|
|
||||||
getConstraintSet(R.id.start).constrainHeight(R.id.player, 0)
|
getConstraintSet(R.id.start).constrainHeight(R.id.player, 0)
|
||||||
enableTransition(R.id.yt_transition, true)
|
enableTransition(R.id.yt_transition, true)
|
||||||
}
|
}
|
||||||
findViewById<LinearLayout>(R.id.linLayout).visibility = View.VISIBLE
|
}
|
||||||
|
|
||||||
val playerViewModel = ViewModelProvider(this)[PlayerViewModel::class.java]
|
val playerViewModel = ViewModelProvider(this)[PlayerViewModel::class.java]
|
||||||
playerViewModel.isFullscreen.value = false
|
playerViewModel.isFullscreen.value = false
|
||||||
requestedOrientation = if (autoRotationEnabled) {
|
requestedOrientation = if (autoRotationEnabled) {
|
||||||
|
@ -107,7 +107,7 @@ import kotlin.math.abs
|
|||||||
|
|
||||||
class PlayerFragment : BaseFragment() {
|
class PlayerFragment : BaseFragment() {
|
||||||
|
|
||||||
private lateinit var binding: FragmentPlayerBinding
|
lateinit var binding: FragmentPlayerBinding
|
||||||
private lateinit var playerBinding: ExoStyledPlayerControlViewBinding
|
private lateinit var playerBinding: ExoStyledPlayerControlViewBinding
|
||||||
private lateinit var doubleTapOverlayBinding: DoubleTapOverlayBinding
|
private lateinit var doubleTapOverlayBinding: DoubleTapOverlayBinding
|
||||||
private val viewModel: PlayerViewModel by activityViewModels()
|
private val viewModel: PlayerViewModel by activityViewModels()
|
||||||
|
@ -3,7 +3,6 @@ package com.github.libretube.util
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.constraintlayout.motion.widget.MotionLayout
|
|
||||||
import androidx.core.os.bundleOf
|
import androidx.core.os.bundleOf
|
||||||
import com.github.libretube.R
|
import com.github.libretube.R
|
||||||
import com.github.libretube.activities.MainActivity
|
import com.github.libretube.activities.MainActivity
|
||||||
@ -21,14 +20,14 @@ object NavigationHelper {
|
|||||||
val bundle = bundleOf(IntentData.channelId to channelId)
|
val bundle = bundleOf(IntentData.channelId to channelId)
|
||||||
activity.navController.navigate(R.id.channelFragment, bundle)
|
activity.navController.navigate(R.id.channelFragment, bundle)
|
||||||
try {
|
try {
|
||||||
val mainMotionLayout =
|
if (activity.binding.mainMotionLayout.progress == 0.toFloat()) {
|
||||||
activity.findViewById<MotionLayout>(R.id.mainMotionLayout)
|
activity.binding.mainMotionLayout.transitionToEnd()
|
||||||
if (mainMotionLayout.progress == 0.toFloat()) {
|
activity.supportFragmentManager.fragments.forEach {
|
||||||
mainMotionLayout.transitionToEnd()
|
(it as PlayerFragment?)?.binding?.playerMotionLayout?.transitionToEnd()
|
||||||
activity.findViewById<MotionLayout>(R.id.playerMotionLayout)
|
}
|
||||||
.transitionToEnd()
|
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
e.printStackTrace()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,12 +10,6 @@ import android.view.View
|
|||||||
import androidx.constraintlayout.motion.widget.MotionLayout
|
import androidx.constraintlayout.motion.widget.MotionLayout
|
||||||
import com.github.libretube.R
|
import com.github.libretube.R
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Created by Arman Chatikyan on 05 Sep 2018
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
class SingleViewTouchableMotionLayout(context: Context, attributeSet: AttributeSet? = null) :
|
class SingleViewTouchableMotionLayout(context: Context, attributeSet: AttributeSet? = null) :
|
||||||
MotionLayout(context, attributeSet) {
|
MotionLayout(context, attributeSet) {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user