Returns the last bitmap capture of the mapView
-Android Only.
Android Only.
*/ public function scrollBy(x:Number, y:Number, animates:Boolean = false):void { - if (!safetyCheck()) return; GoogleMapsANEContext.context.call("scrollBy", x, y, animates); } @@ -302,7 +270,6 @@ public class GoogleMapsANE extends EventDispatcher { * */ public function set mapType(value:uint):void { - if (!safetyCheck()) return; GoogleMapsANEContext.context.call("setMapType", value); } @@ -311,7 +278,6 @@ public class GoogleMapsANE extends EventDispatcher { * */ public function showUserLocation():void { - if (!safetyCheck()) return; GoogleMapsANEContext.context.call("showUserLocation"); } @@ -327,7 +293,6 @@ public class GoogleMapsANE extends EventDispatcher { * */ public function capture(x:int = 0, y:int = 0, width:int = 0, height:int = 0):void { - if (!safetyCheck()) return; var ret:* = GoogleMapsANEContext.context.call("capture", x, y, width, height) as BitmapData; if (ret is ANEError) throw ret as ANEError; } @@ -336,7 +301,6 @@ public class GoogleMapsANE extends EventDispatcher { *Returns the last bitmap capture of the mapView
*/ public function getCapture():BitmapData { - if (!safetyCheck()) return null; var ret:* = GoogleMapsANEContext.context.call("getCapture") as BitmapData; if (ret is ANEError) throw ret as ANEError; return ret; @@ -347,7 +311,6 @@ public class GoogleMapsANE extends EventDispatcher { * */ public function requestPermissions():void { - if (!safetyCheck()) return; GoogleMapsANEContext.context.call("requestPermissions"); } @@ -378,7 +341,6 @@ public class GoogleMapsANE extends EventDispatcher { */ public function set viewPort(value:Rectangle):void { _viewPort = value; - if (!safetyCheck()) return; GoogleMapsANEContext.context.call("setViewPort", _viewPort); } @@ -388,7 +350,6 @@ public class GoogleMapsANE extends EventDispatcher { * */ public function showInfoWindow(id:String):void { - if (!safetyCheck()) return; GoogleMapsANEContext.context.call("showInfoWindow", id); } @@ -398,7 +359,6 @@ public class GoogleMapsANE extends EventDispatcher { * */ public function hideInfoWindow(id:String):void { - if (!safetyCheck()) return; GoogleMapsANEContext.context.call("hideInfoWindow", id); } @@ -409,7 +369,6 @@ public class GoogleMapsANE extends EventDispatcher { * */ public function set style(json:String):void { - if (!safetyCheck()) return; GoogleMapsANEContext.context.call("setStyle", json); } @@ -419,7 +378,6 @@ public class GoogleMapsANE extends EventDispatcher { * Ignored on Apple Maps */ public function set buildingsEnabled(value:Boolean):void { - if (!safetyCheck()) return; GoogleMapsANEContext.context.call("setBuildingsEnabled", value); } @@ -428,8 +386,7 @@ public class GoogleMapsANE extends EventDispatcher { * * Ignored on Apple Maps */ - public function set trafficEnabled(value:Boolean):void { - if (!safetyCheck()) return; + public function set trafficEnabled(value:Boolean):void { GoogleMapsANEContext.context.call("setTrafficEnabled", value); } @@ -438,8 +395,7 @@ public class GoogleMapsANE extends EventDispatcher { * * Ignored on Apple Maps */ - public function set minZoom(value:Number):void { - if (!safetyCheck()) return; + public function set minZoom(value:Number):void { GoogleMapsANEContext.context.call("setMinZoom", value); } @@ -448,8 +404,7 @@ public class GoogleMapsANE extends EventDispatcher { * * Ignored on Apple Maps */ - public function set maxZoom(value:Number):void { - if (!safetyCheck()) return; + public function set maxZoom(value:Number):void { GoogleMapsANEContext.context.call("setMaxZoom", value); } @@ -458,16 +413,14 @@ public class GoogleMapsANE extends EventDispatcher { * * Ignored on Apple Maps */ - public function set indoorEnabled(value:Boolean):void { - if (!safetyCheck()) return; + public function set indoorEnabled(value:Boolean):void { GoogleMapsANEContext.context.call("setIndoorEnabled", value); } /** * Enables or disables the my-location layer. */ - public function set myLocationEnabled(value:Boolean):void { - if (!safetyCheck()) return; + public function set myLocationEnabled(value:Boolean):void { GoogleMapsANEContext.context.call("setMyLocationEnabled", value); } @@ -477,7 +430,6 @@ public class GoogleMapsANE extends EventDispatcher { * returns null on Apple Maps */ public function get projection():Projection { - if (!safetyCheck()) return null; return _projection; } @@ -487,7 +439,6 @@ public class GoogleMapsANE extends EventDispatcher { * */ public function set animationDuration(value:int):void { - if (!safetyCheck()) return; GoogleMapsANEContext.context.call("setAnimationDuration", value); } @@ -497,9 +448,7 @@ public class GoogleMapsANE extends EventDispatcher { * */ public function reverseGeocodeLocation(coordinate:Coordinate):void { - if (_isInited && !GoogleMapsANEContext.isDisposed) { - GoogleMapsANEContext.context.call("reverseGeocodeLocation", coordinate); - } + GoogleMapsANEContext.context.call("reverseGeocodeLocation", coordinate); } /** @@ -508,38 +457,7 @@ public class GoogleMapsANE extends EventDispatcher { * */ public function forwardGeocodeLocation(addressString:String):void { - if (_isInited && !GoogleMapsANEContext.isDisposed) { - GoogleMapsANEContext.context.call("forwardGeocodeLocation", addressString); - } - } - - /** - * - * @return whether we have inited the Google Maps API - * - */ - public function get isInited():Boolean { - return _isInited; - } - - /** - * - * @return whether we have inited the mapView - * - */ - public function get isMapInited():Boolean { - return _isMapInited; - } - - /** - * This method is omitted from the output. * * @private - */ - private function safetyCheck():Boolean { - if (!_isInited && _isMapInited || GoogleMapsANEContext.isDisposed) { - trace("You need to init first"); - return false; - } - return true; + GoogleMapsANEContext.context.call("forwardGeocodeLocation", addressString); } //noinspection JSMethodCanBeStatic diff --git a/native_extension/src/com/tuarua/GoogleMapsANEContext.as b/native_extension/src/com/tuarua/GoogleMapsANEContext.as index 40aad69..d1d11f6 100644 --- a/native_extension/src/com/tuarua/GoogleMapsANEContext.as +++ b/native_extension/src/com/tuarua/GoogleMapsANEContext.as @@ -30,7 +30,6 @@ public class GoogleMapsANEContext { internal static const NAME:String = "GoogleMapsANE"; internal static const TRACE:String = "TRACE"; private static var _context:ExtensionContext; - private static var _isDisposed:Boolean; private static var argsAsJSON:Object; public static var markers:Dictionary = new Dictionary(); public static var circles:Dictionary = new Dictionary(); @@ -45,13 +44,9 @@ public class GoogleMapsANEContext { if (_context == null) { try { _context = ExtensionContext.createExtensionContext("com.tuarua." + NAME, null); - if (_context == null) { - throw new Error("ANE " + NAME + " not created properly. Future calls will fail."); - } _context.addEventListener(StatusEvent.STATUS, gotEvent); - _isDisposed = false; } catch (e:Error) { - trace("[" + NAME + "] ANE not loaded properly. Future calls will fail."); + throw new Error("ANE " + NAME + " not created properly. Future calls will fail."); } } return _context; @@ -67,7 +62,7 @@ public class GoogleMapsANEContext { try { argsAsJSON = JSON.parse(event.code); var coordinate:Coordinate = new Coordinate(argsAsJSON.latitude, argsAsJSON.longitude); - GoogleMapsANE.mapView.dispatchEvent(new GoogleMapsEvent(event.level, coordinate)); + GoogleMaps.mapView.dispatchEvent(new GoogleMapsEvent(event.level, coordinate)); } catch (e:Error) { trace(e.message); } @@ -85,7 +80,7 @@ public class GoogleMapsANEContext { case GoogleMapsEvent.ON_LOADED: case GoogleMapsEvent.ON_CAMERA_IDLE: case GoogleMapsEvent.ON_BITMAP_READY: - GoogleMapsANE.mapView.dispatchEvent(new GoogleMapsEvent(event.level, event.code)); + GoogleMaps.mapView.dispatchEvent(new GoogleMapsEvent(event.level, event.code)); break; case GoogleMapsEvent.DID_END_DRAGGING: try { @@ -96,7 +91,7 @@ public class GoogleMapsANEContext { var marker:Marker = markers[id] as Marker; marker.coordinate.latitude = latitude; marker.coordinate.longitude = longitude; - GoogleMapsANE.mapView.dispatchEvent(new GoogleMapsEvent(event.level, argsAsJSON)); + GoogleMaps.mapView.dispatchEvent(new GoogleMapsEvent(event.level, argsAsJSON)); } catch (e:Error) { trace(e.message); } @@ -105,7 +100,7 @@ public class GoogleMapsANEContext { case GoogleMapsEvent.ON_CAMERA_MOVE_STARTED: try { argsAsJSON = JSON.parse(event.code); - GoogleMapsANE.mapView.dispatchEvent(new GoogleMapsEvent(event.level, argsAsJSON)); + GoogleMaps.mapView.dispatchEvent(new GoogleMapsEvent(event.level, argsAsJSON)); } catch (e:Error) { trace(e.message); } @@ -113,7 +108,7 @@ public class GoogleMapsANEContext { case LocationEvent.LOCATION_UPDATED: try { argsAsJSON = JSON.parse(event.code); - GoogleMapsANE.mapView.dispatchEvent(new LocationEvent(event.level, + GoogleMaps.mapView.dispatchEvent(new LocationEvent(event.level, new Coordinate(argsAsJSON.latitude, argsAsJSON.longitude))); } catch (e:Error) { trace(e.message); @@ -122,7 +117,7 @@ public class GoogleMapsANEContext { case LocationEvent.ON_ADDRESS_LOOKUP: try { argsAsJSON = JSON.parse(event.code); - GoogleMapsANE.mapView.dispatchEvent(new LocationEvent(event.level, + GoogleMaps.mapView.dispatchEvent(new LocationEvent(event.level, new Coordinate(argsAsJSON.latitude, argsAsJSON.longitude), new Address( argsAsJSON.formattedAddress, @@ -137,12 +132,12 @@ public class GoogleMapsANEContext { } break; case LocationEvent.ON_ADDRESS_LOOKUP_ERROR: - GoogleMapsANE.mapView.dispatchEvent(new LocationEvent(event.level, null, null, event.code)); + GoogleMaps.mapView.dispatchEvent(new LocationEvent(event.level, null, null, event.code)); break; case PermissionEvent.ON_PERMISSION_STATUS: try { argsAsJSON = JSON.parse(event.code); - GoogleMapsANE.mapView.dispatchEvent(new PermissionEvent(event.level, argsAsJSON)); + GoogleMaps.mapView.dispatchEvent(new PermissionEvent(event.level, argsAsJSON)); } catch (e:Error) { trace(e.message); } @@ -151,18 +146,11 @@ public class GoogleMapsANEContext { } public static function dispose():void { - if (!_context) { - return; - } - _isDisposed = true; + if (!_context) return; trace("[" + NAME + "] Unloading ANE..."); _context.removeEventListener(StatusEvent.STATUS, gotEvent); _context.dispose(); _context = null; } - - public static function get isDisposed():Boolean { - return _isDisposed; - } } } diff --git a/native_extension/src/com/tuarua/fre/ANEUtils.as b/native_extension/src/com/tuarua/fre/ANEUtils.as index 5ccf7f2..deb9d78 100644 --- a/native_extension/src/com/tuarua/fre/ANEUtils.as +++ b/native_extension/src/com/tuarua/fre/ANEUtils.as @@ -16,10 +16,13 @@ */ package com.tuarua.fre { +import avmplus.DescribeTypeJSON; + import flash.utils.describeType; import flash.utils.getDefinitionByName; import flash.utils.getQualifiedClassName; +/** @private */ public class ANEUtils { public function ANEUtils() { } @@ -32,72 +35,62 @@ public class ANEUtils { return Class(getDefinitionByName(getQualifiedClassName(obj))); } - public static function getClassProps(clz:*):Vector.