Skip to content

Instantly share code, notes, and snippets.

@alaershov
Last active June 7, 2019 06:25
Show Gist options
  • Save alaershov/08f36d6e8afd40849c73b7d502a48f4f to your computer and use it in GitHub Desktop.
Save alaershov/08f36d6e8afd40849c73b7d502a48f4f to your computer and use it in GitHub Desktop.
Toothpick: UserActivity with Inject
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