Created
July 20, 2016 00:42
-
-
Save kejunxia/94458e167c2b4217885138700aa56200 to your computer and use it in GitHub Desktop.
How to map navigation routing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
protected Class<? extends MvcFragment> mapFragmentRouting( | |
Class<? extends FragmentController> controllerClass) { | |
String controllerPackage = controllerClass.getPackage().getName(); | |
//Find the classes of fragment under package .view and named in form of xxxScreen | |
//For example | |
//a.b.c.CounterMasterController -> a.b.c.view.CounterMasterScreen | |
String viewPkgName = controllerPackage.substring(0, controllerPackage.lastIndexOf(".")) + ".view"; | |
String fragmentClassName = viewPkgName + "." | |
+ controllerClass.getSimpleName().replace("Controller", "Screen"); | |
try { | |
return (Class<? extends MvcFragment>) Class.forName(fragmentClassName); | |
} catch (ClassNotFoundException e) { | |
String msg = String.format("Fragment class(%s) for controller(%s) can not be found", | |
fragmentClassName, controllerClass.getName()); | |
throw new RuntimeException(msg, e); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment