mirror of
https://github.com/nextcloud/talk-android
synced 2025-03-12 02:19:44 +00:00
fix to always show polls dialog.
Sometimes the polls dialog seemed to not load the content. This was caused by the showLoadingScreen logic using binding.root.post which overwrote the content depending on if the showResultsScreen or showVoteScreen already set the content. So it was a race conditions that sometimes it worked and sometimes not. Additionally, calculating the height failed in showLoadingScreen, so in the end there was only the headline visible and even not loading spinner. This is now replaced by a fixed height. Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
cbc1eed336
commit
eaa0743027
@ -10,7 +10,6 @@ import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.fragment.app.Fragment
|
||||
import autodagger.AutoInjector
|
||||
import com.nextcloud.android.common.ui.theme.utils.ColorRole
|
||||
@ -27,34 +26,24 @@ class PollLoadingFragment : Fragment() {
|
||||
@Inject
|
||||
lateinit var viewThemeUtils: ViewThemeUtils
|
||||
|
||||
var fragmentHeight = 0
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
NextcloudTalkApplication.sharedApplication!!.componentApplication.inject(this)
|
||||
fragmentHeight = arguments?.getInt(KEY_FRAGMENT_HEIGHT)!!
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||
binding = DialogPollLoadingBinding.inflate(inflater, container, false)
|
||||
binding.root.layoutParams.height = fragmentHeight
|
||||
binding.root.layoutParams.height = HEIGHT
|
||||
viewThemeUtils.platform.colorCircularProgressBar(binding.pollLoadingProgressbar, ColorRole.PRIMARY)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val TAG = PollLoadingFragment::class.java.simpleName
|
||||
private const val KEY_FRAGMENT_HEIGHT = "keyFragmentHeight"
|
||||
private const val HEIGHT = 300
|
||||
|
||||
@JvmStatic
|
||||
fun newInstance(fragmentHeight: Int): PollLoadingFragment {
|
||||
val args = bundleOf(
|
||||
KEY_FRAGMENT_HEIGHT to fragmentHeight
|
||||
)
|
||||
|
||||
val fragment = PollLoadingFragment()
|
||||
fragment.arguments = args
|
||||
return fragment
|
||||
fun newInstance(): PollLoadingFragment {
|
||||
return PollLoadingFragment()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -90,32 +90,30 @@ class PollMainDialogFragment : DialogFragment() {
|
||||
initVotersAmount(state.showVotersAmount, state.poll.numVoters, false)
|
||||
showVoteScreen()
|
||||
}
|
||||
|
||||
is PollMainViewModel.PollResultState -> {
|
||||
initVotersAmount(state.showVotersAmount, state.poll.numVoters, true)
|
||||
showResultsScreen()
|
||||
}
|
||||
|
||||
is PollMainViewModel.LoadingState -> {
|
||||
showLoadingScreen()
|
||||
}
|
||||
|
||||
is PollMainViewModel.DismissDialogState -> {
|
||||
dismiss()
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showLoadingScreen() {
|
||||
binding.root.post {
|
||||
run {
|
||||
val fragmentHeight = binding.messagePollContentFragment.measuredHeight
|
||||
|
||||
val contentFragment = PollLoadingFragment.newInstance(fragmentHeight)
|
||||
val transaction = childFragmentManager.beginTransaction()
|
||||
transaction.replace(binding.messagePollContentFragment.id, contentFragment)
|
||||
transaction.commit()
|
||||
}
|
||||
}
|
||||
val contentFragment = PollLoadingFragment.newInstance()
|
||||
val transaction = childFragmentManager.beginTransaction()
|
||||
transaction.replace(binding.messagePollContentFragment.id, contentFragment)
|
||||
transaction.commit()
|
||||
}
|
||||
|
||||
private fun showVoteScreen() {
|
||||
|
Loading…
Reference in New Issue
Block a user