22
33import android .app .Activity ;
44import android .content .Intent ;
5- import android .content .SharedPreferences ;
65import android .os .Bundle ;
7- import android .preference .PreferenceManager ;
86import android .support .annotation .Nullable ;
97
108import com .crashlytics .android .Crashlytics ;
1513import io .gloop .Gloop ;
1614import io .gloop .drawed .utils .NameUtil ;
1715import io .gloop .drawed .utils .ScreenUtil ;
16+ import io .gloop .drawed .utils .SharedPreferencesStore ;
1817
1918public class SplashActivity extends Activity {
2019
@@ -25,6 +24,8 @@ public void onCreate(Bundle icicle) {
2524 super .onCreate (icicle );
2625 Fabric .with (this , new Crashlytics ());
2726 setContentView (R .layout .activity_splashscreen );
27+
28+ SharedPreferencesStore .setContext (getBaseContext ());
2829 }
2930
3031
@@ -35,7 +36,7 @@ protected void onPostCreate(@Nullable Bundle savedInstanceState) {
3536 // setup screen util at start
3637 ScreenUtil .setActivity (this );
3738
38- if (isFirstStart ())
39+ if (SharedPreferencesStore . isFirstStart ())
3940 showIntroOnFirstRun ();
4041 else {
4142 new Thread (new Runnable () {
@@ -65,27 +66,19 @@ public void run() {
6566 }
6667 }
6768
68- private boolean isFirstStart () {
69- return PreferenceManager .getDefaultSharedPreferences (getBaseContext ()).getBoolean (SHARED_PREFERENCES_FIRST_START , true );
70- }
71-
7269 private void showIntroOnFirstRun () {
7370 // Declare a new thread to do a preference check
7471 new Thread (new Runnable () {
7572 @ Override
7673 public void run () {
77- SharedPreferences getPrefs = PreferenceManager .getDefaultSharedPreferences (getBaseContext ());
78-
7974 // If the activity has never started before...
80- if (isFirstStart ()) {
75+ if (SharedPreferencesStore . isFirstStart ()) {
8176
8277 // Launch app intro
8378 Intent i = new Intent (SplashActivity .this , IntroActivity .class );
8479 startActivity (i );
8580
86- SharedPreferences .Editor e = getPrefs .edit ();
87- e .putBoolean (SHARED_PREFERENCES_FIRST_START , false );
88- e .apply ();
81+ SharedPreferencesStore .setFirstRun (false );
8982 }
9083 }
9184 }).start ();
0 commit comments