Quellcode durchsuchen

splashLayout xml not mandatory because xml is evil

Daniel Zlotin vor 8 Jahren
Ursprung
Commit
9468d40095

+ 14
- 9
android/app/src/main/java/com/reactnativenavigation/controllers/SplashActivity.java Datei anzeigen

@@ -14,8 +14,8 @@ public abstract class SplashActivity extends AppCompatActivity {
14 14
     @Override
15 15
     protected void onCreate(@Nullable Bundle savedInstanceState) {
16 16
         super.onCreate(savedInstanceState);
17
-        NavigationApplication.instance.startReactContext();
18 17
         setSplashLayout();
18
+        NavigationApplication.instance.startReactContext();
19 19
     }
20 20
 
21 21
     private void setSplashLayout() {
@@ -23,19 +23,24 @@ public abstract class SplashActivity extends AppCompatActivity {
23 23
         if (splashLayout > 0) {
24 24
             setContentView(splashLayout);
25 25
         } else {
26
-            setDefaultSplashLayout();
26
+            setContentView(createSplashLayout());
27 27
         }
28 28
     }
29 29
 
30
-    private void setDefaultSplashLayout() {
31
-        View view = new View(this);
32
-        view.setBackgroundColor(Color.WHITE);
33
-        setContentView(view);
30
+    /**
31
+     * @return xml layout res id
32
+     */
33
+    @LayoutRes
34
+    public int getSplashLayout() {
35
+        return 0;
34 36
     }
35 37
 
36 38
     /**
37
-     * 
38
-     * @return -1 if you don't need a splash layout
39
+     * @return the layout you would like to show while react's js context loads
39 40
      */
40
-    public abstract @LayoutRes int getSplashLayout();
41
+    public View createSplashLayout() {
42
+        View view = new View(this);
43
+        view.setBackgroundColor(Color.WHITE);
44
+        return view;
45
+    }
41 46
 }

+ 1
- 0
example-redux/android/app/src/main/java/com/exampleredux/MainActivity.java Datei anzeigen

@@ -3,4 +3,5 @@ package com.exampleredux;
3 3
 import com.reactnativenavigation.controllers.SplashActivity;
4 4
 
5 5
 public class MainActivity extends SplashActivity {
6
+    
6 7
 }