Last active
June 7, 2019 06:25
-
-
Save alaershov/08f36d6e8afd40849c73b7d502a48f4f to your computer and use it in GitHub Desktop.
Toothpick: UserActivity with Inject
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 final class UserActivity extends AppCompatActivity { | |
// поле больше не приватное | |
@Inject | |
UserRepository userRepository; | |
@Override | |
protected void onCreate(@Nullable Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
// после вызова этого метода UserRepository будет инициализирован | |
Toothpick.inject(this, scope); | |
// теперь можно использовать UserRepository! | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment