Repository: cordova-plugin-splashscreen Updated Branches: refs/heads/master 50e4887aa -> e593fe3f5
CB-3679 Make SplashScreen plugin compatible with [email protected] Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-splashscreen/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-splashscreen/commit/e593fe3f Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-splashscreen/tree/e593fe3f Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-splashscreen/diff/e593fe3f Branch: refs/heads/master Commit: e593fe3f53251c67a001a56c473b1a5b9fd913b5 Parents: 50e4887 Author: Andrew Grieve <[email protected]> Authored: Wed Dec 10 16:09:54 2014 -0500 Committer: Andrew Grieve <[email protected]> Committed: Wed Dec 10 16:09:54 2014 -0500 ---------------------------------------------------------------------- src/android/SplashScreen.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-plugin-splashscreen/blob/e593fe3f/src/android/SplashScreen.java ---------------------------------------------------------------------- diff --git a/src/android/SplashScreen.java b/src/android/SplashScreen.java index 71b2f02..be7eb6c 100644 --- a/src/android/SplashScreen.java +++ b/src/android/SplashScreen.java @@ -46,13 +46,22 @@ public class SplashScreen extends CordovaPlugin { private static ProgressDialog spinnerDialog; 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 protected void pluginInitialize() { if (HAS_BUILT_IN_SPLASH_SCREEN || !firstShow) { return; } // Make WebView invisible while loading URL - webView.setVisibility(View.INVISIBLE); + getView().setVisibility(View.INVISIBLE); int drawableId = preferences.getInteger("SplashDrawableId", 0); if (drawableId == 0) { String splashResource = preferences.getString("SplashScreen", null); @@ -132,7 +141,7 @@ public class SplashScreen extends CordovaPlugin { } else if ("spinner".equals(id)) { if ("stop".equals(data.toString())) { this.spinnerStop(); - webView.setVisibility(View.VISIBLE); + getView().setVisibility(View.VISIBLE); } } else if ("onReceivedError".equals(id)) { spinnerStop(); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
