Permalink
Browse files

fixes

  • Loading branch information...
1 parent dc03678 commit 8dff626e65fc34c73cbd3098aef766887d48d7b3 @mateuszmackowiak committed Apr 27, 2012
@@ -117,12 +117,12 @@ package pl.mateuszmackowiak.nativeANE.alert
* @see http://www.liquid-photo.com/2011/10/28/native-extension-for-adobe-air-and-ios-101/
* @see pl.mateuszmackowiak.nativeANE.alert.NativeAlertEvent
*/
- public function NativeAlert(theme:uint=NaN)
+ public function NativeAlert(theme:int=NaN)
{
if(Capabilities.os.toLowerCase().indexOf("linux")>-1)
isAndroid = true;
- if(!isNaN(theme))
+ if(!isNaN(theme) && theme>-1)
_theme = theme;
else
_theme = _defaultTheme;
@@ -168,10 +168,12 @@ package pl.mateuszmackowiak.nativeANE.alert
*/
public function set closeHandler(value:Function):void
{
+
if(hasEventListener(NativeDialogEvent.CLOSED))
removeEventListener(NativeDialogEvent.CLOSED,_closeHandler);
- addEventListener(NativeDialogEvent.CLOSED,_closeHandler);
_closeHandler = value;
+ if(value!=null)
+ addEventListener(NativeDialogEvent.CLOSED,_closeHandler);
}
/**
* @private
@@ -432,9 +434,9 @@ package pl.mateuszmackowiak.nativeANE.alert
if(Capabilities.os.indexOf("Win")>-1)
level--;
dispatchEvent(new NativeDialogEvent(NativeDialogEvent.CLOSED,level.toString()));
- if(closeHandler!=null){
- removeEventListener(NativeDialogEvent.CLOSED,closeHandler);
- closeHandler = null;
+ if(_closeHandler!=null){
+ removeEventListener(NativeDialogEvent.CLOSED,_closeHandler);
+ _closeHandler = null;
}
(event.target as ExtensionContext).removeEventListener( StatusEvent.STATUS, onAlertHandler );
}else{
@@ -117,7 +117,7 @@ package pl.mateuszmackowiak.nativeANE.dialogs
return;
}
- if(!isNaN(theme))
+ if(!isNaN(theme) && theme>-1)
_theme = theme;
else
_theme = _defaultTheme;
@@ -165,7 +165,7 @@ package pl.mateuszmackowiak.nativeANE.dialogs
_selectedIndex = checkedLabel;
try{
if(isAndroid)
- context.call("showListDialog","create",_title,_buttons,labels,checkedLabel,_cancelable,_theme);
+ context.call("showListDialog","show",_title,_buttons,labels,checkedLabel,_cancelable,_theme);
else
context.call("show",_title,_message,_buttons,labels,checkedLabel);
return true;
@@ -243,17 +243,17 @@ package pl.mateuszmackowiak.nativeANE.dialogs
* list of selected labels
*/
public function get selectedLabels():Vector.<String>{
- var lab:Vector.<String> = new Vector.<String>();
+ var labels:Vector.<String> = new Vector.<String>();
if(_list!==null && _list.length>0){
for each (var obj:Object in _list)
{
if(obj.selected == true)
- lab.push(obj.label);
+ labels.push(obj.label);
}
- if(lab.length>0 && _selectedIndex>-1)
- lab.push(_list[_selectedIndex].label);
+ if(labels.length>0 && _selectedIndex>-1)
+ labels.push(_list[_selectedIndex].label);
}
- return lab;
+ return labels;
}
/**
@@ -296,7 +296,7 @@ package pl.mateuszmackowiak.nativeANE.dialogs
/**
- * if the dialog is showing
+ * if the dialog is showing (only Android)
*/
public function isShowing():Boolean{
if(context){
@@ -520,9 +520,12 @@ package pl.mateuszmackowiak.nativeANE.dialogs
{
_isShowing = false;
try{
- context.dispose();
- context.removeEventListener(StatusEvent.STATUS, onStatus);
- return true;
+ if(context){
+ context.dispose();
+ context.removeEventListener(StatusEvent.STATUS, onStatus);
+ context = null;
+ return true;
+ }
}catch(e:Error){
showError("Error calling dispose method "+e.message,e.errorID);
}
@@ -581,31 +584,14 @@ package pl.mateuszmackowiak.nativeANE.dialogs
{
try{
if(event.code == NativeDialogEvent.CLOSED){
- if(dispatchEvent(new NativeDialogEvent(NativeDialogEvent.CLOSED,event.level))){
- trace("dismiss");
- if(isAndroid){
- dismiss();
- }
- _isShowing = false;
- }
+ dispatchEvent(new NativeDialogEvent(NativeDialogEvent.CLOSED,event.level));
}else if(event.code == NativeDialogEvent.CANCELED){
- const e2:Event = new NativeDialogEvent(NativeDialogEvent.CANCELED,event.level);
- if(dispatchEvent(e2)){
- trace("dismiss");
- if(isAndroid){
- dismiss();
- }
- _isShowing = false;
- }
+ new NativeDialogEvent(NativeDialogEvent.CANCELED,event.level);
+
}else if(event.code == NativeDialogEvent.OPENED){
- if(dispatchEvent(new NativeDialogEvent(NativeDialogEvent.OPENED,""))){
- if(isAndroid){
- context.call("showListDialog","show");
- }
- _isShowing = true;
- }
+ dispatchEvent(new NativeDialogEvent(NativeDialogEvent.OPENED,""));
}else if(event.code == NativeDialogListEvent.LIST_CHANGE){
var index:int = -1;
if(event.level.indexOf("_")>-1){
@@ -97,7 +97,7 @@ package pl.mateuszmackowiak.nativeANE.dialogs
* @see pl.mateuszmackowiak.nativeANE.NativeDialogEvent
* @see flash.events.ErrorEvent
*/
- public function NativeTextInputDialog(theme:uint=NaN)
+ public function NativeTextInputDialog(theme:int=-1)
{
if(Capabilities.os.toLowerCase().indexOf("linux")>-1)
isAndroid = true;
@@ -107,7 +107,7 @@ package pl.mateuszmackowiak.nativeANE.dialogs
trace("NativeTextInputDialog is not supported on this platform");
return;
}
- if(!isNaN(theme))
+ if(!isNaN(theme) && theme>-1)
_theme = theme;
else
_theme = _defaultTheme;
@@ -235,8 +235,20 @@ package pl.mateuszmackowiak.nativeANE.dialogs
}
-
-
+ /**
+ * helper method to get the text input by name
+ */
+ public function getTextInputByName(name:String):NativeTextField
+ {
+ if(_textInputs && _textInputs.length>0){
+ for each (var t:NativeTextField in _textInputs)
+ {
+ if(t.name ==name)
+ return t;
+ }
+ }
+ return null;
+ }
/**
* The title of the dialog
@@ -96,8 +96,10 @@ package pl.mateuszmackowiak.nativeANE.progress
private var _title:String="";
private var _message:String = "";
private var _style:uint = STYLE_SPINNER;
- private var _androidTheme:int = -1;
- private var _iosTheme:int = -1;
+
+ private var _androidTheme:int = NaN;
+ private var _iosTheme:int = NaN;
+
private var _maxProgress:int = 100;
private var _indeterminate:Boolean = false;
private var _isShowing:Boolean=false;
@@ -115,7 +117,7 @@ package pl.mateuszmackowiak.nativeANE.progress
* @throws Error if not supported or native files not packaged
* @playerversion 3.0
*/
- public function NativeProgress(style:int = 0x00000000,androidTheme:uint=NaN,iosTheme:uint=NaN)
+ public function NativeProgress(style:int = 0x00000000,AndroidTheme:int=-1,IOSTheme:int=-1)
{
if(Capabilities.os.toLowerCase().indexOf("linux")>-1)
isAndroid = true;
@@ -129,14 +131,16 @@ package pl.mateuszmackowiak.nativeANE.progress
if(style == STYLE_HORIZONTAL || style==STYLE_SPINNER)
_style = style;
- if(!isNaN(androidTheme))
- _androidTheme = androidTheme;
+ if(!isNaN(AndroidTheme) && AndroidTheme>-1)
+ _androidTheme = AndroidTheme;
else
_androidTheme = _defaultAndroidTheme;
- if(!isNaN(iosTheme))
- _iosTheme = iosTheme;
+
+ if(!isNaN(IOSTheme) && IOSTheme>-1)
+ _iosTheme = IOSTheme;
else
_iosTheme = _defaultIOSTheme;
+
try{
context = ExtensionContext.createExtensionContext(EXTENSION_ID, "ProgressContext");
context.addEventListener(StatusEvent.STATUS, onStatus);
@@ -191,7 +195,7 @@ package pl.mateuszmackowiak.nativeANE.progress
return true;
}
else if(isIOS){
- context.call(showProgressPopup,_progress,null,STYLE_HORIZONTAL,_title,_message,cancleble,true);
+ context.call(showProgressPopup,_progress,null,STYLE_HORIZONTAL,_title,_message,cancleble,true,_iosTheme);
_isShowing = true;
return true;
}
@@ -454,7 +458,7 @@ package pl.mateuszmackowiak.nativeANE.progress
* the theme of the NativeProgress
* (if isShowing will be ignored until next show)
*/
- public function set androidTheme(value:int):void
+ public function set androidTheme(value:uint):void
{
if(!isNaN(value))
_androidTheme = value;
@@ -464,7 +468,7 @@ package pl.mateuszmackowiak.nativeANE.progress
/**
* @private
*/
- public function get androidTheme():int
+ public function get androidTheme():uint
{
return _androidTheme;
}
@@ -572,29 +576,29 @@ package pl.mateuszmackowiak.nativeANE.progress
* the andorid default theme of all NativeProges dialogs
* @default pl.mateuszmackowiak.nativeANE.progress.NativeProgess#DEFAULT_THEME
*/
- public static function set defaultAndroidTheme(value:int):void
+ public static function set defaultAndroidTheme(value:uint):void
{
_defaultAndroidTheme = value;
}
/**
* @private
*/
- public static function get defaultAndroidTheme():int
+ public static function get defaultAndroidTheme():uint
{
return _defaultAndroidTheme;
}
/**
* the IOS default theme of all NativeProges dialogs
* @default pl.mateuszmackowiak.nativeANE.progress.NativeProgess#DEFAULT_THEME
*/
- public static function set defaultIOSTheme(value:int):void
+ public static function set defaultIOSTheme(value:uint):void
{
_defaultIOSTheme = value;
}
/**
* @private
*/
- public static function get defaultIOSTheme():int
+ public static function get defaultIOSTheme():uint
{
return _defaultIOSTheme;
}
@@ -46,15 +46,16 @@ package pl.mateuszmackowiak.nativeANE.properties
/**
* IOS / Android
*/
- public static const UID:String = Capabilities.os.toLowerCase().indexOf("iph")>-1?'UDID':'UID';
+ public static const UID:String = (Capabilities.os.toLowerCase().indexOf("iph")>-1)?'UDID':'UID';
+
/**
* IOS / Android
*/
public static const NAME:String = 'name';
/**
- * IOS
+ * IOS / Android
*/
public static const MAC_ADRESS:String = 'MACAdress';
@@ -28,7 +28,7 @@ public FREObject call(FREContext context, FREObject[] args) {
try{
function = args[0].getAsString();
- if(function.equals("create")){
+ if(function.equals("show")){
title = args[1].getAsString();
if(args[2] instanceof FREArray)
@@ -52,10 +52,8 @@ else if(args[4]!=null)
mDialog = createPopup(context,title,buttons,choices,checkedItems,checkedItem,cancelable,theme);
context.dispatchStatusEventAsync(NativeExtension.OPENED,"");
-
- }else if(function.equals("show") && mDialog!=null){
mDialog.show();
-
+
}else if(function.equals("hide")){
if(mDialog!=null && mDialog.isShowing()){
context.dispatchStatusEventAsync(NativeExtension.CANCELED,String.valueOf(-1));
@@ -146,7 +144,8 @@ public AlertDialog createPopup(FREContext context, String title, String buttons[
public void onCancel(DialogInterface dialog)
{
Log.e("List Dialog","onCancle");
- context.dispatchStatusEventAsync(NativeExtension.CANCELED,String.valueOf(-1));
+ context.dispatchStatusEventAsync(NativeExtension.CANCELED,String.valueOf(-1));
+ dialog.dismiss();
}
}
private class ConfitmListener implements DialogInterface.OnClickListener{
@@ -160,7 +159,8 @@ public void onCancel(DialogInterface dialog)
public void onClick(DialogInterface dialog,int id)
{
Log.e("List Dialog","onClicked");
- context.dispatchStatusEventAsync(NativeExtension.CLOSED,String.valueOf(Math.abs(id-1)));
+ context.dispatchStatusEventAsync(NativeExtension.CLOSED,String.valueOf(Math.abs(id-1)));
+ dialog.dismiss();
}
}
@@ -175,7 +175,7 @@ public void onClick(DialogInterface dialog,int id)
@Override
public void onClick(DialogInterface dialog,int id)
{
- context.dispatchStatusEventAsync(NativeExtension.LIST_CHANGE,String.valueOf(id));
+ context.dispatchStatusEventAsync(NativeExtension.LIST_CHANGE,String.valueOf(id));
}
}
Oops, something went wrong.

0 comments on commit 8dff626

Please sign in to comment.