@@ -77,6 +77,18 @@ private View getView() {
77
77
}
78
78
}
79
79
80
+ private int getSplashId () {
81
+ int drawableId = 0 ;
82
+ String splashResource = preferences .getString ("SplashScreen" , "screen" );
83
+ if (splashResource != null ) {
84
+ drawableId = cordova .getActivity ().getResources ().getIdentifier (splashResource , "drawable" , cordova .getActivity ().getClass ().getPackage ().getName ());
85
+ if (drawableId == 0 ) {
86
+ drawableId = cordova .getActivity ().getResources ().getIdentifier (splashResource , "drawable" , cordova .getActivity ().getPackageName ());
87
+ }
88
+ }
89
+ return drawableId ;
90
+ }
91
+
80
92
@ Override
81
93
protected void pluginInitialize () {
82
94
if (HAS_BUILT_IN_SPLASH_SCREEN ) {
@@ -90,17 +102,7 @@ public void run() {
90
102
getView ().setVisibility (View .INVISIBLE );
91
103
}
92
104
});
93
- int drawableId = preferences .getInteger ("SplashDrawableId" , 0 );
94
- if (drawableId == 0 ) {
95
- String splashResource = preferences .getString ("SplashScreen" , "screen" );
96
- if (splashResource != null ) {
97
- drawableId = cordova .getActivity ().getResources ().getIdentifier (splashResource , "drawable" , cordova .getActivity ().getClass ().getPackage ().getName ());
98
- if (drawableId == 0 ) {
99
- drawableId = cordova .getActivity ().getResources ().getIdentifier (splashResource , "drawable" , cordova .getActivity ().getPackageName ());
100
- }
101
- //preferences.set("SplashDrawableId", drawableId);
102
- }
103
- }
105
+ int drawableId = getSplashId ();
104
106
105
107
// Save initial orientation.
106
108
orientation = cordova .getActivity ().getResources ().getConfiguration ().orientation ;
@@ -205,7 +207,7 @@ public void onConfigurationChanged(Configuration newConfig) {
205
207
206
208
// Splash drawable may change with orientation, so reload it.
207
209
if (splashImageView != null ) {
208
- int drawableId = preferences . getInteger ( "SplashDrawableId" , 0 );
210
+ int drawableId = getSplashId ( );
209
211
if (drawableId != 0 ) {
210
212
splashImageView .setImageDrawable (cordova .getActivity ().getResources ().getDrawable (drawableId ));
211
213
}
@@ -263,7 +265,7 @@ public void onAnimationRepeat(Animation animation) {
263
265
@ SuppressWarnings ("deprecation" )
264
266
private void showSplashScreen (final boolean hideAfterDelay ) {
265
267
final int splashscreenTime = preferences .getInteger ("SplashScreenDelay" , DEFAULT_SPLASHSCREEN_DURATION );
266
- final int drawableId = preferences . getInteger ( "SplashDrawableId" , 0 );
268
+ final int drawableId = getSplashId ( );
267
269
268
270
final int fadeSplashScreenDuration = getFadeDuration ();
269
271
final int effectiveSplashDuration = Math .max (0 , splashscreenTime - fadeSplashScreenDuration );
0 commit comments