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 TypeMethodDescriptionvoid
close()
static ModernUI
Get 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 Locale
Get the default or preferred locale set by user.static Typeface
Get 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.boolean
Whether to enable RTL support, it should always be true.protected Locale
Get the default or preferred locale set by user.protected Typeface
Get the default or preferred typeface set by user.void
Runs the Modern UI with the default application setups.void
setTheme
(ResourceId resId) Reset the base theme for this context.Methods inherited from class icyllis.modernui.app.Activity
getSystemService, getToastManager
Methods 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:LifecycleOwner
Returns the Lifecycle of the provider.- Specified by:
getLifecycle
in interfaceLifecycleOwner
- Returns:
- The lifecycle of the provider.
-
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. -
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:
getWindowManager
in classActivity
- Returns:
- window view manager
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
-