Last active
March 12, 2020 15:40
-
-
Save cribetti/ab958d52c2e833476c2f8c66047e920c to your computer and use it in GitHub Desktop.
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
class FragmentFactoryImpl(private val arg: String): FragmentFactory() { | |
override fun instantiate(classLoader: ClassLoader, className: String): Fragment { | |
return when (className) { | |
MyFragment::class.java.name -> MyFragment(arg) | |
MyFragment2::class.java.name -> { | |
MyFragment2().apply { | |
arguments = Bundle().apply { | |
putString("key", arg) | |
} | |
} | |
} | |
else -> super.instantiate(classLoader, className) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment