Update removePopUp method of PopUpUtil to accept a class or an instance.

This commit is contained in:
Ghazi Triki 2017-02-22 11:21:11 +01:00
parent ad045e95e8
commit 605b47c1af

View File

@ -28,8 +28,13 @@ package org.bigbluebutton.core {
import mx.managers.PopUpManager;
import mx.managers.SystemManager;
import org.as3commons.logging.api.ILogger;
import org.as3commons.logging.api.getClassLogger;
public final class PopUpUtil {
private static const LOGGER:ILogger = getClassLogger(PopUpUtil);
private static var popUpDict:Dictionary = new Dictionary(true);
public static function createNonModelPopUp(parent:DisplayObject, className:Class, center:Boolean = true):IFlexDisplayObject {
@ -46,14 +51,17 @@ package org.bigbluebutton.core {
return null;
}
public static function removePopUp(className:Class):void {
var fqcn:String = getQualifiedClassName(className);
public static function removePopUp(classOrInstance:*):void {
var fqcn:String = getQualifiedClassName(classOrInstance);
if (popUpDict[fqcn] != undefined) {
PopUpManager.removePopUp(popUpDict[fqcn])
delete popUpDict[fqcn];
LOGGER.debug("Removed PopUp with type [{0}]", [fqcn]);
}
}
private static function checkPopUpExists(className:Class):Boolean {
LOGGER.debug("Checking if [{0}] exists as a PopUp", [className]);
var systemManager:SystemManager = FlexGlobals.topLevelApplication.systemManager;
var childList:IChildList = systemManager.rawChildren;
@ -61,10 +69,11 @@ package org.bigbluebutton.core {
var childObject:IUIComponent = childList.getChildAt(i) as IUIComponent;
// PopUp already exists
if (childObject is className && childObject.isPopUp) {
LOGGER.debug("PopUp with type [{0}] found", [className]);
return true;
}
}
LOGGER.debug("No PopUp with type [{0}] not found", [className]);
return false;
}
@ -74,6 +83,9 @@ package org.bigbluebutton.core {
PopUpManager.centerPopUp(popUp)
}
popUpDict[getQualifiedClassName(className)] = popUp;
LOGGER.debug("Created PopUp with type [{0}]", [className]);
return popUp;
}
}