diff options
author | Deepanshu Gupta <deepanshu@google.com> | 2015-08-26 20:18:47 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-08-26 20:18:47 +0000 |
commit | 9b1ac26921b9c7aaf3c43c8094d81cfabc5cc085 (patch) | |
tree | 4a23858e74646bd67babe1856813889cf8ef8cc6 /tools | |
parent | 6b7f9ae6f56375b1bd84f31206cac179e09b8146 (diff) | |
parent | 1754824c2835d6f3a17c4a2c0ab668991797fcf9 (diff) | |
download | frameworks_base-9b1ac26921b9c7aaf3c43c8094d81cfabc5cc085.zip frameworks_base-9b1ac26921b9c7aaf3c43c8094d81cfabc5cc085.tar.gz frameworks_base-9b1ac26921b9c7aaf3c43c8094d81cfabc5cc085.tar.bz2 |
am 1754824c: am c96ef952: Add documentation about hack in commit: f8ea750455 [DO NOT MERGE]
* commit '1754824c2835d6f3a17c4a2c0ab668991797fcf9':
Add documentation about hack in commit: f8ea750455 [DO NOT MERGE]
Diffstat (limited to 'tools')
-rw-r--r-- | tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java index 6ef0b79..6b54cb6 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java @@ -464,6 +464,20 @@ public final class BridgeContext extends Context { @Override public ClassLoader getClassLoader() { + // The documentation for this method states that it should return a class loader one can + // use to retrieve classes in this package. However, when called by LayoutInflater, we do + // not want the class loader to return app's custom views. + // This is so that the IDE can instantiate the custom views and also generate proper error + // messages in case of failure. This also enables the IDE to fallback to MockView in case + // there's an exception thrown when trying to inflate the custom view. + // To work around this issue, LayoutInflater is modified via LayoutLib Create tool to + // replace invocations of this method to a new method: getFrameworkClassLoader(). Also, + // the method is injected into Context. The implementation of getFrameworkClassLoader() is: + // "return getClass().getClassLoader();". This means that when LayoutInflater asks for + // the context ClassLoader, it gets only LayoutLib's ClassLoader which doesn't have + // access to the apps's custom views. + // This method can now return the right ClassLoader, which CustomViews can use to do the + // right thing. if (mClassLoader == null) { mClassLoader = new ClassLoader(getClass().getClassLoader()) { @Override |