-
Notifications
You must be signed in to change notification settings - Fork 95
Description
Hi!
I'm having some problems in NavDrawerMvx.
When I leave application (without closing it), use other applications and some time later return for NavDrawerMvx, the fragment is not rendered on the screen and is displayed only the ActionBar and NavigationDrawer, with properly checked option, the way I left it before leaving the application. In place of the fragment, appears only the gray background of the main layout.
I made some changes that apparently corrected this problem, but I would like to know if it's the best solution.
What I did in HomeView was:
1 - Added this to save the current checked navigation drawer option before the app proccess is killed:
protected override void OnSaveInstanceState(Bundle outState)
{
base.OnSaveInstanceState(outState);
outState.PutInt("menu", _drawerList.CheckedItemPosition);
}
2 - Prevent the app from restart on rotate:
[Activity(Label = "Home", ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize)]
3 - Execute the SelectMenuItemCommand in OnCreate if saveInstaceState is not nullable:
if (savedInstanceState == null)
this.ViewModel.SelectMenuItemCommand.Execute(this.ViewModel.MenuItems[0]);
else
this.ViewModel.SelectMenuItemCommand.Execute(this.ViewModel.MenuItems[savedInstanceState.GetInt("menu")]);
4 - Prevent the Show method to return true if the checked navigation drawer option and current fragment are the same, commenting the this lines:
//if (this.SupportFragmentManager.FindFragmentById(Resource.Id.content_frame) as //BrowseView != null)
//{
//return true;
//}
//if (this.SupportFragmentManager.FindFragmentById(Resource.Id.content_frame) as //FriendsView != null)
//{
//return true;
//}
//if (this.SupportFragmentManager.FindFragmentById(Resource.Id.content_frame) as //ProfileView != null)
//{
//return true;
//}
It's worked for me, although every fragment will be reloaded by checking an option in the menu, even if it is already current. Also, I don't know what is the impact to the application to prevent the restart of the application in the rotation.
Can you please confirm to me if there is other solution?
Thanks for this sample!
Best regards, rrispoli.