Package icyllis.modernui
Class ModernUI
java.lang.Object
icyllis.modernui.core.Context
icyllis.modernui.app.Activity
icyllis.modernui.ModernUI
- All Implemented Interfaces:
LifecycleOwner,AutoCloseable
The core class of Modern UI.
-
Field Summary
FieldsFields inherited from class icyllis.modernui.core.Context
WINDOW_SERVICE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()static ModernUIGet Modern UI instance.Returns the Lifecycle of the provider.getResourceChannel(String namespace, String path) Returns a Resources instance for the application's environment.getResourceStream(String namespace, String path) static LocaleGet the default or preferred locale set by user.static TypefaceGet the default or preferred typeface set by user.getTheme()Return the Theme object associated with this Context.Get the view manager of the application window (i.e.booleanWhether to enable RTL support, it should always be true.protected LocaleGet the default or preferred locale set by user.protected TypefaceGet the default or preferred typeface set by user.voidRuns the Modern UI with the default application setups.voidsetTheme(ResourceId resId) Reset the base theme for this context.Methods inherited from class icyllis.modernui.app.Activity
getSystemService, getToastManagerMethods inherited from class icyllis.modernui.core.Context
obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes
-
Field Details
-
ID
- See Also:
-
NAME_CPT
- See Also:
-
props
-
-
Constructor Details
-
ModernUI
public ModernUI()
-
-
Method Details
-
getInstance
Get Modern UI instance.- Returns:
- the Modern UI
-
run
Runs the Modern UI with the default application setups. This method is only called by themain()on the main thread. -
getWindow
-
getLifecycle
Description copied from interface:LifecycleOwnerReturns the Lifecycle of the provider.- Specified by:
getLifecyclein interfaceLifecycleOwner- Returns:
- The lifecycle of the provider.
-
getResources
Description copied from class:ContextReturns 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:
getResourcesin classContext- Returns:
- a Resources instance for the application's environment
-
setTheme
Description copied from class:ContextReset 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:ContextReturn 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. -
onGetSelectedLocale
Get the default or preferred locale set by user.- Returns:
- the selected locale
-
getSelectedLocale
Get the default or preferred locale set by user.- Returns:
- the selected locale
-
onGetSelectedTypeface
Get the default or preferred typeface set by user.- Returns:
- the selected typeface
-
getSelectedTypeface
Get the default or preferred typeface set by user.- Returns:
- the selected typeface
-
hasRtlSupport
@Experimental public boolean hasRtlSupport()Whether to enable RTL support, it should always be true.- Returns:
- whether RTL is supported
-
getResourceStream
@Experimental @NonNull public InputStream getResourceStream(@NonNull String namespace, @NonNull String path) throws IOException - Throws:
IOException
-
getResourceChannel
@Experimental @NonNull public ReadableByteChannel getResourceChannel(@NonNull String namespace, @NonNull String path) throws IOException - Throws:
IOException
-
getWindowManager
Get the view manager of the application window (i.e. main window).- Overrides:
getWindowManagerin classActivity- Returns:
- window view manager
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-