flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmcl...@apache.org
Subject git commit: [flex-sdk] [refs/heads/develop] - FLEX-33836 lazy loading of resource files give performance improvement (esp mobile)
Date Sun, 29 Dec 2013 06:38:32 GMT
Updated Branches:
  refs/heads/develop b0e208c92 -> edd6e20f5


FLEX-33836 lazy loading of resource files give performance improvement (esp mobile)


Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/edd6e20f
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/edd6e20f
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/edd6e20f

Branch: refs/heads/develop
Commit: edd6e20f5b04e41c054877f5798141119c02afc1
Parents: b0e208c
Author: Justin Mclean <jmclean@apache.org>
Authored: Sun Dec 29 17:38:04 2013 +1100
Committer: Justin Mclean <jmclean@apache.org>
Committed: Sun Dec 29 17:38:04 2013 +1100

----------------------------------------------------------------------
 .../src/mx/resources/ResourceManagerImpl.as     | 74 ++++++++++++++++++--
 1 file changed, 70 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/edd6e20f/frameworks/projects/framework/src/mx/resources/ResourceManagerImpl.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/framework/src/mx/resources/ResourceManagerImpl.as b/frameworks/projects/framework/src/mx/resources/ResourceManagerImpl.as
index 9c21ca8..07c6d95 100644
--- a/frameworks/projects/framework/src/mx/resources/ResourceManagerImpl.as
+++ b/frameworks/projects/framework/src/mx/resources/ResourceManagerImpl.as
@@ -414,16 +414,20 @@ public class ResourceManagerImpl extends EventDispatcher implements
IResourceMan
                 "' for locale '" + locale + "'.");
         }
         
-        // Create an instance of the bundle class.
-        resourceBundle = ResourceBundle(new bundleClass());
+        // Create a proxy
+        var proxy:ResourceBundleProxy = new ResourceBundleProxy();
+        
+		proxy.bundleClass = bundleClass;
+		proxy.useWeakReference = useWeakReference;
 
         // In case we just created a ResourceBundle from a Flex 2 SWC,
         // set its locale and bundleName, because the old constructor
         // didn't used to do this.
-        ResourceBundle(resourceBundle)._locale = locale;
-        ResourceBundle(resourceBundle)._bundleName = bundleName;
+        proxy.locale = locale;
+        proxy.bundleName = bundleName;
                 
         // Add that resource bundle instance to the ResourceManager.
+        resourceBundle = proxy;
         addResourceBundle(resourceBundle, useWeakReference);
         
         return resourceBundle;
@@ -707,6 +711,10 @@ public class ResourceManagerImpl extends EventDispatcher implements IResourceMan
                 }
             }
         }
+        else if (bundleObject is ResourceBundleProxy)
+        {
+        	bundle = loadResourceBundleProxy(ResourceBundleProxy(bundleObject));
+        }
         else 
         {
             bundle = bundleObject as IResourceBundle;
@@ -715,6 +723,17 @@ public class ResourceManagerImpl extends EventDispatcher implements IResourceMan
         return bundle;
     }
     
+    private function loadResourceBundleProxy(proxy:ResourceBundleProxy):ResourceBundle {
+    	var proxyClass:Class = proxy.bundleClass;
+        var resourceBundle:ResourceBundle = ResourceBundle(new proxyClass());
+   		resourceBundle._locale = proxy.locale;
+    	resourceBundle._bundleName = proxy.bundleName;
+    	
+    	addResourceBundle(resourceBundle, proxy.useWeakReference);
+    	
+    	return resourceBundle;
+    }
+    
     /**
      *  @copy mx.resources.IResourceManager#removeResourceBundle()
      *  
@@ -851,6 +870,10 @@ public class ResourceManagerImpl extends EventDispatcher implements IResourceMan
                     }
                 }
             }
+            else if (bundleObject is ResourceBundleProxy)
+            {
+        		bundle = loadResourceBundleProxy(ResourceBundleProxy(bundleObject));
+            }
             else 
             {
                 bundle = bundleObject as IResourceBundle;
@@ -1161,6 +1184,7 @@ import flash.events.EventDispatcher;
 import mx.events.ModuleEvent;
 import mx.events.ResourceEvent;
 import mx.modules.IModuleInfo;
+import mx.resources.IResourceBundle;
 import mx.resources.IResourceModule;
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -1322,3 +1346,45 @@ class ResourceEventDispatcher extends EventDispatcher
         dispatchEvent(resourceEvent);
     }
 }
+
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Helper class: ResourceBundleProxy
+//
+////////////////////////////////////////////////////////////////////////////////
+
+/**
+ *  @private
+ */
+class ResourceBundleProxy implements IResourceBundle
+{
+	public var bundleClass:Class;
+	public var useWeakReference:Boolean;
+	
+	private var _bundleName:String;
+	private var _locale:String;
+ 
+    public function ResourceBundleProxy()
+	{
+	}
+       
+	public function get bundleName():String {
+		return _bundleName;
+	}
+	
+	public function set bundleName(value:String):void {
+		_bundleName = value;
+	}
+       
+    public function get content():Object {
+    	return null;
+    }
+        
+	public function get locale():String {
+		return _locale;
+	}
+	
+	public function set locale(value:String):void {
+		_locale = value;
+	}
+}


Mime
View raw message