Browse Source

Deprecated layout managers

Guy Carmeli 8 years ago
parent
commit
425f865112

+ 2
- 2
android/app/src/main/java/com/reactnativenavigation/activities/TabActivity.java View File

@@ -31,14 +31,14 @@ public class TabActivity extends BaseReactActivity {
31 31
         mViewPager = (ViewPager) findViewById(R.id.viewPager);
32 32
 
33 33
         setupToolbar();
34
-        setupViews();
34
+        setupViewPager();
35 35
     }
36 36
 
37 37
     private void setupToolbar() {
38 38
         setSupportActionBar(mToolbar);
39 39
     }
40 40
 
41
-    private void setupViews() {
41
+    private void setupViewPager() {
42 42
         ArrayList<Screen> screens = (ArrayList<Screen>) getIntent().getSerializableExtra(EXTRA_SCREENS);
43 43
         ViewPagerAdapter adapter = new ViewPagerAdapter(this, mViewPager, screens);
44 44
         mViewPager.setAdapter(adapter);

+ 34
- 0
android/app/src/main/java/com/reactnativenavigation/core/RctManager.java View File

@@ -6,10 +6,14 @@ import android.content.Context;
6 6
 import com.facebook.react.LifecycleState;
7 7
 import com.facebook.react.ReactInstanceManager;
8 8
 import com.facebook.react.ReactPackage;
9
+import com.facebook.react.bridge.ReactContext;
9 10
 import com.facebook.react.bridge.ReactContextBaseJavaModule;
11
+import com.facebook.react.bridge.WritableMap;
10 12
 
11 13
 import java.util.List;
12 14
 
15
+import static com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter;
16
+
13 17
 /**
14 18
  * Created by guyc on 22/02/16.
15 19
  */
@@ -85,4 +89,34 @@ public class RctManager {
85 89
 
86 90
         return mReactManager.getCurrentReactContext().getNativeModule(nativeModuleClass);
87 91
     }
92
+
93
+    /**
94
+     * Sends an event to JavaScript using <a href="https://facebook.github.io/react-native/docs/native-modules-android.html#sending-events-to-javascript">RCTDeviceEventEmitter</a>
95
+     * @param eventName Name of the event
96
+     * @param params Event params
97
+     * @param navigatorEventId Id of the navigator
98
+     */
99
+    public void sendEvent(String eventName, String navigatorEventId, WritableMap params) {
100
+        RCTDeviceEventEmitter eventEmitter = getEventEmitter();
101
+        if (eventEmitter == null) {
102
+            return;
103
+        }
104
+
105
+        params.putString(KEY_EVENT_ID, eventName);
106
+        eventEmitter.emit(navigatorEventId, params);
107
+    }
108
+
109
+    private RCTDeviceEventEmitter getEventEmitter() {
110
+        if (mReactManager == null) {
111
+            return null;
112
+        }
113
+
114
+        ReactContext currentReactContext = mReactManager.getCurrentReactContext();
115
+        if (currentReactContext == null) {
116
+            return null;
117
+        }
118
+
119
+        return currentReactContext.getJSModule(RCTDeviceEventEmitter.class);
120
+    }
88 121
 }
122
+

+ 1
- 0
android/app/src/main/java/com/reactnativenavigation/layouts/ReactTabLayout.java View File

@@ -11,6 +11,7 @@ import java.util.UUID;
11 11
  *
12 12
  * Created by guyc on 06/03/16.
13 13
  */
14
+@Deprecated
14 15
 public class ReactTabLayout extends TabLayout {
15 16
 
16 17
     public enum InitialState {

+ 1
- 0
android/app/src/main/java/com/reactnativenavigation/managers/AppBarLayoutManager.java View File

@@ -17,6 +17,7 @@ import java.util.Map;
17 17
 /**
18 18
  * Created by guyc on 08/03/16.
19 19
  */
20
+@Deprecated
20 21
 public class AppBarLayoutManager extends ViewGroupManager<AppBarLayout> {
21 22
     private static final String REACT_CLASS = "AppbarLayout";
22 23
     private static final int COMMAND_SET_CHILDREN_SCROLL_FLAGS = 1;

+ 1
- 0
android/app/src/main/java/com/reactnativenavigation/managers/CoordinatorLayoutManager.java View File

@@ -12,6 +12,7 @@ import java.util.Map;
12 12
 /**
13 13
  * Created by guyc on 19/03/16.
14 14
  */
15
+@Deprecated
15 16
 public class CoordinatorLayoutManager extends ViewGroupManager<CoordinatorLayout> {
16 17
     private static final String REACT_CLASS = "CoordinatorLayout";
17 18
     private static final String COMMAND_CHILD_FLAGS = "setChildFlags";

+ 1
- 0
android/app/src/main/java/com/reactnativenavigation/managers/TabLayoutManager.java View File

@@ -30,6 +30,7 @@ import static android.support.design.widget.TabLayout.Tab;
30 30
  *
31 31
  * Created by guyc on 06/03/16.
32 32
  */
33
+@Deprecated
33 34
 public class TabLayoutManager extends ViewGroupManager<ReactTabLayout> {
34 35
     private static final String REACT_CLASS = "TabLayout";
35 36
     public static final int COMMAND_SET_VIEW_PAGER_TYPE = 1;

+ 1
- 0
android/app/src/main/java/com/reactnativenavigation/managers/ToolbarManager.java View File

@@ -13,6 +13,7 @@ import com.reactnativenavigation.R;
13 13
  *
14 14
  * Created by guyc on 19/03/16.
15 15
  */
16
+@Deprecated
16 17
 public class ToolbarManager extends ViewGroupManager<Toolbar> {
17 18
     private static final String REACT_CLASS = "Toolbar";
18 19
 

+ 1
- 0
android/app/src/main/java/com/reactnativenavigation/modules/RctLayoutManager.java View File

@@ -12,6 +12,7 @@ import com.reactnativenavigation.utils.ContextProvider;
12 12
 /**
13 13
  * Created by guyc on 20/03/16.
14 14
  */
15
+@Deprecated
15 16
 public class RctLayoutManager extends ReactContextBaseJavaModule {
16 17
     public static final String REACT_CLASS = "RctLayoutManager";
17 18