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
@PreferenceComponent(entities = {Profile.class, Device.class}) | |
public interface UserProfileComponent { | |
} |
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 MyApplication extends Application { | |
@Override | |
public void onCreate() { | |
super.onCreate(); | |
PreferenceComponent_UserProfileComponent.init(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
Preference_UserProfile userProfile = PreferenceComponent_UserProfileComponent.getInstance().UserProfile(); | |
Preference_UserDevice userDevice = PreferenceComponent_UserProfileComponent.getInstance().UserDevice(); |
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
/** | |
* Component integrates entities. | |
*/ | |
@PreferenceComponent(entities = {Profile.class, Device.class}) | |
public interface UserProfileComponent { | |
/** | |
* declare dependency injection targets. | |
*/ | |
void inject(MainActivity __); | |
void inject(LoginActivity __); |
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
@Override | |
protected void onCreate(@Nullable Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
PreferenceComponent_UserProfileComponent.getInstance().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
@InjectPreference | |
public PreferenceComponent_UserProfileComponent component; | |
@InjectPreference | |
public Preference_UserProfile userProfile; |
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
apply plugin: 'kotlin-android' | |
kapt { | |
correctErrorTypes = true | |
} |
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
@PreferenceComponent(entities = arrayOf(Profile::class, Device::class)) | |
interface UserProfileComponent { | |
/** | |
* declare dependency injection targets. | |
*/ | |
fun inject(target: MainActivity) | |
fun inject(target: LoginActivity) | |
} |
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
@InjectPreference | |
lateinit var component: PreferenceComponent_UserProfileComponent | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
PreferenceComponent_UserProfileComponent.getInstance().inject(this) // inject dependency injection to MainActivity. |
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
@Singleton | |
public class AppViewModelFactory implements ViewModelProvider.Factory { | |
private final Map<Class<? extends ViewModel>, Provider<ViewModel>> creators; | |
@Inject | |
public AppViewModelFactory(Map<Class<? extends ViewModel>, Provider<ViewModel>> creators) { | |
this.creators = creators; | |
} | |
@SuppressWarnings("unchecked") |