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
public class EmotionManager { | |
private final PeanutButterJar peanutButterJar; | |
private final Benfica benfica; | |
public EmotionManager() { | |
this.peanutButterJar = new PeanutButterJar(); | |
this.benfica = new Benfica(); | |
} |
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
public class EmotionManager { | |
private final PeanutButterJar peanutButterJar; | |
private final Benfica benfica; | |
public EmotionManager(PeanutButterJar peanutButterJar, Benfica benfica) { | |
this.peanutButterJar = peanutButterJar; | |
this.benfica = benfica; | |
} |
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
PeanutButterJar peanutButterJar = new PeanutButterJar(...); | |
Benfica benfica = new Benfica(...); | |
EmotionManager emotionManager = new EmotionManager(peanutButterJar, benfica); |
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
public class EmotionManager { | |
private final PeanutButterJar peanutButterJar; | |
private final Benfica benfica; | |
@Inject public EmotionManager(PeanutButterJar peanutButterJar, Benfica benfica) { | |
this.peanutButterJar = peanutButterJar; | |
this.benfica = benfica; | |
} |
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
public class PeanutButterJar { | |
@Inject public PeanutButterJar() {} | |
... | |
} | |
public class Benfica { | |
@Inject public Benfica() {} |
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
public class MainActivity extends AppCompatActivity { | |
@Inject EmotionManager emotionManager; | |
@Override protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
getActivityComponent().inject(this); | |
} | |
} |
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
public class EmotionManager { | |
private final PeanutButterJar peanutButterJar; | |
private final Benfica benfica; | |
@Inject public EmotionManager(PeanutButterJar peanutButterJar, Benfica benfica) { | |
this.peanutButterJar = peanutButterJar; | |
this.benfica = benfica; | |
} | |
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
@Module public class ActivityModule { | |
private final Activity activity; | |
public ActivityModule(Activity activity) { | |
this.activity = activity; | |
} | |
@Provides public Context provideActivityContext() { | |
return activity; |
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
@Provides | |
public Context provideApplicationContext() { | |
return application; | |
} | |
@Provides @Named("activity_context") | |
public Context provideActivityContext() { | |
return activity; | |
} |
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
public class ClassA { | |
private final Context context; | |
@Inject public ClassA(Context context) { | |
this.context = context; // Application Context | |
} | |
} | |
public class ClassB { |
OlderNewer