Package icyllis.modernui.core
Class Context
java.lang.Object
icyllis.modernui.core.Context
- Direct Known Subclasses:
Activity
,ContextWrapper
Interface for obtaining global information about the application environment.
This is an abstract class whose implementation is provided by the framework.
It allows access to application-specific resources and classes, as well as
up-calls for application-level operations such as launching activities, etc.
Note: Unless otherwise specified, all Context objects are thread-safe by simply publishing them safely.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Use withgetSystemService(String)
to retrieve aWindowManager
for accessing the system's window manager. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract Resources
Returns a Resources instance for the application's environment.abstract Object
getSystemService
(String name) abstract Resources.Theme
getTheme()
Return the Theme object associated with this Context.final TypedArray
obtainStyledAttributes
(ResourceId resId, String[] attrs) Retrieve styled attribute information in this Context's theme.final TypedArray
obtainStyledAttributes
(AttributeSet set, ResourceId defStyleAttr, ResourceId defStyleRes, String[] attrs) Retrieve styled attribute information in this Context's theme.final TypedArray
obtainStyledAttributes
(AttributeSet set, String[] attrs) Retrieve styled attribute information in this Context's theme.final TypedArray
obtainStyledAttributes
(String[] attrs) Retrieve styled attribute information in this Context's theme.abstract void
setTheme
(ResourceId resId) Reset the base theme for this context.
-
Field Details
-
WINDOW_SERVICE
Use withgetSystemService(String)
to retrieve aWindowManager
for accessing the system's window manager.- See Also:
-
-
Constructor Details
-
Context
public Context()
-
-
Method Details
-
getResources
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.
- Returns:
- a Resources instance for the application's environment
-
setTheme
Reset the base theme for this context. Note that this should be called before any views are instantiated in the Context.- Parameters:
resId
- The style resource describing the theme.
-
getTheme
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 withgetResources()
. Calling this method is not particularly fast, so it is recommended to cache it in a local variable. -
obtainStyledAttributes
Retrieve styled attribute information in this Context's theme. SeeResources.Theme.obtainStyledAttributes(String[])
for more information.- See Also:
-
obtainStyledAttributes
@NonNull public final TypedArray obtainStyledAttributes(@Nullable @StyleRes ResourceId resId, @NonNull @StyleableRes String[] attrs) Retrieve styled attribute information in this Context's theme. SeeResources.Theme.obtainStyledAttributes(ResourceId, String[])
for more information.- See Also:
-
obtainStyledAttributes
@NonNull public final TypedArray obtainStyledAttributes(@Nullable AttributeSet set, @NonNull @StyleableRes String[] attrs) Retrieve styled attribute information in this Context's theme. SeeResources.Theme.obtainStyledAttributes(AttributeSet, ResourceId, ResourceId, String[])
for more information.- See Also:
-
obtainStyledAttributes
@NonNull public final TypedArray obtainStyledAttributes(@Nullable AttributeSet set, @Nullable @AttrRes ResourceId defStyleAttr, @Nullable @StyleRes ResourceId defStyleRes, @NonNull @StyleableRes String[] attrs) Retrieve styled attribute information in this Context's theme. SeeResources.Theme.obtainStyledAttributes(AttributeSet, ResourceId, ResourceId, String[])
for more information.- See Also:
-
getSystemService
-