OSDN Git Service

Make Context.getClassLoader() work.
authorDeepanshu Gupta <deepanshu@google.com>
Tue, 19 May 2015 01:47:07 +0000 (18:47 -0700)
committerDeepanshu Gupta <deepanshu@google.com>
Wed, 20 May 2015 02:56:20 +0000 (19:56 -0700)
commitf8ea750455eec81e4e6d877b3e18e29a86d4ec95
tree98759198fabb789eaa05ccd8c893d4dfaa64d3fc
parent21b564573327b1ed2f7e06146b8a01c47ede3089
Make Context.getClassLoader() work.

Context.getClassLoader() is used by the LayoutInflater and can be used
by custom views. However, when called from the LayoutInflater, this
needs to return only the Framework classes. This is so that the IDE gets
a chance to instantiate the custom views, which helps in better error
reporting and better fallback in case of exceptions, like MockView.

To workaround this need of the same method returning different results
based on where it's called from, the method call in LayoutInflater is
renamed to getFrameworkClassLoader() and the new method is injected in
Context. The implementation of getFrameworkClassLoader() maintains the
existing behaviour of getClassLoader().

Context.getClassLoader() is now modified to return classes from both
Framework and the app namespace.

Also, update the list of packages to search for Framework views.

Change-Id: I1a6be4aa1fc5c1c5520b5440a348a52f10b6eb3b
tools/layoutlib/bridge/src/android/view/BridgeInflater.java
tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java
tools/layoutlib/create/src/com/android/tools/layoutlib/create/AsmAnalyzer.java
tools/layoutlib/create/src/com/android/tools/layoutlib/create/AsmGenerator.java
tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java
tools/layoutlib/create/src/com/android/tools/layoutlib/create/ICreateInfo.java
tools/layoutlib/create/src/com/android/tools/layoutlib/create/InjectMethodRunnables.java [new file with mode: 0644]
tools/layoutlib/create/src/com/android/tools/layoutlib/create/InjectMethodsAdapter.java [new file with mode: 0644]
tools/layoutlib/create/src/com/android/tools/layoutlib/create/ReplaceMethodCallsAdapter.java
tools/layoutlib/create/tests/com/android/tools/layoutlib/create/AsmGeneratorTest.java