Skip to content

Instantly share code, notes, and snippets.

View skydoves's full-sized avatar
💡
Practice is the only shortcut

Jaewoong Eum skydoves

💡
Practice is the only shortcut
View GitHub Profile
apply plugin: 'kotlin-android'
kapt {
correctErrorTypes = true
}
@InjectPreference
public PreferenceComponent_UserProfileComponent component;
@InjectPreference
public Preference_UserProfile userProfile;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
PreferenceComponent_UserProfileComponent.getInstance().inject(this);
}
/**
* Component integrates entities.
*/
@PreferenceComponent(entities = {Profile.class, Device.class})
public interface UserProfileComponent {
/**
* declare dependency injection targets.
*/
void inject(MainActivity __);
void inject(LoginActivity __);
Preference_UserProfile userProfile = PreferenceComponent_UserProfileComponent.getInstance().UserProfile();
Preference_UserDevice userDevice = PreferenceComponent_UserProfileComponent.getInstance().UserDevice();
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
PreferenceComponent_UserProfileComponent.init(this);
}
}
@PreferenceComponent(entities = {Profile.class, Device.class})
public interface UserProfileComponent {
}
@PreferenceFunction(keyname = "uuid")
public String putUuidFunction(String uuid) {
return SecurityUtils.encrypt(uuid);
}
@PreferenceFunction(keyname = "uuid")
public String getUuidFunction(String uuid) {
return SecurityUtils.decrypt(uuid);
}
component.UserProfile().putVisits(component.UserProfile().getVisits());
@PreferenceFunction(keyname = "visits")
public int putVisitCountFunction(int count) {
return ++count;
}