Package icyllis.modernui.core
Class ContextWrapper
java.lang.Object
icyllis.modernui.core.Context
icyllis.modernui.core.ContextWrapper
- Direct Known Subclasses:
ContextThemeWrapper
Proxying implementation of Context that simply delegates all of its calls to
another Context. Can be subclassed to modify behavior without changing
the original Context.
-
Field Summary
Fields inherited from class icyllis.modernui.core.Context
WINDOW_SERVICE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
attachBaseContext
(Context base) Set the base context for this ContextWrapper.Returns a Resources instance for the application's environment.getSystemService
(String name) getTheme()
Return the Theme object associated with this Context.void
setTheme
(ResourceId resId) Reset the base theme for this context.Methods inherited from class icyllis.modernui.core.Context
obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes
-
Constructor Details
-
ContextWrapper
-
-
Method Details
-
attachBaseContext
Set the base context for this ContextWrapper. All calls will then be delegated to the base context. Throws IllegalStateException if a base context has already been set.- Parameters:
base
- The new base context for this wrapper.
-
getBaseContext
- Returns:
- the base context as set by the constructor or setBaseContext
-
getResources
Description copied from class:Context
Returns a Resources instance for the application's environment.Note: For a Context object, the implementation of this method should always return the same Resources object, even if a resource reload occurs.
- Specified by:
getResources
in classContext
- Returns:
- a Resources instance for the application's environment
-
setTheme
Description copied from class:Context
Reset the base theme for this context. Note that this should be called before any views are instantiated in the Context. -
getTheme
Description copied from class:Context
Return the Theme object associated with this Context.Note: For a Context object, the implementation of this method should always return the same Theme object, even if a resource reload or theme reset occurs. And the object returned by
Resources.Theme.getResources()
should be consistent withContext.getResources()
. Calling this method is not particularly fast, so it is recommended to cache it in a local variable. -
getSystemService
- Specified by:
getSystemService
in classContext
-