@nativescript-community/ui-massifmaps 3.0.1 → 4.0.1

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.
Files changed (248) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +237 -0
  3. package/api/bridge.android.d.ts +2 -0
  4. package/api/bridge.android.js +156 -0
  5. package/api/bridge.android.js.map +1 -0
  6. package/api/bridge.d.ts +91 -0
  7. package/api/bridge.ios.d.ts +2 -0
  8. package/api/bridge.ios.js +168 -0
  9. package/api/bridge.ios.js.map +1 -0
  10. package/api/index.common.d.ts +495 -0
  11. package/api/index.common.js +1448 -0
  12. package/api/index.common.js.map +1 -0
  13. package/api/index.d.ts +2 -0
  14. package/api/index.js +3 -0
  15. package/api/index.js.map +1 -0
  16. package/api/massif-api.d.ts +12471 -0
  17. package/api/resolve.d.ts +52 -0
  18. package/api/resolve.js +214 -0
  19. package/api/resolve.js.map +1 -0
  20. package/api/schema.d.ts +67 -0
  21. package/api/schema.js +539 -0
  22. package/api/schema.js.map +1 -0
  23. package/bindings/components/Options.d.ts +14 -13
  24. package/bindings/components/Options.js.map +1 -1
  25. package/bindings/core/Variant.d.ts +2 -1
  26. package/bindings/core/Variant.js.map +1 -1
  27. package/bindings/enums.d.ts +138 -0
  28. package/bindings/enums.js +153 -0
  29. package/bindings/enums.js.map +1 -0
  30. package/bindings/graphics/Bitmap.d.ts +2 -1
  31. package/bindings/graphics/Bitmap.js.map +1 -1
  32. package/bindings/layers/ClusterElementBuilder.d.ts +2 -1
  33. package/bindings/layers/ClusterElementBuilder.js.map +1 -1
  34. package/bindings/layers/CompositeVectorTileLayer.d.ts +3 -7
  35. package/bindings/layers/CompositeVectorTileLayer.js +3 -6
  36. package/bindings/layers/CompositeVectorTileLayer.js.map +1 -1
  37. package/bindings/layers/HillshadeRasterTileLayer.d.ts +3 -2
  38. package/bindings/layers/HillshadeRasterTileLayer.js.map +1 -1
  39. package/bindings/layers/Layer.d.ts +2 -1
  40. package/bindings/layers/Layer.js.map +1 -1
  41. package/bindings/layers/RasterTileLayer.d.ts +3 -2
  42. package/bindings/layers/RasterTileLayer.js.map +1 -1
  43. package/bindings/layers/TileLayer.d.ts +5 -3
  44. package/bindings/layers/TileLayer.js +1 -1
  45. package/bindings/layers/TileLayer.js.map +1 -1
  46. package/bindings/layers/VectorEditEventListener.d.ts +2 -1
  47. package/bindings/layers/VectorEditEventListener.js.map +1 -1
  48. package/bindings/layers/VectorTileLayer.d.ts +5 -4
  49. package/bindings/layers/VectorTileLayer.js.map +1 -1
  50. package/bindings/packagemanager/PackageInfo.d.ts +2 -1
  51. package/bindings/packagemanager/PackageInfo.js.map +1 -1
  52. package/bindings/packagemanager/PackageManagerListener.d.ts +2 -1
  53. package/bindings/packagemanager/PackageManagerListener.js.map +1 -1
  54. package/bindings/packagemanager/PackageStatus.d.ts +2 -1
  55. package/bindings/packagemanager/PackageStatus.js.map +1 -1
  56. package/bindings/packagemanager/PackageTileMask.d.ts +2 -1
  57. package/bindings/packagemanager/PackageTileMask.js.map +1 -1
  58. package/bindings/routing/RouteMatchingPoint.d.ts +2 -1
  59. package/bindings/routing/RouteMatchingPoint.js.map +1 -1
  60. package/bindings/routing/RoutingInstruction.js.map +1 -1
  61. package/bindings/styles/AnimationStyle.d.ts +3 -2
  62. package/bindings/styles/AnimationStyle.js.map +1 -1
  63. package/bindings/styles/AnimationStyleBuilder.d.ts +7 -6
  64. package/bindings/styles/AnimationStyleBuilder.js.map +1 -1
  65. package/bindings/styles/LabelStyle.js.map +1 -1
  66. package/bindings/styles/LabelStyleBuilder.d.ts +5 -4
  67. package/bindings/styles/LabelStyleBuilder.js.map +1 -1
  68. package/bindings/styles/LineStyle.d.ts +2 -1
  69. package/bindings/styles/LineStyle.js.map +1 -1
  70. package/bindings/styles/LineStyleBuilder.d.ts +6 -5
  71. package/bindings/styles/LineStyleBuilder.js.map +1 -1
  72. package/bindings/styles/MarkerStyle.js.map +1 -1
  73. package/bindings/styles/MarkerStyleBuilder.d.ts +5 -4
  74. package/bindings/styles/MarkerStyleBuilder.js.map +1 -1
  75. package/bindings/styles/NMLModelStyle.js.map +1 -1
  76. package/bindings/styles/NMLModelStyleBuilder.d.ts +5 -4
  77. package/bindings/styles/NMLModelStyleBuilder.js.map +1 -1
  78. package/bindings/ui/BalloonPopupButtonClickInfo.js.map +1 -1
  79. package/bindings/ui/ClickInfo.js.map +1 -1
  80. package/bindings/ui/MapClickInfo.js.map +1 -1
  81. package/bindings/ui/PopupClickInfo.js.map +1 -1
  82. package/bindings/ui/RasterTileClickInfo.js.map +1 -1
  83. package/bindings/ui/UTFGridClickInfo.js.map +1 -1
  84. package/bindings/ui/VectorElementClickInfo.js.map +1 -1
  85. package/bindings/ui/VectorElementDragInfo.d.ts +2 -1
  86. package/bindings/ui/VectorElementDragInfo.js.map +1 -1
  87. package/bindings/ui/VectorTileClickInfo.d.ts +3 -1
  88. package/bindings/ui/VectorTileClickInfo.js +5 -2
  89. package/bindings/ui/VectorTileClickInfo.js.map +1 -1
  90. package/bindings/utils/BundleAssetPackage.d.ts +15 -0
  91. package/bindings/utils/BundleAssetPackage.js +8 -0
  92. package/bindings/utils/BundleAssetPackage.js.map +1 -0
  93. package/bindings/utils/index.d.ts +1 -0
  94. package/bindings/utils/index.js +1 -0
  95. package/bindings/utils/index.js.map +1 -1
  96. package/bindings/vectortiles/MBVectorTileDecoder.d.ts +4 -3
  97. package/bindings/vectortiles/MBVectorTileDecoder.js.map +1 -1
  98. package/celestial/CelestialArc.android.d.ts +0 -1
  99. package/celestial/CelestialArc.android.js +0 -3
  100. package/celestial/CelestialArc.android.js.map +1 -1
  101. package/celestial/CelestialArc.d.ts +1 -3
  102. package/celestial/CelestialArc.ios.d.ts +0 -1
  103. package/celestial/CelestialArc.ios.js +0 -1
  104. package/celestial/CelestialArc.ios.js.map +1 -1
  105. package/celestial/CelestialObject.android.d.ts +0 -1
  106. package/celestial/CelestialObject.android.js +0 -1
  107. package/celestial/CelestialObject.android.js.map +1 -1
  108. package/celestial/CelestialObject.d.ts +0 -2
  109. package/celestial/CelestialObject.ios.d.ts +0 -1
  110. package/celestial/CelestialObject.ios.js +0 -1
  111. package/celestial/CelestialObject.ios.js.map +1 -1
  112. package/celestial/CelestialObjectVector.android.d.ts +0 -1
  113. package/celestial/CelestialObjectVector.android.js +0 -4
  114. package/celestial/CelestialObjectVector.android.js.map +1 -1
  115. package/celestial/CelestialObjectVector.d.ts +0 -2
  116. package/celestial/CelestialObjectVector.ios.d.ts +0 -1
  117. package/celestial/CelestialObjectVector.ios.js +0 -1
  118. package/celestial/CelestialObjectVector.ios.js.map +1 -1
  119. package/celestial/CelestialSprite.android.d.ts +0 -1
  120. package/celestial/CelestialSprite.android.js +0 -3
  121. package/celestial/CelestialSprite.android.js.map +1 -1
  122. package/celestial/CelestialSprite.d.ts +1 -3
  123. package/celestial/CelestialSprite.ios.d.ts +0 -1
  124. package/celestial/CelestialSprite.ios.js +0 -1
  125. package/celestial/CelestialSprite.ios.js.map +1 -1
  126. package/components/index.android.d.ts +9 -27
  127. package/components/index.android.js +3 -21
  128. package/components/index.android.js.map +1 -1
  129. package/components/index.d.ts +4 -26
  130. package/components/index.ios.d.ts +3 -21
  131. package/components/index.ios.js +3 -21
  132. package/components/index.ios.js.map +1 -1
  133. package/core/index.android.js +3 -3
  134. package/core/index.android.js.map +1 -1
  135. package/core/index.ios.js +3 -4
  136. package/core/index.ios.js.map +1 -1
  137. package/datasources/mbtiles.android.d.ts +2 -2
  138. package/index.android.d.ts +1 -6
  139. package/index.android.js +4 -8
  140. package/index.android.js.map +1 -1
  141. package/index.common.d.ts +3 -6
  142. package/index.common.js +3 -6
  143. package/index.common.js.map +1 -1
  144. package/index.d.ts +6 -0
  145. package/index.ios.d.ts +1 -6
  146. package/index.ios.js +1 -6
  147. package/index.ios.js.map +1 -1
  148. package/layers/CelestialLayer.android.d.ts +0 -1
  149. package/layers/CelestialLayer.android.js +0 -3
  150. package/layers/CelestialLayer.android.js.map +1 -1
  151. package/layers/CelestialLayer.d.ts +1 -4
  152. package/layers/CelestialLayer.ios.d.ts +0 -1
  153. package/layers/CelestialLayer.ios.js +1 -4
  154. package/layers/CelestialLayer.ios.js.map +1 -1
  155. package/layers/composite.android.d.ts +3 -5
  156. package/layers/composite.android.js +0 -6
  157. package/layers/composite.android.js.map +1 -1
  158. package/layers/composite.d.ts +6 -25
  159. package/layers/composite.ios.d.ts +2 -6
  160. package/layers/composite.ios.js +2 -10
  161. package/layers/composite.ios.js.map +1 -1
  162. package/layers/index.android.d.ts +3 -3
  163. package/layers/index.d.ts +4 -22
  164. package/layers/raster.android.d.ts +8 -8
  165. package/layers/raster.android.js +1 -1
  166. package/layers/raster.android.js.map +1 -1
  167. package/layers/raster.d.ts +2 -11
  168. package/layers/vector.android.d.ts +10 -10
  169. package/layers/vector.android.js +2 -2
  170. package/layers/vector.android.js.map +1 -1
  171. package/layers/vector.d.ts +15 -71
  172. package/nativeclass.common.d.ts +6 -31
  173. package/nativeclass.common.js +4 -21
  174. package/nativeclass.common.js.map +1 -1
  175. package/nativescript.config.ts +9 -6
  176. package/package.json +2 -2
  177. package/platforms/android/include-settings.gradle +18 -4
  178. package/platforms/android/include.gradle +10 -2
  179. package/platforms/android/java/com/nativescript/massifmaps/additions/CelestialEventListener.java +1 -1
  180. package/platforms/android/java/com/nativescript/massifmaps/additions/ClusterElementBuilder.java +1 -1
  181. package/platforms/android/java/com/nativescript/massifmaps/additions/HillshadeRasterTileLayer.java +4 -4
  182. package/platforms/android/java/com/nativescript/massifmaps/additions/RasterTileEventListener.java +1 -1
  183. package/platforms/android/java/com/nativescript/massifmaps/additions/RendererCaptureListener.java +1 -1
  184. package/platforms/android/java/com/nativescript/massifmaps/additions/SynchronousHandler.java +28 -0
  185. package/platforms/android/java/com/nativescript/massifmaps/additions/TileDownloadListener.java +4 -4
  186. package/platforms/android/java/com/nativescript/massifmaps/additions/VectorElementEventListener.java +1 -1
  187. package/platforms/android/java/com/nativescript/massifmaps/additions/VectorTileEventListener.java +1 -1
  188. package/platforms/android/java/com/nativescript/massifmaps/additions2/FeatureCollectionSearchService.java +1 -2
  189. package/platforms/android/java/com/nativescript/massifmaps/additions2/VectorEditEventListener.java +21 -20
  190. package/platforms/android/java/com/nativescript/massifmaps/additions2/VectorTileSearchService.java +1 -2
  191. package/platforms/android/java/com/nativescript/massifmaps/api/EventListener.java +60 -0
  192. package/platforms/android/java/com/nativescript/massifmaps/geocoding/GeocodingServiceAdditions.java +5 -5
  193. package/platforms/android/java/com/nativescript/massifmaps/packagemanager/PackageManagerListener.java +11 -11
  194. package/platforms/android/java/com/nativescript/massifmaps/routing/RoutingServiceAdditions.java +19 -36
  195. package/platforms/android/native-api-usage.json +8 -0
  196. package/platforms/ios/build.xcconfig +4 -1
  197. package/platforms/ios/native-api-usage.json +1 -0
  198. package/platforms/ios/src/MassifMapsAdditions.h +1 -0
  199. package/platforms/ios/src/NSMSFApiEventListener.h +23 -0
  200. package/platforms/ios/src/NSMSFApiEventListener.mm +33 -0
  201. package/platforms/ios/src/NSMSFFeatureCollectionSearchService.swift +1 -1
  202. package/platforms/ios/src/NSMSFGeocodingServiceAdditions.swift +1 -1
  203. package/platforms/ios/src/NSMSFHillshadeRasterTileLayer.swift +1 -1
  204. package/platforms/ios/src/NSMSFMainThread.swift +21 -0
  205. package/platforms/ios/src/NSMSFRoutingServiceAdditions.swift +1 -1
  206. package/platforms/ios/src/NSMSFVectorTileSearchService.swift +1 -1
  207. package/projections/index.ios.js.map +1 -1
  208. package/renderers/index.d.ts +3 -10
  209. package/routing/index.android.d.ts +17 -17
  210. package/tsconfig.tsbuildinfo +1 -1
  211. package/typings/massifmaps.android.d.ts +1913 -410
  212. package/typings/massifmaps.ios.d.ts +21 -4
  213. package/typings/ns.massifmaps.android.d.ts +44 -175
  214. package/typings/ns.massifmaps.ios.d.ts +10 -63
  215. package/ui/index.android.d.ts +10 -14
  216. package/ui/index.android.js +6 -66
  217. package/ui/index.android.js.map +1 -1
  218. package/ui/index.common.d.ts +31 -0
  219. package/ui/index.common.js +130 -2
  220. package/ui/index.common.js.map +1 -1
  221. package/ui/index.d.ts +60 -21
  222. package/ui/index.ios.d.ts +4 -6
  223. package/ui/index.ios.js +5 -92
  224. package/ui/index.ios.js.map +1 -1
  225. package/utils/index.android.d.ts +9 -22
  226. package/utils/index.android.js +20 -129
  227. package/utils/index.android.js.map +1 -1
  228. package/utils/index.d.ts +9 -7
  229. package/utils/index.ios.d.ts +10 -18
  230. package/utils/index.ios.js +20 -109
  231. package/utils/index.ios.js.map +1 -1
  232. package/vectorelements/index.android.d.ts +6 -6
  233. package/vectorelements/line.android.d.ts +8 -11
  234. package/vectorelements/line.android.js +1 -4
  235. package/vectorelements/line.android.js.map +1 -1
  236. package/vectorelements/line.ios.d.ts +1 -4
  237. package/vectorelements/line.ios.js +1 -4
  238. package/vectorelements/line.ios.js.map +1 -1
  239. package/vectortiles/index.android.d.ts +0 -2
  240. package/vectortiles/index.android.js +0 -9
  241. package/vectortiles/index.android.js.map +1 -1
  242. package/platforms/android/java/com/nativescript/massifmaps/additions/AssetPackage.java +0 -59
  243. package/platforms/android/java/com/nativescript/massifmaps/additions/DirAssetPackage.java +0 -53
  244. package/platforms/android/java/com/nativescript/massifmaps/additions/MapEventListener.java +0 -17
  245. package/platforms/android/java/com/nativescript/massifmaps/additions/MapView.java +0 -167
  246. package/platforms/android/java/com/nativescript/massifmaps/additions/TextureMapView.java +0 -166
  247. package/platforms/ios/src/NSMSFMapEventListener.swift +0 -43
  248. package/platforms/ios/src/NSMSFMapView.swift +0 -106
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nativescript-community/ui-massifmaps",
3
- "version": "3.0.1",
3
+ "version": "4.0.1",
4
4
  "description": "NativeScript plugin for MassifMaps SDK",
5
5
  "main": "index",
6
6
  "typings": "index.d.ts",
@@ -48,5 +48,5 @@
48
48
  "publishConfig": {
49
49
  "access": "public"
50
50
  },
51
- "gitHead": "f68a406b89c0b8a17f0d979243d6c320bdbbfe97"
51
+ "gitHead": "9faae9f65857a63e09fca6f4715eda04b0c646b9"
52
52
  }
@@ -1,6 +1,20 @@
1
- println 'debugMassif settings: ' + System.env.DEBUGMASSIF
2
1
  if (System.env.DEBUGMASSIF) {
2
+ // MASSIF_SDK_HOME is REQUIRED here, and its absence has to be loud. Unset, the path below
3
+ // became "null/scripts/android-dev/massif": gradle accepted the include, the project had no
4
+ // variants, and the app silently kept whatever libmassif.so was already in its intermediates.
5
+ // A whole afternoon went into a bug that had already been fixed in a library nothing rebuilt.
6
+ def home = System.env.MASSIF_SDK_HOME
7
+ if (!home) {
8
+ throw new GradleException('DEBUGMASSIF is set but MASSIF_SDK_HOME is not - '
9
+ + 'cannot locate the local massif project. Set it to your mobile-sdk checkout, '
10
+ + 'or unset DEBUGMASSIF to build against the published AAR.')
11
+ }
12
+ def dir = new File("${home}/scripts/android-dev/massif")
13
+ if (!dir.isDirectory()) {
14
+ throw new GradleException("MASSIF_SDK_HOME does not look like a mobile-sdk checkout: "
15
+ + "${dir} is not a directory")
16
+ }
17
+ println "debugMassif project: ${dir}"
3
18
  include ':massif'
4
- println 'debugMassif project: ' + "${System.env.MASSIF_SDK_HOME}/scripts/android-dev/massif"
5
- project(':massif').projectDir = new File("${System.env.MASSIF_SDK_HOME}/scripts/android-dev/massif")
6
- }
19
+ project(':massif').projectDir = dir
20
+ }
@@ -14,7 +14,7 @@ dependencies {
14
14
 
15
15
  } else {
16
16
 
17
- def massifSDKVersion = project.hasProperty("massifSDKVersion") ? project.massifSDKVersion : "6.0.0"
17
+ def massifSDKVersion = project.hasProperty("massifSDKVersion") ? project.massifSDKVersion : "6.2.0"
18
18
  def massifSDKVariant = project.hasProperty("massifSDKVariant") ? project.massifSDKVariant : "full"
19
19
 
20
20
  if (massifSDKVariant == "full") {
@@ -39,7 +39,15 @@ android {
39
39
  if (massifSDKVariant == "lite") {
40
40
  exclude '**/additions2/**'
41
41
  }
42
+
43
+ // The surface API's listener extends com.massifmaps.api.EventListener, which only
44
+ // exists in an SDK built with all/native/api. Turn it off with -PmassifApi=false
45
+ // when pinning an older SDK; the plugin's object API is unaffected.
46
+ def massifApi = project.hasProperty("massifApi") ? project.massifApi.toString() : "true"
47
+ if (massifApi == "false") {
48
+ exclude '**/nativescript/massifmaps/api/**'
49
+ }
42
50
  }
43
51
  }
44
52
  }
45
- }
53
+ }
@@ -26,7 +26,7 @@ public class CelestialEventListener extends com.massifmaps.layers.CelestialEvent
26
26
 
27
27
  @Override
28
28
  public boolean onCelestialObjectClicked(final ClickInfo arg0, final CelestialObject arg1) {
29
- if (MapView.RUN_ON_MAIN_THREAD) {
29
+ if (SynchronousHandler.RUN_ON_MAIN_THREAD) {
30
30
  if (mainHandler == null) {
31
31
  mainHandler = new Handler(android.os.Looper.getMainLooper());
32
32
  }
@@ -103,7 +103,7 @@ public class ClusterElementBuilder extends com.massifmaps.layers.ClusterElementB
103
103
  if (useNativeBuilder) {
104
104
  return nativeBuildClusterElement(pos, elements);
105
105
  }
106
- if (MapView.RUN_ON_MAIN_THREAD) {
106
+ if (SynchronousHandler.RUN_ON_MAIN_THREAD) {
107
107
  final Object[] arr = new Object[1];
108
108
  if (mainHandler == null) {
109
109
  mainHandler = new Handler(android.os.Looper.getMainLooper());
@@ -41,7 +41,7 @@ public class HillshadeRasterTileLayer extends com.massifmaps.layers.HillshadeRas
41
41
  result = fThis.getElevation(pos);
42
42
  } catch (final Exception e) {
43
43
  e.printStackTrace();
44
- if (MapView.RUN_ON_MAIN_THREAD) {
44
+ if (SynchronousHandler.RUN_ON_MAIN_THREAD) {
45
45
  if (mainHandler == null) {
46
46
  mainHandler = new Handler(android.os.Looper.getMainLooper());
47
47
  }
@@ -58,7 +58,7 @@ public class HillshadeRasterTileLayer extends com.massifmaps.layers.HillshadeRas
58
58
  }
59
59
 
60
60
  final Double fRa = result;
61
- if (MapView.RUN_ON_MAIN_THREAD) {
61
+ if (SynchronousHandler.RUN_ON_MAIN_THREAD) {
62
62
  if (mainHandler == null) {
63
63
  mainHandler = new Handler(android.os.Looper.getMainLooper());
64
64
  }
@@ -88,7 +88,7 @@ public class HillshadeRasterTileLayer extends com.massifmaps.layers.HillshadeRas
88
88
  result = fThis.getElevations(poses);
89
89
  } catch (final Exception e) {
90
90
  e.printStackTrace();
91
- if (MapView.RUN_ON_MAIN_THREAD) {
91
+ if (SynchronousHandler.RUN_ON_MAIN_THREAD) {
92
92
  if (mainHandler == null) {
93
93
  mainHandler = new Handler(android.os.Looper.getMainLooper());
94
94
  }
@@ -105,7 +105,7 @@ public class HillshadeRasterTileLayer extends com.massifmaps.layers.HillshadeRas
105
105
  }
106
106
 
107
107
  final DoubleVector fRa = result;
108
- if (MapView.RUN_ON_MAIN_THREAD) {
108
+ if (SynchronousHandler.RUN_ON_MAIN_THREAD) {
109
109
  if (mainHandler == null) {
110
110
  mainHandler = new Handler(android.os.Looper.getMainLooper());
111
111
  }
@@ -25,7 +25,7 @@ public class RasterTileEventListener extends com.massifmaps.layers.RasterTileEve
25
25
 
26
26
  @Override
27
27
  public boolean onRasterTileClicked(final RasterTileClickInfo clickInfo) {
28
- if (MapView.RUN_ON_MAIN_THREAD) {
28
+ if (SynchronousHandler.RUN_ON_MAIN_THREAD) {
29
29
  final Object[] arr = new Object[1];
30
30
  if (mainHandler == null) {
31
31
  mainHandler = new Handler(android.os.Looper.getMainLooper());
@@ -21,7 +21,7 @@ public class RendererCaptureListener extends com.massifmaps.renderers.RendererCa
21
21
 
22
22
  @Override
23
23
  public void onMapRendered(final Bitmap bitmap) {
24
- if (MapView.RUN_ON_MAIN_THREAD) {
24
+ if (SynchronousHandler.RUN_ON_MAIN_THREAD) {
25
25
  final Object[] arr = new Object[1];
26
26
  if (mainHandler == null) {
27
27
  mainHandler = new Handler(android.os.Looper.getMainLooper());
@@ -6,6 +6,34 @@ import android.os.Looper;
6
6
 
7
7
  public class SynchronousHandler {
8
8
 
9
+ /**
10
+ * Whether the plugin's listeners hop to the main thread and WAIT before calling into
11
+ * JavaScript.
12
+ *
13
+ * It lives here, next to the hop, rather than on a map view: the SDK emits from its render,
14
+ * tile and routing threads, where NativeScript has no runtime at all, and every listener in
15
+ * this plugin - map events, routing, geocoding, search, hillshade, tile downloads - has the
16
+ * same problem whether or not the surface API is in play. It is plugin policy, so it does not
17
+ * belong on the SDK's MapView either.
18
+ *
19
+ * Waiting rather than posting is what lets a consuming callback answer in time, and what
20
+ * keeps a facade payload alive until the handler has read it.
21
+ */
22
+ public static boolean RUN_ON_MAIN_THREAD = true;
23
+
24
+ public static void setRunOnMainThread(boolean value) {
25
+ RUN_ON_MAIN_THREAD = value;
26
+ }
27
+
28
+ /** The whole pattern in one call: hop and wait when asked to, otherwise run here. */
29
+ public static void run(final Handler handler, final Runnable r) {
30
+ if (RUN_ON_MAIN_THREAD) {
31
+ postAndWait(handler, r);
32
+ } else {
33
+ r.run();
34
+ }
35
+ }
36
+
9
37
  private static class NotifyRunnable implements Runnable {
10
38
  private final Runnable mRunnable;
11
39
  private boolean mFinished = false;
@@ -31,7 +31,7 @@ public class TileDownloadListener extends com.massifmaps.datasources.TileDownloa
31
31
 
32
32
  @Override
33
33
  public void onDownloadCompleted() {
34
- if (MapView.RUN_ON_MAIN_THREAD) {
34
+ if (SynchronousHandler.RUN_ON_MAIN_THREAD) {
35
35
  final Object[] arr = new Object[1];
36
36
  if (mainHandler == null) {
37
37
  mainHandler = new Handler(android.os.Looper.getMainLooper());
@@ -58,7 +58,7 @@ public class TileDownloadListener extends com.massifmaps.datasources.TileDownloa
58
58
 
59
59
  @Override
60
60
  public void onDownloadFailed(final MapTile tile) {
61
- if (MapView.RUN_ON_MAIN_THREAD) {
61
+ if (SynchronousHandler.RUN_ON_MAIN_THREAD) {
62
62
  final Object[] arr = new Object[1];
63
63
  if (mainHandler == null) {
64
64
  mainHandler = new Handler(android.os.Looper.getMainLooper());
@@ -85,7 +85,7 @@ public class TileDownloadListener extends com.massifmaps.datasources.TileDownloa
85
85
 
86
86
  @Override
87
87
  public void onDownloadProgress(final float progress) {
88
- if (MapView.RUN_ON_MAIN_THREAD) {
88
+ if (SynchronousHandler.RUN_ON_MAIN_THREAD) {
89
89
  final Object[] arr = new Object[1];
90
90
  if (mainHandler == null) {
91
91
  mainHandler = new Handler(android.os.Looper.getMainLooper());
@@ -112,7 +112,7 @@ public class TileDownloadListener extends com.massifmaps.datasources.TileDownloa
112
112
 
113
113
  @Override
114
114
  public void onDownloadStarting(final int tileCount) {
115
- if (MapView.RUN_ON_MAIN_THREAD) {
115
+ if (SynchronousHandler.RUN_ON_MAIN_THREAD) {
116
116
  final Object[] arr = new Object[1];
117
117
  if (mainHandler == null) {
118
118
  mainHandler = new Handler(android.os.Looper.getMainLooper());
@@ -23,7 +23,7 @@ public class VectorElementEventListener extends com.massifmaps.layers.VectorElem
23
23
 
24
24
  @Override
25
25
  public boolean onVectorElementClicked(final VectorElementClickInfo clickInfo) {
26
- if (MapView.RUN_ON_MAIN_THREAD) {
26
+ if (SynchronousHandler.RUN_ON_MAIN_THREAD) {
27
27
  final Object[] arr = new Object[1];
28
28
  if (mainHandler == null) {
29
29
  mainHandler = new Handler(android.os.Looper.getMainLooper());
@@ -25,7 +25,7 @@ public class VectorTileEventListener extends com.massifmaps.layers.VectorTileEve
25
25
 
26
26
  @Override
27
27
  public boolean onVectorTileClicked(final VectorTileClickInfo clickInfo) {
28
- if (MapView.RUN_ON_MAIN_THREAD) {
28
+ if (SynchronousHandler.RUN_ON_MAIN_THREAD) {
29
29
  final Object[] arr = new Object[1];
30
30
  if (mainHandler == null) {
31
31
  mainHandler = new Handler(android.os.Looper.getMainLooper());
@@ -3,7 +3,6 @@ package com.nativescript.massifmaps.additions2;
3
3
  import android.os.Handler;
4
4
  import android.util.Log;
5
5
 
6
- import com.nativescript.massifmaps.additions.MapView;
7
6
  import com.nativescript.massifmaps.additions.SynchronousHandler;
8
7
  import com.nativescript.massifmaps.additions.FeatureCollectionSearchServiceCallback;
9
8
  import com.massifmaps.search.SearchRequest;
@@ -27,7 +26,7 @@ public class FeatureCollectionSearchService extends com.massifmaps.search.Featur
27
26
  @Override
28
27
  public void run() {
29
28
  final FeatureCollection results = FeatureCollectionSearchService.this.findFeatures(request);
30
- if (MapView.RUN_ON_MAIN_THREAD) {
29
+ if (SynchronousHandler.RUN_ON_MAIN_THREAD) {
31
30
  if (mainHandler == null) {
32
31
  mainHandler = new Handler(android.os.Looper.getMainLooper());
33
32
  }
@@ -3,7 +3,6 @@ package com.nativescript.massifmaps.additions2;
3
3
  import android.os.Handler;
4
4
  import android.util.Log;
5
5
 
6
- import com.nativescript.massifmaps.additions.MapView;
7
6
  import com.nativescript.massifmaps.additions.SynchronousHandler;
8
7
  import com.massifmaps.geometry.Geometry;
9
8
  import com.massifmaps.layers.VectorElementDragPointStyle;
@@ -19,13 +18,14 @@ public class VectorEditEventListener extends com.massifmaps.layers.VectorEditEve
19
18
  public interface Listener {
20
19
  boolean onElementSelect(VectorElement element);
21
20
 
22
- PointStyle onSelectDragPointStyle(VectorElement element, VectorElementDragPointStyle dragPointStyle);
21
+ PointStyle onSelectDragPointStyle(VectorElement element,
22
+ @VectorElementDragPointStyle.Value int dragPointStyle);
23
23
 
24
- VectorElementDragResult onDragEnd(VectorElementDragInfo dragInfo);
24
+ @VectorElementDragResult.Value int onDragEnd(VectorElementDragInfo dragInfo);
25
25
 
26
- VectorElementDragResult onDragMove(VectorElementDragInfo dragInfo);
26
+ @VectorElementDragResult.Value int onDragMove(VectorElementDragInfo dragInfo);
27
27
 
28
- VectorElementDragResult onDragStart(VectorElementDragInfo dragInfo);
28
+ @VectorElementDragResult.Value int onDragStart(VectorElementDragInfo dragInfo);
29
29
 
30
30
  void onElementDelete(VectorElement element);
31
31
 
@@ -48,7 +48,7 @@ public class VectorEditEventListener extends com.massifmaps.layers.VectorEditEve
48
48
 
49
49
  @Override
50
50
  public boolean onElementSelect(final VectorElement element) {
51
- if (MapView.RUN_ON_MAIN_THREAD) {
51
+ if (SynchronousHandler.RUN_ON_MAIN_THREAD) {
52
52
  final Object[] arr = new Object[1];
53
53
  if (mainHandler == null) {
54
54
  mainHandler = new Handler(android.os.Looper.getMainLooper());
@@ -76,7 +76,7 @@ public class VectorEditEventListener extends com.massifmaps.layers.VectorEditEve
76
76
 
77
77
  @Override
78
78
  public void onElementDelete(final VectorElement element) {
79
- if (MapView.RUN_ON_MAIN_THREAD) {
79
+ if (SynchronousHandler.RUN_ON_MAIN_THREAD) {
80
80
  if (mainHandler == null) {
81
81
  mainHandler = new Handler(android.os.Looper.getMainLooper());
82
82
  }
@@ -101,7 +101,7 @@ public class VectorEditEventListener extends com.massifmaps.layers.VectorEditEve
101
101
 
102
102
  @Override
103
103
  public void onElementDeselected(final VectorElement element) {
104
- if (MapView.RUN_ON_MAIN_THREAD) {
104
+ if (SynchronousHandler.RUN_ON_MAIN_THREAD) {
105
105
  if (mainHandler == null) {
106
106
  mainHandler = new Handler(android.os.Looper.getMainLooper());
107
107
  }
@@ -126,7 +126,7 @@ public class VectorEditEventListener extends com.massifmaps.layers.VectorEditEve
126
126
 
127
127
  @Override
128
128
  public void onElementModify(final VectorElement element, final Geometry geometry) {
129
- if (MapView.RUN_ON_MAIN_THREAD) {
129
+ if (SynchronousHandler.RUN_ON_MAIN_THREAD) {
130
130
  if (mainHandler == null) {
131
131
  mainHandler = new Handler(android.os.Looper.getMainLooper());
132
132
  }
@@ -150,8 +150,9 @@ public class VectorEditEventListener extends com.massifmaps.layers.VectorEditEve
150
150
  }
151
151
 
152
152
  @Override
153
- public PointStyle onSelectDragPointStyle(final VectorElement element, final VectorElementDragPointStyle dragPointStyle) {
154
- if (MapView.RUN_ON_MAIN_THREAD) {
153
+ public PointStyle onSelectDragPointStyle(final VectorElement element,
154
+ final @VectorElementDragPointStyle.Value int dragPointStyle) {
155
+ if (SynchronousHandler.RUN_ON_MAIN_THREAD) {
155
156
  final Object[] arr = new Object[1];
156
157
  if (mainHandler == null) {
157
158
  mainHandler = new Handler(android.os.Looper.getMainLooper());
@@ -178,8 +179,8 @@ public class VectorEditEventListener extends com.massifmaps.layers.VectorEditEve
178
179
  }
179
180
 
180
181
  @Override
181
- public VectorElementDragResult onDragEnd(final VectorElementDragInfo dragInfo) {
182
- if (MapView.RUN_ON_MAIN_THREAD) {
182
+ public @VectorElementDragResult.Value int onDragEnd(final VectorElementDragInfo dragInfo) {
183
+ if (SynchronousHandler.RUN_ON_MAIN_THREAD) {
183
184
  final Object[] arr = new Object[1];
184
185
  if (mainHandler == null) {
185
186
  mainHandler = new Handler(android.os.Looper.getMainLooper());
@@ -195,7 +196,7 @@ public class VectorEditEventListener extends com.massifmaps.layers.VectorEditEve
195
196
  }
196
197
  });
197
198
 
198
- return (VectorElementDragResult) arr[0];
199
+ return (Integer) arr[0];
199
200
  } else {
200
201
  if (listener != null) {
201
202
  return listener.onDragEnd(dragInfo);
@@ -206,8 +207,8 @@ public class VectorEditEventListener extends com.massifmaps.layers.VectorEditEve
206
207
  }
207
208
 
208
209
  @Override
209
- public VectorElementDragResult onDragMove(final VectorElementDragInfo dragInfo) {
210
- if (MapView.RUN_ON_MAIN_THREAD) {
210
+ public @VectorElementDragResult.Value int onDragMove(final VectorElementDragInfo dragInfo) {
211
+ if (SynchronousHandler.RUN_ON_MAIN_THREAD) {
211
212
  final Object[] arr = new Object[1];
212
213
  if (mainHandler == null) {
213
214
  mainHandler = new Handler(android.os.Looper.getMainLooper());
@@ -223,7 +224,7 @@ public class VectorEditEventListener extends com.massifmaps.layers.VectorEditEve
223
224
  }
224
225
  });
225
226
 
226
- return (VectorElementDragResult) arr[0];
227
+ return (Integer) arr[0];
227
228
  } else {
228
229
  if (listener != null) {
229
230
  return listener.onDragMove(dragInfo);
@@ -234,8 +235,8 @@ public class VectorEditEventListener extends com.massifmaps.layers.VectorEditEve
234
235
  }
235
236
 
236
237
  @Override
237
- public VectorElementDragResult onDragStart(final VectorElementDragInfo dragInfo) {
238
- if (MapView.RUN_ON_MAIN_THREAD) {
238
+ public @VectorElementDragResult.Value int onDragStart(final VectorElementDragInfo dragInfo) {
239
+ if (SynchronousHandler.RUN_ON_MAIN_THREAD) {
239
240
  final Object[] arr = new Object[1];
240
241
  if (mainHandler == null) {
241
242
  mainHandler = new Handler(android.os.Looper.getMainLooper());
@@ -251,7 +252,7 @@ public class VectorEditEventListener extends com.massifmaps.layers.VectorEditEve
251
252
  }
252
253
  });
253
254
 
254
- return (VectorElementDragResult) arr[0];
255
+ return (Integer) arr[0];
255
256
  } else {
256
257
  if (listener != null) {
257
258
  return listener.onDragStart(dragInfo);
@@ -3,7 +3,6 @@ package com.nativescript.massifmaps.additions2;
3
3
  import android.os.Handler;
4
4
  import android.util.Log;
5
5
 
6
- import com.nativescript.massifmaps.additions.MapView;
7
6
  import com.nativescript.massifmaps.additions.SynchronousHandler;
8
7
  import com.massifmaps.search.SearchRequest;
9
8
  import com.massifmaps.datasources.TileDataSource;
@@ -28,7 +27,7 @@ public class VectorTileSearchService extends com.massifmaps.search.VectorTileSea
28
27
  @Override
29
28
  public void run() {
30
29
  final VectorTileFeatureCollection results = that.findFeatures(request);
31
- if (MapView.RUN_ON_MAIN_THREAD) {
30
+ if (SynchronousHandler.RUN_ON_MAIN_THREAD) {
32
31
  if (mainHandler == null) {
33
32
  mainHandler = new Handler(android.os.Looper.getMainLooper());
34
33
  }
@@ -0,0 +1,60 @@
1
+ package com.nativescript.massifmaps.api;
2
+
3
+ import android.os.Handler;
4
+ import android.os.Looper;
5
+
6
+ import com.nativescript.massifmaps.additions.SynchronousHandler;
7
+
8
+ /**
9
+ * The surface API's event listener, with the thread hop JavaScript needs.
10
+ *
11
+ * The SDK emits from its render and tile threads, and NativeScript has no JavaScript runtime
12
+ * there - a director calling straight into JS from one of them fails to find a Runtime. So this
13
+ * posts onto the main looper and WAITS, the same SynchronousHandler dance every other listener in
14
+ * this plugin does. Waiting rather than posting is what lets a consuming subscription answer in
15
+ * time, and what keeps the facade's payload alive until the handler has read it.
16
+ *
17
+ * It is a Java class rather than a NativeScript subclass of the SDK's director for exactly that
18
+ * reason: the hop itself must not be JavaScript.
19
+ */
20
+ public class EventListener extends com.massifmaps.api.EventListener {
21
+
22
+ /** What the JavaScript side implements. Return true to consume, when the subscription may. */
23
+ public interface Listener {
24
+ boolean onEvent(int target, String event, int payload);
25
+ }
26
+
27
+ protected Listener listener = null;
28
+ private Handler mainHandler = null;
29
+
30
+ public EventListener(Listener listener) {
31
+ super();
32
+ this.listener = listener;
33
+ }
34
+
35
+ public void setListener(Listener listener) {
36
+ this.listener = listener;
37
+ }
38
+
39
+ @Override
40
+ public boolean onEvent(final int target, final String event, final int payload) {
41
+ final Listener current = listener;
42
+ if (current == null) {
43
+ return false;
44
+ }
45
+ if (!SynchronousHandler.RUN_ON_MAIN_THREAD) {
46
+ return current.onEvent(target, event, payload);
47
+ }
48
+ if (mainHandler == null) {
49
+ mainHandler = new Handler(Looper.getMainLooper());
50
+ }
51
+ final boolean[] result = new boolean[1];
52
+ SynchronousHandler.postAndWait(mainHandler, new Runnable() {
53
+ @Override
54
+ public void run() {
55
+ result[0] = current.onEvent(target, event, payload);
56
+ }
57
+ });
58
+ return result[0];
59
+ }
60
+ }
@@ -1,9 +1,9 @@
1
1
  package com.nativescript.massifmaps.geocoding;
2
2
 
3
+ import com.nativescript.massifmaps.additions.SynchronousHandler;
3
4
  import android.os.Handler;
4
5
  import android.util.Log;
5
6
 
6
- import com.nativescript.massifmaps.additions.MapView;
7
7
 
8
8
 
9
9
  import com.massifmaps.geocoding.GeocodingRequest;
@@ -29,7 +29,7 @@ public class GeocodingServiceAdditions {
29
29
  results = service.calculateAddresses(request);
30
30
  } catch (final Exception e) {
31
31
  e.printStackTrace();
32
- if (MapView.RUN_ON_MAIN_THREAD) {
32
+ if (SynchronousHandler.RUN_ON_MAIN_THREAD) {
33
33
  if (mainHandler == null) {
34
34
  mainHandler = new Handler(android.os.Looper.getMainLooper());
35
35
  }
@@ -46,7 +46,7 @@ public class GeocodingServiceAdditions {
46
46
  }
47
47
 
48
48
  final GeocodingResultVector fRa = results;
49
- if (MapView.RUN_ON_MAIN_THREAD) {
49
+ if (SynchronousHandler.RUN_ON_MAIN_THREAD) {
50
50
  if (mainHandler == null) {
51
51
  mainHandler = new Handler(android.os.Looper.getMainLooper());
52
52
  }
@@ -74,7 +74,7 @@ public class GeocodingServiceAdditions {
74
74
  results = service.calculateAddresses(request);
75
75
  } catch (final Exception e) {
76
76
  e.printStackTrace();
77
- if (MapView.RUN_ON_MAIN_THREAD) {
77
+ if (SynchronousHandler.RUN_ON_MAIN_THREAD) {
78
78
  if (mainHandler == null) {
79
79
  mainHandler = new Handler(android.os.Looper.getMainLooper());
80
80
  }
@@ -91,7 +91,7 @@ public class GeocodingServiceAdditions {
91
91
  }
92
92
 
93
93
  final GeocodingResultVector fRa = results;
94
- if (MapView.RUN_ON_MAIN_THREAD) {
94
+ if (SynchronousHandler.RUN_ON_MAIN_THREAD) {
95
95
  if (mainHandler == null) {
96
96
  mainHandler = new Handler(android.os.Looper.getMainLooper());
97
97
  }
@@ -2,7 +2,6 @@ package com.nativescript.massifmaps.packagemanager;
2
2
 
3
3
  import android.os.Handler;
4
4
 
5
- import com.nativescript.massifmaps.additions.MapView;
6
5
  import com.nativescript.massifmaps.additions.SynchronousHandler;
7
6
  import com.massifmaps.packagemanager.PackageErrorType;
8
7
  import com.massifmaps.packagemanager.PackageStatus;
@@ -13,7 +12,7 @@ public class PackageManagerListener extends com.massifmaps.packagemanager.Packag
13
12
  public interface Listener {
14
13
  void onPackageCancelled(String id, int version);
15
14
 
16
- void onPackageFailed(String id, int version, PackageErrorType errorType);
15
+ void onPackageFailed(String id, int version, @PackageErrorType.Value int errorType);
17
16
 
18
17
  void onPackageListFailed();
19
18
 
@@ -41,7 +40,7 @@ public class PackageManagerListener extends com.massifmaps.packagemanager.Packag
41
40
 
42
41
  @Override
43
42
  public void onPackageCancelled(final String id, final int version) {
44
- if (MapView.RUN_ON_MAIN_THREAD) {
43
+ if (SynchronousHandler.RUN_ON_MAIN_THREAD) {
45
44
  final Object[] arr = new Object[1];
46
45
  if (mainHandler == null) {
47
46
  mainHandler = new Handler(android.os.Looper.getMainLooper());
@@ -67,8 +66,9 @@ public class PackageManagerListener extends com.massifmaps.packagemanager.Packag
67
66
  }
68
67
 
69
68
  @Override
70
- public void onPackageFailed(final String id, final int version, final PackageErrorType errorType) {
71
- if (MapView.RUN_ON_MAIN_THREAD) {
69
+ public void onPackageFailed(final String id, final int version,
70
+ final @PackageErrorType.Value int errorType) {
71
+ if (SynchronousHandler.RUN_ON_MAIN_THREAD) {
72
72
  final Object[] arr = new Object[1];
73
73
  if (mainHandler == null) {
74
74
  mainHandler = new Handler(android.os.Looper.getMainLooper());
@@ -95,7 +95,7 @@ public class PackageManagerListener extends com.massifmaps.packagemanager.Packag
95
95
 
96
96
  @Override
97
97
  public void onPackageListFailed() {
98
- if (MapView.RUN_ON_MAIN_THREAD) {
98
+ if (SynchronousHandler.RUN_ON_MAIN_THREAD) {
99
99
  final Object[] arr = new Object[1];
100
100
  if (mainHandler == null) {
101
101
  mainHandler = new Handler(android.os.Looper.getMainLooper());
@@ -122,7 +122,7 @@ public class PackageManagerListener extends com.massifmaps.packagemanager.Packag
122
122
 
123
123
  @Override
124
124
  public void onPackageListUpdated() {
125
- if (MapView.RUN_ON_MAIN_THREAD) {
125
+ if (SynchronousHandler.RUN_ON_MAIN_THREAD) {
126
126
  final Object[] arr = new Object[1];
127
127
  if (mainHandler == null) {
128
128
  mainHandler = new Handler(android.os.Looper.getMainLooper());
@@ -149,7 +149,7 @@ public class PackageManagerListener extends com.massifmaps.packagemanager.Packag
149
149
 
150
150
  @Override
151
151
  public void onPackageStatusChanged(final String id, final int version, final PackageStatus status) {
152
- if (MapView.RUN_ON_MAIN_THREAD) {
152
+ if (SynchronousHandler.RUN_ON_MAIN_THREAD) {
153
153
  final Object[] arr = new Object[1];
154
154
  if (mainHandler == null) {
155
155
  mainHandler = new Handler(android.os.Looper.getMainLooper());
@@ -176,7 +176,7 @@ public class PackageManagerListener extends com.massifmaps.packagemanager.Packag
176
176
 
177
177
  @Override
178
178
  public void onPackageUpdated(final String id, final int version) {
179
- if (MapView.RUN_ON_MAIN_THREAD) {
179
+ if (SynchronousHandler.RUN_ON_MAIN_THREAD) {
180
180
  final Object[] arr = new Object[1];
181
181
  if (mainHandler == null) {
182
182
  mainHandler = new Handler(android.os.Looper.getMainLooper());
@@ -203,7 +203,7 @@ public class PackageManagerListener extends com.massifmaps.packagemanager.Packag
203
203
 
204
204
  @Override
205
205
  public void onStyleFailed(final String styleName) {
206
- if (MapView.RUN_ON_MAIN_THREAD) {
206
+ if (SynchronousHandler.RUN_ON_MAIN_THREAD) {
207
207
  final Object[] arr = new Object[1];
208
208
  if (mainHandler == null) {
209
209
  mainHandler = new Handler(android.os.Looper.getMainLooper());
@@ -230,7 +230,7 @@ public class PackageManagerListener extends com.massifmaps.packagemanager.Packag
230
230
 
231
231
  @Override
232
232
  public void onStyleUpdated(final String styleName) {
233
- if (MapView.RUN_ON_MAIN_THREAD) {
233
+ if (SynchronousHandler.RUN_ON_MAIN_THREAD) {
234
234
  final Object[] arr = new Object[1];
235
235
  if (mainHandler == null) {
236
236
  mainHandler = new Handler(android.os.Looper.getMainLooper());