I have Navigation Drawer
in my application with several Fragments
and few new Activity
also apart from main application flow.
Fragment
, Network is required and in case of any network error, I used to show Dialog
. User needs to click on "OK" button and again go back to navigation drawer to retry.As inner Fragments
and handling call back can be cumbersome, how to handle this situation efficiently?
For individual Activities this can be achieved easily, but worried about the Navigation Drawer and inner Fragments.
Any suggestions?
Make this error layout hidden in this fragment. When there is any network error then change its visibility to VISIBLE. and in this hidden layout add a button to recall same method to check network connection etc.
Let say you have fragment xml like -
fragment -
Relative Layout consisting -
1. -All layouts (VISIBLE) &
2. -Hidden network error layout with a button (GONE)
When there is network error then change 1. 's visibility to - GONE and 2.'s visibility to VISIBLE
and on retry button call -
checkNetworkConnectionCall();
I hope this will solve you problem.