Browse Source

Add option to set custom splash layout

Guy Carmeli 8 years ago
parent
commit
cc87b8513b

+ 20
- 1
android/app/src/main/java/com/reactnativenavigation/controllers/SplashActivity.java View File

@@ -2,6 +2,7 @@ package com.reactnativenavigation.controllers;
2 2
 
3 3
 import android.graphics.Color;
4 4
 import android.os.Bundle;
5
+import android.support.annotation.LayoutRes;
5 6
 import android.support.annotation.Nullable;
6 7
 import android.support.v7.app.AppCompatActivity;
7 8
 import android.view.View;
@@ -14,9 +15,27 @@ public abstract class SplashActivity extends AppCompatActivity {
14 15
     protected void onCreate(@Nullable Bundle savedInstanceState) {
15 16
         super.onCreate(savedInstanceState);
16 17
         NavigationApplication.instance.startReactContext();
17
-        //TODO show fancy splash
18
+        setSplashLayout();
19
+    }
20
+
21
+    private void setSplashLayout() {
22
+        final int splashLayout = getSplashLayout();
23
+        if (splashLayout > 0) {
24
+            setContentView(splashLayout);
25
+        } else {
26
+            setDefaultSplashLayout();
27
+        }
28
+    }
29
+
30
+    private void setDefaultSplashLayout() {
18 31
         View view = new View(this);
19 32
         view.setBackgroundColor(Color.WHITE);
20 33
         setContentView(view);
21 34
     }
35
+
36
+    /**
37
+     * 
38
+     * @return -1 if you don't need a splash layout
39
+     */
40
+    public abstract @LayoutRes int getSplashLayout();
22 41
 }