Skip to content
Advertisement

Alertdialog running ongoing dosen’t dismiss or cancel

According this answer , I wanna to show dilaog until the next 10 posts is loaded so I created the static alertDialog method to use it in different places in my app, but the problem is the dialog doesn’t cancel or dismiss

setProgressDialog in Utils class

JavaScript

then I used it in HomeFragment on click load more button

JavaScript

PS: I tried also to create dialog AlertDialog dialog = Utils.setProgressDialog(requireContext()); instead to call the method directly then dialod.show(), and after the getPosts cancel or dismiss it but it dosen’t appear

Advertisement

Answer

I fixed it by adding a flag boolean in the viewmodel to detect loading state

JavaScript

and use it in getPosts() like this

JavaScript

and finally in the fragment on button click

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement