CB-3679 Make SplashScreen plugin compatible with cordova-android@4.0.x
This commit is contained in:
parent
50e4887aa1
commit
e593fe3f53
@ -46,13 +46,22 @@ public class SplashScreen extends CordovaPlugin {
|
|||||||
private static ProgressDialog spinnerDialog;
|
private static ProgressDialog spinnerDialog;
|
||||||
private static boolean firstShow = true;
|
private static boolean firstShow = true;
|
||||||
|
|
||||||
|
// Helper to be compile-time compatable with both Cordova 3.x and 4.x.
|
||||||
|
private View getView() {
|
||||||
|
try {
|
||||||
|
return (View)webView.getClass().getMethod("getView").invoke(webView);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return (View)webView;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void pluginInitialize() {
|
protected void pluginInitialize() {
|
||||||
if (HAS_BUILT_IN_SPLASH_SCREEN || !firstShow) {
|
if (HAS_BUILT_IN_SPLASH_SCREEN || !firstShow) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Make WebView invisible while loading URL
|
// Make WebView invisible while loading URL
|
||||||
webView.setVisibility(View.INVISIBLE);
|
getView().setVisibility(View.INVISIBLE);
|
||||||
int drawableId = preferences.getInteger("SplashDrawableId", 0);
|
int drawableId = preferences.getInteger("SplashDrawableId", 0);
|
||||||
if (drawableId == 0) {
|
if (drawableId == 0) {
|
||||||
String splashResource = preferences.getString("SplashScreen", null);
|
String splashResource = preferences.getString("SplashScreen", null);
|
||||||
@ -132,7 +141,7 @@ public class SplashScreen extends CordovaPlugin {
|
|||||||
} else if ("spinner".equals(id)) {
|
} else if ("spinner".equals(id)) {
|
||||||
if ("stop".equals(data.toString())) {
|
if ("stop".equals(data.toString())) {
|
||||||
this.spinnerStop();
|
this.spinnerStop();
|
||||||
webView.setVisibility(View.VISIBLE);
|
getView().setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
} else if ("onReceivedError".equals(id)) {
|
} else if ("onReceivedError".equals(id)) {
|
||||||
spinnerStop();
|
spinnerStop();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user