Skip to content

Commit 6455a62

Browse files
Merge pull request react-native-maps#370 from lelandrichardson/lmr--rn-029-compat
RN 0.29 Compat and various changes
2 parents 65d1f9b + 53e988d commit 6455a62

File tree

10 files changed

+85
-82
lines changed

10 files changed

+85
-82
lines changed

android/lib/src/main/java/com/airbnb/android/react/maps/AirMapManager.java

+11-26
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,10 @@
2626

2727
public class AirMapManager extends ViewGroupManager<AirMapView> {
2828

29-
public static final String REACT_CLASS = "AIRMap";
30-
31-
public static final int ANIMATE_TO_REGION = 1;
32-
public static final int ANIMATE_TO_COORDINATE = 2;
33-
public static final int FIT_TO_ELEMENTS = 3;
29+
private static final String REACT_CLASS = "AIRMap";
30+
private static final int ANIMATE_TO_REGION = 1;
31+
private static final int ANIMATE_TO_COORDINATE = 2;
32+
private static final int FIT_TO_ELEMENTS = 3;
3433

3534
private final Map<String, Integer> MAP_TYPES = MapBuilder.of(
3635
"standard", GoogleMap.MAP_TYPE_NORMAL,
@@ -41,23 +40,10 @@ public class AirMapManager extends ViewGroupManager<AirMapView> {
4140

4241
private ReactContext reactContext;
4342

44-
private Context appContext;
45-
private AirMapMarkerManager markerManager;
46-
private AirMapPolylineManager polylineManager;
47-
private AirMapPolygonManager polygonManager;
48-
private AirMapCircleManager circleManager;
49-
50-
public AirMapManager(
51-
Context context,
52-
AirMapMarkerManager markerManager,
53-
AirMapPolylineManager polylineManager,
54-
AirMapPolygonManager polygonManager,
55-
AirMapCircleManager circleManager) {
43+
private final Context appContext;
44+
45+
public AirMapManager(Context context) {
5646
this.appContext = context;
57-
this.markerManager = markerManager;
58-
this.polylineManager = polylineManager;
59-
this.polygonManager = polygonManager;
60-
this.circleManager = circleManager;
6147
}
6248

6349
@Override
@@ -71,13 +57,12 @@ protected AirMapView createViewInstance(ThemedReactContext context) {
7157

7258
try {
7359
MapsInitializer.initialize(this.appContext);
74-
} catch (Exception e) {
60+
} catch (RuntimeException e) {
7561
e.printStackTrace();
7662
emitMapError("Map initialize error", "map_init_error");
7763
}
78-
AirMapView view = new AirMapView(context, this.appContext, this);
7964

80-
return view;
65+
return new AirMapView(context, this.appContext, this);
8166
}
8267

8368
@Override
@@ -224,7 +209,7 @@ public void receiveCommand(AirMapView view, int commandId, @Nullable ReadableArr
224209
@Override
225210
@Nullable
226211
public Map getExportedCustomDirectEventTypeConstants() {
227-
Map map = MapBuilder.of(
212+
Map<String, Map<String, String>> map = MapBuilder.of(
228213
"onMapReady", MapBuilder.of("registrationName", "onMapReady"),
229214
"onPress", MapBuilder.of("registrationName", "onPress"),
230215
"onLongPress", MapBuilder.of("registrationName", "onLongPress"),
@@ -286,7 +271,7 @@ public void updateExtraData(AirMapView view, Object extraData) {
286271
view.updateExtraData(extraData);
287272
}
288273

289-
public void pushEvent(View view, String name, WritableMap data) {
274+
void pushEvent(View view, String name, WritableMap data) {
290275
reactContext.getJSModule(RCTEventEmitter.class)
291276
.receiveEvent(view.getId(), name, data);
292277
}

android/lib/src/main/java/com/airbnb/android/react/maps/MapsPackage.java

+1-6
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,7 @@ public List<ViewManager> createViewManagers(ReactApplicationContext reactContext
3333
AirMapPolylineManager polylineManager = new AirMapPolylineManager(reactContext);
3434
AirMapPolygonManager polygonManager = new AirMapPolygonManager(reactContext);
3535
AirMapCircleManager circleManager = new AirMapCircleManager(reactContext);
36-
AirMapManager mapManager = new AirMapManager(
37-
reactContext.getBaseContext(),
38-
annotationManager,
39-
polylineManager,
40-
polygonManager,
41-
circleManager);
36+
AirMapManager mapManager = new AirMapManager(reactContext.getBaseContext());
4237

4338
return Arrays.<ViewManager>asList(
4439
calloutManager,

example/android/AirMapsExplorer.iml

-19
This file was deleted.

example/android/app/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,6 @@ android {
100100

101101
dependencies {
102102
compile "com.android.support:appcompat-v7:23.4.0"
103-
compile "com.facebook.react:react-native:0.27.2" // From node_modules
103+
compile "com.facebook.react:react-native:0.29.0" // From node_modules
104104
compile project(':react-native-maps')
105105
}

example/android/app/src/main/AndroidManifest.xml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<application
77
android:allowBackup="true"
88
android:label="@string/app_name"
9+
android:name=".ExampleApplication"
910
android:icon="@mipmap/ic_launcher"
1011
android:theme="@style/AppTheme">
1112
<activity
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.airbnb.android.react.maps.example;
2+
3+
import android.app.Application;
4+
5+
import com.airbnb.android.react.maps.MapsPackage;
6+
import com.facebook.react.ReactApplication;
7+
import com.facebook.react.ReactNativeHost;
8+
import com.facebook.react.ReactPackage;
9+
import com.facebook.react.shell.MainReactPackage;
10+
11+
import java.util.Arrays;
12+
import java.util.List;
13+
14+
public class ExampleApplication extends Application implements ReactApplication {
15+
private final ReactNativeHost reactNativeHost = new ReactNativeHost(this) {
16+
@Override protected boolean getUseDeveloperSupport() {
17+
return BuildConfig.DEBUG;
18+
}
19+
20+
@Override protected List<ReactPackage> getPackages() {
21+
return Arrays.asList(
22+
new MainReactPackage(),
23+
new MapsPackage());
24+
}
25+
};
26+
27+
@Override
28+
public ReactNativeHost getReactNativeHost() {
29+
return reactNativeHost;
30+
}
31+
}
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
package com.airbnb.android.react.maps.example;
22

3-
import com.airbnb.android.react.maps.MapsPackage;
43
import com.facebook.react.ReactActivity;
5-
import com.facebook.react.ReactPackage;
6-
import com.facebook.react.shell.MainReactPackage;
74

8-
import java.util.Arrays;
9-
import java.util.List;
105

116
public class MainActivity extends ReactActivity {
127

@@ -19,23 +14,4 @@ protected String getMainComponentName() {
1914
return "AirMapsExplorer";
2015
}
2116

22-
/**
23-
* Returns whether dev mode should be enabled.
24-
* This enables e.g. the dev menu.
25-
*/
26-
@Override
27-
protected boolean getUseDeveloperSupport() {
28-
return BuildConfig.DEBUG;
29-
}
30-
31-
/**
32-
* A list of packages used by the app. If the app uses additional views
33-
* or modules besides the default ones, add more packages here.
34-
*/
35-
@Override
36-
protected List<ReactPackage> getPackages() {
37-
return Arrays.asList(
38-
new MainReactPackage(),
39-
new MapsPackage(this));
40-
}
4117
}

example/package.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
"version": "0.0.1",
44
"private": true,
55
"scripts": {
6-
"start": "react-native start"
6+
"start": "react-native start",
7+
"watch": "node ./scripts/watch-and-copy-src.js",
8+
"packager": "sh ./node_modules/react-native/packager/packager.sh --root ./node_modules/react-native-maps",
9+
"dev": "concurrently 'npm run watch' 'npm run packager'"
710
},
811
"dependencies": {
9-
"react": "15.1.0",
10-
"react-native": "0.27.2",
12+
"react": "15.2.0",
13+
"react-native": "0.29.0",
1114
"react-native-maps": "../"
1215
}
1316
}

example/scripts/watch-and-copy-src.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
const fs = require('fs-extra');
2+
const watch = require('node-watch');
3+
const rimraf = require('rimraf');
4+
5+
const packageName = 'react-native-maps/components';
6+
const packagePath = '../components';
7+
8+
console.log(`Cleaning node_modules/${packageName}`);
9+
rimraf(`node_modules/${packageName}`, () => {
10+
console.log(`Copying ${packageName}`);
11+
fs.copy(packagePath, `node_modules/${packageName}`, (err) => {
12+
if (err) return console.error(err);
13+
14+
// Remove conflicting node_modules from `airbnb-dls`.
15+
//['react-native', 'react'].forEach(moduleName =>
16+
// rimraf(`node_modules/${packageName}/node_modules/${moduleName}`, () => {}));
17+
});
18+
19+
console.log(`Watching ${packageName}`);
20+
watch(packagePath, (filename) => {
21+
const localPath = filename.split(packagePath).pop();
22+
const destination = `node_modules/${packageName}${localPath}`;
23+
console.log(`Copying ${filename} to ${destination}`);
24+
fs.copy(filename, destination, (err) => {
25+
if (err) return console.error(err);
26+
});
27+
});
28+
});

package.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@
2020
"google-maps",
2121
"mapkit"
2222
],
23-
"dependencies": {},
23+
"dependencies": {
24+
"react": "*",
25+
"react-native": "*"
26+
},
2427
"devDependencies": {
25-
"react": "15.1.0",
26-
"react-native": "0.27.2"
28+
"react": "15.2.0",
29+
"react-native": "0.29.0"
2730
}
2831
}

0 commit comments

Comments
 (0)