Class ModernUI

All Implemented Interfaces:
LifecycleOwner, AutoCloseable

public class ModernUI extends Activity implements AutoCloseable, LifecycleOwner
The core class of Modern UI.
  • Field Details

  • Constructor Details

    • ModernUI

      public ModernUI()
  • Method Details

    • getInstance

      public static ModernUI getInstance()
      Get Modern UI instance.
      Returns:
      the Modern UI
    • run

      @MainThread public void run(@NonNull Fragment fragment)
      Runs the Modern UI with the default application setups. This method is only called by the main() on the main thread.
    • getWindow

      public ActivityWindow getWindow()
    • getLifecycle

      @NonNull public Lifecycle getLifecycle()
      Description copied from interface: LifecycleOwner
      Returns the Lifecycle of the provider.
      Specified by:
      getLifecycle in interface LifecycleOwner
      Returns:
      The lifecycle of the provider.
    • getResources

      public Resources 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 class Context
      Returns:
      a Resources instance for the application's environment
    • setTheme

      public void setTheme(@Nullable ResourceId resId)
      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.
      Specified by:
      setTheme in class Context
      Parameters:
      resId - The style resource describing the theme.
    • getTheme

      public Resources.Theme 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 with Context.getResources(). Calling this method is not particularly fast, so it is recommended to cache it in a local variable.

      Specified by:
      getTheme in class Context
    • onGetSelectedLocale

      protected Locale onGetSelectedLocale()
      Get the default or preferred locale set by user.
      Returns:
      the selected locale
    • getSelectedLocale

      @NonNull public static Locale getSelectedLocale()
      Get the default or preferred locale set by user.
      Returns:
      the selected locale
    • onGetSelectedTypeface

      @NonNull protected Typeface onGetSelectedTypeface()
      Get the default or preferred typeface set by user.
      Returns:
      the selected typeface
    • getSelectedTypeface

      @NonNull public static 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

      @Internal public WindowManager getWindowManager()
      Get the view manager of the application window (i.e. main window).
      Overrides:
      getWindowManager in class Activity
      Returns:
      window view manager
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable