Skip to content

Commit

Permalink
fix: crash after rotating device in open content (openedx#256)
Browse files Browse the repository at this point in the history
* fix: crash after rotating device in open content

* refactor: removed unused variable
  • Loading branch information
dixidroid authored Mar 14, 2024
1 parent 9df8df2 commit f91927b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class HtmlUnitFragment : Fragment() {
},
onWebPageLoaded = {
isLoading = false
viewModel.setWebPageLoaded(requireContext().assets)
if (isAdded) viewModel.setWebPageLoaded(requireContext().assets)
}
)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ class EncodedVideoUnitViewModel(
private set
var castPlayer: CastPlayer? = null
private set
private var castContext: CastContext? = null

var isCastActive = false

Expand Down Expand Up @@ -80,9 +79,10 @@ class EncodedVideoUnitViewModel(
initPlayer()

val executor = Executors.newSingleThreadExecutor()
castContext = CastContext.getSharedInstance(context, executor).result
castContext?.let {
castPlayer = CastPlayer(it)
CastContext.getSharedInstance(context, executor).addOnCompleteListener {
it.result?.let { castContext ->
castPlayer = CastPlayer(castContext)
}
}
}

Expand Down

0 comments on commit f91927b

Please sign in to comment.