android - Reloading the Main Activity : Navigation Stops working -


in main activity want reload activity want app reload since user logging in. dont know if thats idea when validating user credentials , calling these lines of code in main activity.

var viewgroup = (viewgroup)     ((viewgroup)findviewbyid(android.resource.id.content)).getchildat(0); viewgroup.removeallviews(); finish(); startactivity(intent); 

what happens screen flashes , activity loaded again scratch(that doesnt not mature). problem app works fine navigation stops working when call

showviewmodel(someviewmodel);

i know doing wrong, or may not following best practise here. intent reload application setting flags , load users profile making user feel if user logged in.

version: 4.1.4

platform: xamarin android

your navigation breaks because you're trying handle navigation on own instead of letting mvvmcross you.

as can see in default android presenter, method receives intent not public. when call showviewmodel, instance of imvxandroidviewmodelrequesttranslator (more this implementation if didn't override it) called , creates intent you.

regarding problem, i'd question whether need recreate entire view. if don't, can create subclass of mvxpresentationhint , whathever using changepresentation method. clean , cross platform solution (since code triggers presentation change on shared code area)

if need recreate entire view, should use showviewmodel viewmodel when needed instead of calling startactivity on own. i'd create helper method showviewmodelandremoveselffrombackstack in order show viewmodel again , prevent user returning old one. such behaviour can achieved using parameter/presentation values , treating them accordingly in presenter


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -