Guest User

Untitled

a guest
Jul 19th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. @Singleton
  2. public class AppPreferenceHelper implements PreferenceHelper {
  3. static final String PREFS_APP_STATE = "prefsAppState";
  4. static final String APP_STATE_LOGIN = "logIn";
  5. String PREF_NAME ="appPreference" ;
  6.  
  7. private SharedPreferences sharedPreferences;
  8.  
  9. @Inject
  10. AppPreferenceHelper(@ApplicationContext Context context) {
  11. this.sharedPreferences = context.getSharedPreferences(PreferenceConstant.PREF_NAME,Context.MODE_PRIVATE);
  12.  
  13. }
  14.  
  15. @Override
  16. public void setAppState(String state) {
  17. sharedPreferences.edit().putString(PREFS_APP_STATE,state);
  18. }
  19.  
  20. @Override
  21. public String getAppState() {
  22. return sharedPreferences.getString(PREFS_APP_STATE,APP_STATE_LOGIN);
  23. }
  24.  
  25. }
  26.  
  27.  
  28. @PerActivity
  29. @Component(dependencies = ApplicationComponent.class, modules = ActivityModule.class)
  30. public interface ActivityComponent {
  31.  
  32.  
  33. void inject(SplashActivity mainActivity);
  34. void inject(LogInActivity logInActivity);
  35. }
  36. @Module
  37. public class ApplicationModule {
  38.  
  39. private final Application mApplication;
  40.  
  41. public ApplicationModule(Application application) {
  42. mApplication = application;
  43. }
  44.  
  45. @Provides
  46. @ApplicationContext
  47. Context provideContext() {
  48. return mApplication;
  49. }
  50.  
  51. @Provides
  52. Application provideApplication() {
  53. return mApplication;
  54. }
  55.  
  56.  
  57. @Provides
  58. @Singleton
  59. AppPreferenceHelper providePreferencesHelper(AppPreferenceHelper appPreferencesHelper) {
  60. return appPreferencesHelper;
  61. }
  62.  
  63. }
  64. @Module
  65. public class ActivityModule {
  66. private Activity mActivity;
  67.  
  68. public ActivityModule(Activity activity) {
  69. mActivity = activity;
  70. }
  71.  
  72. @Provides
  73. @ActivityContext
  74. Context provideContext() {
  75. return mActivity;
  76. }
  77.  
  78. @Provides
  79. Activity provideActivity`enter code here`() {
  80. return mActivity;
  81. }`enter code here`
  82.  
  83. @Provides
  84. @PerActivity
  85. SpashMvpPresenter<SplashView> provideSplashPresenter(
  86. SplashPresenter<SplashView> presenter) {
  87. return presenter;
  88. }
  89.  
  90. }
Add Comment
Please, Sign In to add comment