This file contains hidden or 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 Car(private var engine : CarEngine) | |
| class CarEngine |
This file contains hidden or 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 MyModalBottomSheet : BottomSheetDialogFragment() { | |
| /** | |
| * ํ์ฌ BottomSheet(Fragment)์ Theme๋ฅผ ์ป์ด์ค๋ ๋ฉ์๋๋ฅผ ์ค๋ฒ๋ผ์ด๋ฉ ํด์ ์ฐ๋ฆฌ๊ฐ ์ปค์คํ ํ๊ฒ ์ ์ํ | |
| * | |
| * RoundBottomSheetDialog ๋ผ๋ Theme.Design.Light.BottomSheetDialog ์คํ์ผ์ ์์ํ ์คํ์ผ์ ๋ฐํํ๊ฒ ํด์ค๋ค. | |
| */ | |
| override fun getTheme(): Int = R.style.RoundBottomSheetDialog | |
| /** |
This file contains hidden or 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 fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| setContentView(R.layout.activity_main) | |
| savedInstanceState ?: supportFragmentManager.beginTransaction() | |
| .add(R.id.frameLayoutContainer,MainFragment.newInstance("frameFragment"),null).commit() | |
| } |
This file contains hidden or 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 MainFragment : DaggerFragment() { | |
| /** | |
| * Custom Dependency in Fragment | |
| */ | |
| @Inject | |
| lateinit var myDependency : IDependency | |
| /** | |
| * Custom Dynamic Argument |
This file contains hidden or 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
| @RunWith(AndroidJUnit4::class) | |
| class MainFragmentTest { | |
| @Before | |
| fun setup() { | |
| } | |
| @Test | |
| fun testWithDaggerFragmentFieldInjection() { |
This file contains hidden or 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
| @Component( | |
| modules = [ | |
| AndroidSupportInjectionModule::class, | |
| FragmentContributorModule::class, | |
| DependencyModule::class | |
| ] | |
| ) | |
| @AppScope | |
| interface TestAppComponent { |
This file contains hidden or 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
| @Component( | |
| modules = [ | |
| AndroidSupportInjectionModule::class, | |
| FragmentContributorModule::class, | |
| DependencyModule::class | |
| ] | |
| ) | |
| @AppScope | |
| interface TestAppComponent { |
This file contains hidden or 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 MainFragment @Inject constructor(private val myDependency: Dependency) : Fragment() { | |
| override fun onCreateView( | |
| inflater: LayoutInflater, | |
| container: ViewGroup?, | |
| savedInstanceState: Bundle? | |
| ): View = inflater.inflate(R.layout.fragment_main, container, false) | |
| override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
| dep_tv.text = myDependency.sayMyName() |
This file contains hidden or 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 MyFragmentFactory @Inject constructor(private val myDependency: Dependency) : FragmentFactory() { | |
| override fun instantiate(classLoader: ClassLoader, className: String): Fragment { | |
| return when(loadFragmentClass(classLoader,className)) { | |
| MainFragment::class.java -> MainFragment(myDependency) | |
| else -> super.instantiate(classLoader, className) | |
| } | |
| } | |
| } |
This file contains hidden or 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
| @Beta | |
| public abstract class DaggerAppCompatActivity extends AppCompatActivity | |
| implements HasAndroidInjector { | |
| @Inject DispatchingAndroidInjector<Object> androidInjector; | |
| @Override | |
| protected void onCreate(@Nullable Bundle savedInstanceState) { | |
| AndroidInjection.inject(this); | |
| super.onCreate(savedInstanceState); |
OlderNewer