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
| // Root | |
| class FooActivity { | |
| val bar: Bar by Inject() | |
| fun onCreate(state) { | |
| KTP.openScope("Scope Name") | |
| .installModule(MyModule()) | |
| .inject(this); | |
| } | |
| } |
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 | |
| protected void onNewIntent(Intent intent) { | |
| super.onNewIntent(intent); | |
| Dart.inject(this, intent.getExtras()); | |
| } |
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
| public class SmoothieMakerTest { | |
| @Rule public EasyMockRule mocks = new EasyMockRule(this); | |
| @TestSubject private SmoothieMaker smoothieMakerUnderTest = new SmoothieMaker(); | |
| @Mock private Blender mockBlender; | |
| @Mock private Freezer mockFreezer; | |
| @After | |
| public void tearDown() throws Exception { | |
| ToothPick.reset(); |
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
| @Inject Lazy<SmoothieMaker> smoothieMaker; | |
| smoothieMaker.get().makeSmoothie(); |
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
| public class SmoothieShopModule extends Module { | |
| public SmoothieShopModule() { | |
| bind(Blender.class).to(JarBlender.class); // Blender -> JarBlender | |
| bind(Freezer.class).to(new Freezer()); // Freezer -> Freezer instance | |
| } | |
| } | |
| class SmoothieShop { | |
| @Inject SmoothieMaker smoothieMaker1; | |
| @Inject SmoothieMaker smoothieMaker2; |
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
| bind(Blender.class).to(JarBlender.class); // Blender -> JarBlender | |
| bind(Freezer.class).to(new Freezer()); // Freezer -> Freezer instance |
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 SmoothieShop { | |
| @Inject SmoothieMaker smoothieMaker1; | |
| @Inject SmoothieMaker smoothieMaker2; | |
| public SmoothieShop() { | |
| Scope scope = Toothpick.openScope("SmoothieShop"); | |
| Toothpick.inject(this, scope); | |
| ... | |
| } | |
| ... |
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 SmoothieMaker { | |
| @Inject Blender blender; | |
| @Inject Freezer freezer; | |
| ... | |
| } |
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
| Intent intent = Henson.with(context) | |
| .gotoDetailActivity() | |
| .itemId(selectedItem.id) | |
| .shouldShowMap(true) | |
| .build(); | |
| startActivity(intent); |
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
| public class DetailActivity extends Activity { | |
| @InjectExtra String itemId; | |
| @Nullable @InjectExtra boolean shouldShowMap; | |
| @Override | |
| public void onCreate(Bundle savedInstanceState) { | |
| super.onCreate(savedInstanceState); | |
| Dart.inject(this); | |
| ... | |
| } |
NewerOlder