Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use TransitionAdapter. #3509

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.constraintlayout.motion.widget.MotionLayout
import androidx.constraintlayout.motion.widget.TransitionAdapter
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.fragment.app.commit
Expand Down Expand Up @@ -192,14 +193,7 @@ class AudioPlayerFragment : Fragment(), AudioPlayerOptions {
mainActivity.binding.container.visibility = View.VISIBLE
val mainMotionLayout = mainActivity.binding.mainMotionLayout

binding.playerMotionLayout.addTransitionListener(object : MotionLayout.TransitionListener {
override fun onTransitionStarted(
motionLayout: MotionLayout?,
startId: Int,
endId: Int
) {
}

binding.playerMotionLayout.addTransitionListener(object : TransitionAdapter() {
override fun onTransitionChange(
motionLayout: MotionLayout?,
startId: Int,
Expand All @@ -220,14 +214,6 @@ class AudioPlayerFragment : Fragment(), AudioPlayerOptions {
mainMotionLayout.progress = 0F
}
}

override fun onTransitionTrigger(
MotionLayout: MotionLayout?,
triggerId: Int,
positive: Boolean,
progress: Float
) {
}
})

binding.playerMotionLayout.progress = 1.toFloat()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import android.view.ViewGroup
import android.widget.TextView
import android.widget.Toast
import androidx.constraintlayout.motion.widget.MotionLayout
import androidx.constraintlayout.motion.widget.TransitionAdapter
import androidx.core.content.getSystemService
import androidx.core.net.toUri
import androidx.core.os.bundleOf
Expand Down Expand Up @@ -90,7 +91,6 @@ import com.github.libretube.ui.models.PlayerViewModel
import com.github.libretube.ui.sheets.BaseBottomSheet
import com.github.libretube.ui.sheets.CommentsSheet
import com.github.libretube.ui.sheets.PlayingQueueSheet
import com.github.libretube.util.DataSaverMode
import com.github.libretube.util.HtmlParser
import com.github.libretube.util.LinkHandler
import com.github.libretube.util.NowPlayingNotification
Expand Down Expand Up @@ -283,14 +283,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
mainActivity.binding.container.visibility = View.VISIBLE
val mainMotionLayout = mainActivity.binding.mainMotionLayout

binding.playerMotionLayout.addTransitionListener(object : MotionLayout.TransitionListener {
override fun onTransitionStarted(
motionLayout: MotionLayout?,
startId: Int,
endId: Int
) {
}

binding.playerMotionLayout.addTransitionListener(object : TransitionAdapter() {
override fun onTransitionChange(
motionLayout: MotionLayout?,
startId: Int,
Expand Down Expand Up @@ -325,14 +318,6 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
changeOrientationMode()
}
}

override fun onTransitionTrigger(
MotionLayout: MotionLayout?,
triggerId: Int,
positive: Boolean,
progress: Float
) {
}
})

if (PlayerHelper.swipeGestureEnabled) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import android.view.GestureDetector
import android.view.MotionEvent
import android.view.View
import androidx.constraintlayout.motion.widget.MotionLayout
import androidx.constraintlayout.motion.widget.TransitionAdapter
import com.github.libretube.R

class SingleViewTouchableMotionLayout(context: Context, attributeSet: AttributeSet? = null) :
Expand All @@ -22,38 +23,13 @@ class SingleViewTouchableMotionLayout(context: Context, attributeSet: AttributeS
private val swipeUpListener = mutableListOf<() -> Unit>()

init {
addTransitionListener(object : TransitionListener {
override fun onTransitionStarted(
motionLayout: MotionLayout?,
startId: Int,
endId: Int
) {
}

override fun onTransitionChange(p0: MotionLayout?, p1: Int, p2: Int, p3: Float) {
}

override fun onTransitionCompleted(p0: MotionLayout?, p1: Int) {
addTransitionListener(object : TransitionAdapter() {
override fun onTransitionCompleted(motionLayout: MotionLayout?, currentId: Int) {
touchStarted = false
}

override fun onTransitionTrigger(
motionLayout: MotionLayout?,
triggerId: Int,
positive: Boolean,
progress: Float
) {
}
})

super.setTransitionListener(object : TransitionListener {
override fun onTransitionStarted(
motionLayout: MotionLayout?,
startId: Int,
endId: Int
) {
}

super.setTransitionListener(object : TransitionAdapter() {
override fun onTransitionChange(p0: MotionLayout?, p1: Int, p2: Int, p3: Float) {
transitionListenerList.filterNotNull()
.forEach { it.onTransitionChange(p0, p1, p2, p3) }
Expand All @@ -63,14 +39,6 @@ class SingleViewTouchableMotionLayout(context: Context, attributeSet: AttributeS
transitionListenerList.filterNotNull()
.forEach { it.onTransitionCompleted(p0, p1) }
}

override fun onTransitionTrigger(
motionLayout: MotionLayout?,
triggerId: Int,
positive: Boolean,
progress: Float
) {
}
})
}

Expand Down