react-native-map4d-services 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +24 -24
- package/android/build.gradle +60 -60
- package/android/src/main/AndroidManifest.xml +4 -4
- package/android/src/main/java/com/reactnativemap4dservices/Map4dServicesModule.java +91 -91
- package/android/src/main/java/com/reactnativemap4dservices/Map4dServicesPackage.java +28 -28
- package/android/src/main/java/com/reactnativemap4dservices/SClient.java +50 -50
- package/android/src/main/java/com/reactnativemap4dservices/SConverter.java +166 -166
- package/android/src/main/java/com/reactnativemap4dservices/SJsonUtils.java +130 -130
- package/android/src/main/java/com/reactnativemap4dservices/SRequest.java +376 -376
- package/ios/Map4dServices.h +5 -5
- package/ios/Map4dServices.m +67 -81
- package/ios/Map4dServices.xcodeproj/project.pbxproj +2 -2
- package/ios/SClient.h +23 -23
- package/ios/SClient.m +47 -47
- package/ios/SParamConvert.h +44 -44
- package/ios/SParamConvert.m +229 -229
- package/ios/SRequest.h +36 -40
- package/ios/SRequest.m +112 -142
- package/lib/commonjs/index.js +0 -10
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +0 -6
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/index.d.ts +94 -111
- package/package.json +150 -150
- package/react-native-map4d-services.podspec +20 -20
- package/src/index.tsx +150 -175
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2021 IOTLink
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 IOTLink
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
# react-native-map4d-services
|
|
2
|
-
|
|
3
|
-
React Native Map4dServices for iOS + Android
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```sh
|
|
8
|
-
npm install react-native-map4d-services
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Usage
|
|
12
|
-
|
|
13
|
-
E.g. Auto Suggest
|
|
14
|
-
|
|
15
|
-
```js
|
|
16
|
-
import { fetchSuggestion } from "react-native-map4d-services";
|
|
17
|
-
|
|
18
|
-
// ...
|
|
19
|
-
|
|
20
|
-
fetchSuggestion({text: 'abc'})
|
|
21
|
-
.then(result => {
|
|
22
|
-
console.log('Suggestion:', result);
|
|
23
|
-
})
|
|
24
|
-
```
|
|
1
|
+
# react-native-map4d-services
|
|
2
|
+
|
|
3
|
+
React Native Map4dServices for iOS + Android
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install react-native-map4d-services
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
E.g. Auto Suggest
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
import { fetchSuggestion } from "react-native-map4d-services";
|
|
17
|
+
|
|
18
|
+
// ...
|
|
19
|
+
|
|
20
|
+
fetchSuggestion({text: 'abc'})
|
|
21
|
+
.then(result => {
|
|
22
|
+
console.log('Suggestion:', result);
|
|
23
|
+
})
|
|
24
|
+
```
|
package/android/build.gradle
CHANGED
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
buildscript {
|
|
2
|
-
if (project == rootProject) {
|
|
3
|
-
repositories {
|
|
4
|
-
google()
|
|
5
|
-
mavenCentral()
|
|
6
|
-
jcenter()
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
dependencies {
|
|
10
|
-
classpath 'com.android.tools.build:gradle:3.5.3'
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
apply plugin: 'com.android.library'
|
|
16
|
-
|
|
17
|
-
def safeExtGet(prop, fallback) {
|
|
18
|
-
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
android {
|
|
22
|
-
compileSdkVersion safeExtGet('Map4dServices_compileSdkVersion', 29)
|
|
23
|
-
defaultConfig {
|
|
24
|
-
minSdkVersion safeExtGet('Map4dServices_minSdkVersion', 16)
|
|
25
|
-
targetSdkVersion safeExtGet('Map4dServices_targetSdkVersion', 29)
|
|
26
|
-
versionCode 1
|
|
27
|
-
versionName "1.0"
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
buildTypes {
|
|
32
|
-
release {
|
|
33
|
-
minifyEnabled false
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
lintOptions {
|
|
37
|
-
disable 'GradleCompatible'
|
|
38
|
-
}
|
|
39
|
-
compileOptions {
|
|
40
|
-
sourceCompatibility JavaVersion.VERSION_1_8
|
|
41
|
-
targetCompatibility JavaVersion.VERSION_1_8
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
repositories {
|
|
46
|
-
mavenLocal()
|
|
47
|
-
maven {
|
|
48
|
-
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
|
|
49
|
-
url("$rootDir/../node_modules/react-native/android")
|
|
50
|
-
}
|
|
51
|
-
google()
|
|
52
|
-
mavenCentral()
|
|
53
|
-
jcenter()
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
dependencies {
|
|
57
|
-
//noinspection GradleDynamicVersion
|
|
58
|
-
implementation "com.facebook.react:react-native:+" // From node_modules
|
|
59
|
-
implementation 'vn.map4d:Map4dServices:2.0.0'
|
|
60
|
-
}
|
|
1
|
+
buildscript {
|
|
2
|
+
if (project == rootProject) {
|
|
3
|
+
repositories {
|
|
4
|
+
google()
|
|
5
|
+
mavenCentral()
|
|
6
|
+
jcenter()
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
dependencies {
|
|
10
|
+
classpath 'com.android.tools.build:gradle:3.5.3'
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
apply plugin: 'com.android.library'
|
|
16
|
+
|
|
17
|
+
def safeExtGet(prop, fallback) {
|
|
18
|
+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
android {
|
|
22
|
+
compileSdkVersion safeExtGet('Map4dServices_compileSdkVersion', 29)
|
|
23
|
+
defaultConfig {
|
|
24
|
+
minSdkVersion safeExtGet('Map4dServices_minSdkVersion', 16)
|
|
25
|
+
targetSdkVersion safeExtGet('Map4dServices_targetSdkVersion', 29)
|
|
26
|
+
versionCode 1
|
|
27
|
+
versionName "1.0"
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
buildTypes {
|
|
32
|
+
release {
|
|
33
|
+
minifyEnabled false
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
lintOptions {
|
|
37
|
+
disable 'GradleCompatible'
|
|
38
|
+
}
|
|
39
|
+
compileOptions {
|
|
40
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
41
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
repositories {
|
|
46
|
+
mavenLocal()
|
|
47
|
+
maven {
|
|
48
|
+
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
|
|
49
|
+
url("$rootDir/../node_modules/react-native/android")
|
|
50
|
+
}
|
|
51
|
+
google()
|
|
52
|
+
mavenCentral()
|
|
53
|
+
jcenter()
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
dependencies {
|
|
57
|
+
//noinspection GradleDynamicVersion
|
|
58
|
+
implementation "com.facebook.react:react-native:+" // From node_modules
|
|
59
|
+
implementation 'vn.map4d:Map4dServices:2.0.0'
|
|
60
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
2
|
-
package="com.reactnativemap4dservices">
|
|
3
|
-
|
|
4
|
-
</manifest>
|
|
1
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
2
|
+
package="com.reactnativemap4dservices">
|
|
3
|
+
|
|
4
|
+
</manifest>
|
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
package com.reactnativemap4dservices;
|
|
2
|
-
|
|
3
|
-
import androidx.annotation.NonNull;
|
|
4
|
-
|
|
5
|
-
import com.facebook.react.bridge.Promise;
|
|
6
|
-
import com.facebook.react.bridge.ReactApplicationContext;
|
|
7
|
-
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
8
|
-
import com.facebook.react.bridge.ReactMethod;
|
|
9
|
-
import com.facebook.react.bridge.ReadableMap;
|
|
10
|
-
import com.facebook.react.module.annotations.ReactModule;
|
|
11
|
-
|
|
12
|
-
import vn.map4d.services.MFServicesOptions;
|
|
13
|
-
|
|
14
|
-
@ReactModule(name = Map4dServicesModule.NAME)
|
|
15
|
-
public class Map4dServicesModule extends ReactContextBaseJavaModule {
|
|
16
|
-
public static final String NAME = "Map4dServices";
|
|
17
|
-
|
|
18
|
-
private MFServicesOptions servicesOptions;
|
|
19
|
-
|
|
20
|
-
public Map4dServicesModule(ReactApplicationContext reactContext) {
|
|
21
|
-
super(reactContext);
|
|
22
|
-
servicesOptions = new MFServicesOptions.Builder(reactContext).build();
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
@Override
|
|
26
|
-
@NonNull
|
|
27
|
-
public String getName() {
|
|
28
|
-
return NAME;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/* Place | Suggestions */
|
|
32
|
-
@ReactMethod
|
|
33
|
-
public void fetchSuggestion(ReadableMap params, @NonNull Promise promise) {
|
|
34
|
-
SClient.fireRequest(servicesOptions, SRequest.buildSuggestionsRequestWithData(params), promise);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/* Place | Detail */
|
|
38
|
-
@ReactMethod
|
|
39
|
-
public void fetchPlaceDetail(String placeId, @NonNull Promise promise) {
|
|
40
|
-
SClient.fireRequest(servicesOptions, SRequest.buildPlaceDetailRequestWithId(placeId), promise);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/* Place | Text search */
|
|
44
|
-
@ReactMethod
|
|
45
|
-
public void fetchTextSearch(ReadableMap params, @NonNull Promise promise) {
|
|
46
|
-
SClient.fireRequest(servicesOptions, SRequest.buildTextSearchRequestWithData(params), promise);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/* Place | Nearby search */
|
|
50
|
-
@ReactMethod
|
|
51
|
-
public void fetchNearbySearch(ReadableMap params, @NonNull Promise promise) {
|
|
52
|
-
SClient.fireRequest(servicesOptions, SRequest.buildNearbySearchRequestWithData(params), promise);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/* Place | Viewbox search */
|
|
56
|
-
@ReactMethod
|
|
57
|
-
public void fetchViewboxSearch(ReadableMap params, @NonNull Promise promise) {
|
|
58
|
-
SClient.fireRequest(servicesOptions, SRequest.buildViewboxSearchRequestWithData(params), promise);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/* Place | Geocode */
|
|
62
|
-
@ReactMethod
|
|
63
|
-
public void fetchGeocode(ReadableMap params, @NonNull Promise promise) {
|
|
64
|
-
SClient.fireRequest(servicesOptions, SRequest.buildGeocodingRequestWithData(params), promise);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/* Route | Directions */
|
|
68
|
-
@ReactMethod
|
|
69
|
-
public void fetchDirections(ReadableMap params, @NonNull Promise promise) {
|
|
70
|
-
SClient.fireRequest(servicesOptions, SRequest.buildDirectionsRequestWithData(params), promise);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/* Route | ETA */
|
|
74
|
-
@ReactMethod
|
|
75
|
-
public void fetchRouteETA(ReadableMap params, @NonNull Promise promise) {
|
|
76
|
-
SClient.fireRequest(servicesOptions, SRequest.buildRouteETARequestWithData(params), promise);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/* Route | Distance matrix */
|
|
80
|
-
@ReactMethod
|
|
81
|
-
public void fetchDistanceMatrix(ReadableMap params, @NonNull Promise promise) {
|
|
82
|
-
SClient.fireRequest(servicesOptions, SRequest.buildDistanceMatrixRequestWithData(params), promise);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/* Route | Graph route */
|
|
86
|
-
@ReactMethod
|
|
87
|
-
public void fetchGraphRoute(ReadableMap params, @NonNull Promise promise) {
|
|
88
|
-
SClient.fireRequest(servicesOptions, SRequest.buildGraphRouteRequestWithData(params), promise);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
}
|
|
1
|
+
package com.reactnativemap4dservices;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
|
|
5
|
+
import com.facebook.react.bridge.Promise;
|
|
6
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
7
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
8
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
9
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
10
|
+
import com.facebook.react.module.annotations.ReactModule;
|
|
11
|
+
|
|
12
|
+
import vn.map4d.services.MFServicesOptions;
|
|
13
|
+
|
|
14
|
+
@ReactModule(name = Map4dServicesModule.NAME)
|
|
15
|
+
public class Map4dServicesModule extends ReactContextBaseJavaModule {
|
|
16
|
+
public static final String NAME = "Map4dServices";
|
|
17
|
+
|
|
18
|
+
private MFServicesOptions servicesOptions;
|
|
19
|
+
|
|
20
|
+
public Map4dServicesModule(ReactApplicationContext reactContext) {
|
|
21
|
+
super(reactContext);
|
|
22
|
+
servicesOptions = new MFServicesOptions.Builder(reactContext).build();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@Override
|
|
26
|
+
@NonNull
|
|
27
|
+
public String getName() {
|
|
28
|
+
return NAME;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* Place | Suggestions */
|
|
32
|
+
@ReactMethod
|
|
33
|
+
public void fetchSuggestion(ReadableMap params, @NonNull Promise promise) {
|
|
34
|
+
SClient.fireRequest(servicesOptions, SRequest.buildSuggestionsRequestWithData(params), promise);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/* Place | Detail */
|
|
38
|
+
@ReactMethod
|
|
39
|
+
public void fetchPlaceDetail(String placeId, @NonNull Promise promise) {
|
|
40
|
+
SClient.fireRequest(servicesOptions, SRequest.buildPlaceDetailRequestWithId(placeId), promise);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/* Place | Text search */
|
|
44
|
+
@ReactMethod
|
|
45
|
+
public void fetchTextSearch(ReadableMap params, @NonNull Promise promise) {
|
|
46
|
+
SClient.fireRequest(servicesOptions, SRequest.buildTextSearchRequestWithData(params), promise);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/* Place | Nearby search */
|
|
50
|
+
@ReactMethod
|
|
51
|
+
public void fetchNearbySearch(ReadableMap params, @NonNull Promise promise) {
|
|
52
|
+
SClient.fireRequest(servicesOptions, SRequest.buildNearbySearchRequestWithData(params), promise);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/* Place | Viewbox search */
|
|
56
|
+
@ReactMethod
|
|
57
|
+
public void fetchViewboxSearch(ReadableMap params, @NonNull Promise promise) {
|
|
58
|
+
SClient.fireRequest(servicesOptions, SRequest.buildViewboxSearchRequestWithData(params), promise);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/* Place | Geocode */
|
|
62
|
+
@ReactMethod
|
|
63
|
+
public void fetchGeocode(ReadableMap params, @NonNull Promise promise) {
|
|
64
|
+
SClient.fireRequest(servicesOptions, SRequest.buildGeocodingRequestWithData(params), promise);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/* Route | Directions */
|
|
68
|
+
@ReactMethod
|
|
69
|
+
public void fetchDirections(ReadableMap params, @NonNull Promise promise) {
|
|
70
|
+
SClient.fireRequest(servicesOptions, SRequest.buildDirectionsRequestWithData(params), promise);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* Route | ETA */
|
|
74
|
+
@ReactMethod
|
|
75
|
+
public void fetchRouteETA(ReadableMap params, @NonNull Promise promise) {
|
|
76
|
+
SClient.fireRequest(servicesOptions, SRequest.buildRouteETARequestWithData(params), promise);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/* Route | Distance matrix */
|
|
80
|
+
@ReactMethod
|
|
81
|
+
public void fetchDistanceMatrix(ReadableMap params, @NonNull Promise promise) {
|
|
82
|
+
SClient.fireRequest(servicesOptions, SRequest.buildDistanceMatrixRequestWithData(params), promise);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/* Route | Graph route */
|
|
86
|
+
@ReactMethod
|
|
87
|
+
public void fetchGraphRoute(ReadableMap params, @NonNull Promise promise) {
|
|
88
|
+
SClient.fireRequest(servicesOptions, SRequest.buildGraphRouteRequestWithData(params), promise);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
package com.reactnativemap4dservices;
|
|
2
|
-
|
|
3
|
-
import androidx.annotation.NonNull;
|
|
4
|
-
|
|
5
|
-
import com.facebook.react.ReactPackage;
|
|
6
|
-
import com.facebook.react.bridge.NativeModule;
|
|
7
|
-
import com.facebook.react.bridge.ReactApplicationContext;
|
|
8
|
-
import com.facebook.react.uimanager.ViewManager;
|
|
9
|
-
|
|
10
|
-
import java.util.ArrayList;
|
|
11
|
-
import java.util.Collections;
|
|
12
|
-
import java.util.List;
|
|
13
|
-
|
|
14
|
-
public class Map4dServicesPackage implements ReactPackage {
|
|
15
|
-
@NonNull
|
|
16
|
-
@Override
|
|
17
|
-
public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactContext) {
|
|
18
|
-
List<NativeModule> modules = new ArrayList<>();
|
|
19
|
-
modules.add(new Map4dServicesModule(reactContext));
|
|
20
|
-
return modules;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
@NonNull
|
|
24
|
-
@Override
|
|
25
|
-
public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
|
|
26
|
-
return Collections.emptyList();
|
|
27
|
-
}
|
|
28
|
-
}
|
|
1
|
+
package com.reactnativemap4dservices;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
|
|
5
|
+
import com.facebook.react.ReactPackage;
|
|
6
|
+
import com.facebook.react.bridge.NativeModule;
|
|
7
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
8
|
+
import com.facebook.react.uimanager.ViewManager;
|
|
9
|
+
|
|
10
|
+
import java.util.ArrayList;
|
|
11
|
+
import java.util.Collections;
|
|
12
|
+
import java.util.List;
|
|
13
|
+
|
|
14
|
+
public class Map4dServicesPackage implements ReactPackage {
|
|
15
|
+
@NonNull
|
|
16
|
+
@Override
|
|
17
|
+
public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactContext) {
|
|
18
|
+
List<NativeModule> modules = new ArrayList<>();
|
|
19
|
+
modules.add(new Map4dServicesModule(reactContext));
|
|
20
|
+
return modules;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@NonNull
|
|
24
|
+
@Override
|
|
25
|
+
public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
|
|
26
|
+
return Collections.emptyList();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
package com.reactnativemap4dservices;
|
|
2
|
-
|
|
3
|
-
import androidx.annotation.NonNull;
|
|
4
|
-
import androidx.annotation.Nullable;
|
|
5
|
-
|
|
6
|
-
import com.facebook.react.bridge.Promise;
|
|
7
|
-
import com.facebook.react.bridge.WritableMap;
|
|
8
|
-
import com.facebook.react.bridge.WritableNativeMap;
|
|
9
|
-
|
|
10
|
-
import org.json.JSONException;
|
|
11
|
-
import org.json.JSONObject;
|
|
12
|
-
|
|
13
|
-
import vn.map4d.services.MFServiceCallback;
|
|
14
|
-
import vn.map4d.services.MFServiceOptions;
|
|
15
|
-
import vn.map4d.services.MFServiceTask;
|
|
16
|
-
import vn.map4d.services.MFServices;
|
|
17
|
-
import vn.map4d.services.MFServicesOptions;
|
|
18
|
-
|
|
19
|
-
class SClient {
|
|
20
|
-
static void fireRequest(MFServicesOptions options, MFServiceOptions serviceOptions, @NonNull Promise promise) {
|
|
21
|
-
MFServiceTask serviceTask = new MFServices(options)
|
|
22
|
-
.request(serviceOptions, new MFServiceCallback<JSONObject>() {
|
|
23
|
-
@Override
|
|
24
|
-
public void onSuccess(@Nullable JSONObject json) {
|
|
25
|
-
if (json == null) {
|
|
26
|
-
promise.resolve(null);
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
try {
|
|
30
|
-
final WritableMap data = SJsonUtils.convertJsonToMap(json);
|
|
31
|
-
promise.resolve(data);
|
|
32
|
-
} catch (JSONException e) {
|
|
33
|
-
WritableMap result = new WritableNativeMap();
|
|
34
|
-
result.putString("code", "Map4dServices");
|
|
35
|
-
result.putString("message", "Error when parse JSON data result !");
|
|
36
|
-
promise.resolve(result);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
@Override
|
|
42
|
-
public void onError(String code, String message) {
|
|
43
|
-
WritableMap result = new WritableNativeMap();
|
|
44
|
-
result.putString("code", code);
|
|
45
|
-
result.putString("message", message);
|
|
46
|
-
promise.resolve(result);
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
}
|
|
1
|
+
package com.reactnativemap4dservices;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import androidx.annotation.Nullable;
|
|
5
|
+
|
|
6
|
+
import com.facebook.react.bridge.Promise;
|
|
7
|
+
import com.facebook.react.bridge.WritableMap;
|
|
8
|
+
import com.facebook.react.bridge.WritableNativeMap;
|
|
9
|
+
|
|
10
|
+
import org.json.JSONException;
|
|
11
|
+
import org.json.JSONObject;
|
|
12
|
+
|
|
13
|
+
import vn.map4d.services.MFServiceCallback;
|
|
14
|
+
import vn.map4d.services.MFServiceOptions;
|
|
15
|
+
import vn.map4d.services.MFServiceTask;
|
|
16
|
+
import vn.map4d.services.MFServices;
|
|
17
|
+
import vn.map4d.services.MFServicesOptions;
|
|
18
|
+
|
|
19
|
+
class SClient {
|
|
20
|
+
static void fireRequest(MFServicesOptions options, MFServiceOptions serviceOptions, @NonNull Promise promise) {
|
|
21
|
+
MFServiceTask serviceTask = new MFServices(options)
|
|
22
|
+
.request(serviceOptions, new MFServiceCallback<JSONObject>() {
|
|
23
|
+
@Override
|
|
24
|
+
public void onSuccess(@Nullable JSONObject json) {
|
|
25
|
+
if (json == null) {
|
|
26
|
+
promise.resolve(null);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
try {
|
|
30
|
+
final WritableMap data = SJsonUtils.convertJsonToMap(json);
|
|
31
|
+
promise.resolve(data);
|
|
32
|
+
} catch (JSONException e) {
|
|
33
|
+
WritableMap result = new WritableNativeMap();
|
|
34
|
+
result.putString("code", "Map4dServices");
|
|
35
|
+
result.putString("message", "Error when parse JSON data result !");
|
|
36
|
+
promise.resolve(result);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@Override
|
|
42
|
+
public void onError(String code, String message) {
|
|
43
|
+
WritableMap result = new WritableNativeMap();
|
|
44
|
+
result.putString("code", code);
|
|
45
|
+
result.putString("message", message);
|
|
46
|
+
promise.resolve(result);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|