Skip to content

Commit

Permalink
Simplify PlayerFragment transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxr1998 committed Sep 23, 2022
1 parent 19cf7c2 commit 264fa60
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import android.content.Intent
import android.content.pm.ActivityInfo
import android.net.Uri
import android.os.Bundle
import androidx.fragment.app.add
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
Expand Down Expand Up @@ -59,13 +58,10 @@ class ActivityEventHandler(
}
}
is ActivityEvent.LaunchNativePlayer -> {
supportFragmentManager.beginTransaction().apply {
val args = Bundle().apply {
putParcelable(Constants.EXTRA_MEDIA_PLAY_OPTIONS, event.playOptions)
}
add<PlayerFragment>(R.id.fragment_container, args = args)
addToBackStack(null)
}.commit()
val args = Bundle().apply {
putParcelable(Constants.EXTRA_MEDIA_PLAY_OPTIONS, event.playOptions)
}
supportFragmentManager.addFragment<PlayerFragment>(args)
}
is ActivityEvent.OpenUrl -> {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import androidx.fragment.app.add
import androidx.fragment.app.replace
import org.jellyfin.mobile.R

inline fun <reified T : Fragment> FragmentManager.addFragment() {
inline fun <reified T : Fragment> FragmentManager.addFragment(args: Bundle? = null) {
beginTransaction().apply {
add<T>(R.id.fragment_container)
add<T>(R.id.fragment_container, args = args)
addToBackStack(null)
}.commit()
}
Expand Down

0 comments on commit 264fa60

Please sign in to comment.