Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Singleton
- public class AppPreferenceHelper implements PreferenceHelper {
- static final String PREFS_APP_STATE = "prefsAppState";
- static final String APP_STATE_LOGIN = "logIn";
- String PREF_NAME ="appPreference" ;
- private SharedPreferences sharedPreferences;
- @Inject
- AppPreferenceHelper(@ApplicationContext Context context) {
- this.sharedPreferences = context.getSharedPreferences(PreferenceConstant.PREF_NAME,Context.MODE_PRIVATE);
- }
- @Override
- public void setAppState(String state) {
- sharedPreferences.edit().putString(PREFS_APP_STATE,state);
- }
- @Override
- public String getAppState() {
- return sharedPreferences.getString(PREFS_APP_STATE,APP_STATE_LOGIN);
- }
- }
- @PerActivity
- @Component(dependencies = ApplicationComponent.class, modules = ActivityModule.class)
- public interface ActivityComponent {
- void inject(SplashActivity mainActivity);
- void inject(LogInActivity logInActivity);
- }
- @Module
- public class ApplicationModule {
- private final Application mApplication;
- public ApplicationModule(Application application) {
- mApplication = application;
- }
- @Provides
- @ApplicationContext
- Context provideContext() {
- return mApplication;
- }
- @Provides
- Application provideApplication() {
- return mApplication;
- }
- @Provides
- @Singleton
- AppPreferenceHelper providePreferencesHelper(AppPreferenceHelper appPreferencesHelper) {
- return appPreferencesHelper;
- }
- }
- @Module
- public class ActivityModule {
- private Activity mActivity;
- public ActivityModule(Activity activity) {
- mActivity = activity;
- }
- @Provides
- @ActivityContext
- Context provideContext() {
- return mActivity;
- }
- @Provides
- Activity provideActivity`enter code here`() {
- return mActivity;
- }`enter code here`
- @Provides
- @PerActivity
- SpashMvpPresenter<SplashView> provideSplashPresenter(
- SplashPresenter<SplashView> presenter) {
- return presenter;
- }
- }
Add Comment
Please, Sign In to add comment