Skip to content

Commit

Permalink
fixed progress running infinite issue
Browse files Browse the repository at this point in the history
  • Loading branch information
aman-alfresco committed Sep 26, 2023
1 parent 7bac9c8 commit 69e0de5
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class ViewerFragment : Fragment(), MavericksView {
private val viewModel: ViewerViewModel by fragmentViewModelWithArgs { args }
private lateinit var binding: ViewerBinding
private var childFragment: ChildViewerFragment? = null
private var hasLoadingStatus: Boolean = false

private val viewerLoadingListener = object : LoadingListener {
override fun onContentLoaded() {
Expand Down Expand Up @@ -119,7 +120,9 @@ class ViewerFragment : Fragment(), MavericksView {
state.viewerUri,
state.viewerMimeType,
)
show(Status.LoadingPreview)
if (!hasLoadingStatus) {
show(Status.LoadingPreview)
}
} else {
show(Status.NotSupported)
}
Expand Down Expand Up @@ -158,6 +161,7 @@ class ViewerFragment : Fragment(), MavericksView {
}

private fun show(s: Status) {
println("ViewerFragment.show ${s.name}")
binding.apply {
when (s) {
Status.LoadingMetadata -> {
Expand All @@ -179,12 +183,14 @@ class ViewerFragment : Fragment(), MavericksView {
}

Status.PreviewLoaded -> {
hasLoadingStatus = true
info.isVisible = childFragment?.showInfoWhenLoaded() == true
loading.isVisible = false
status.text = ""
}

Status.NotSupported -> {
hasLoadingStatus = true
info.isVisible = true
loading.isVisible = false
status.text = getString(R.string.error_preview_not_available)
Expand Down

0 comments on commit 69e0de5

Please sign in to comment.