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
 
2
 
3
 import android.graphics.Color;
3
 import android.graphics.Color;
4
 import android.os.Bundle;
4
 import android.os.Bundle;
5
+import android.support.annotation.LayoutRes;
5
 import android.support.annotation.Nullable;
6
 import android.support.annotation.Nullable;
6
 import android.support.v7.app.AppCompatActivity;
7
 import android.support.v7.app.AppCompatActivity;
7
 import android.view.View;
8
 import android.view.View;
14
     protected void onCreate(@Nullable Bundle savedInstanceState) {
15
     protected void onCreate(@Nullable Bundle savedInstanceState) {
15
         super.onCreate(savedInstanceState);
16
         super.onCreate(savedInstanceState);
16
         NavigationApplication.instance.startReactContext();
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
         View view = new View(this);
31
         View view = new View(this);
19
         view.setBackgroundColor(Color.WHITE);
32
         view.setBackgroundColor(Color.WHITE);
20
         setContentView(view);
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
 }