Class ViewUtils


  • public final class ViewUtils
    extends Object
    • Constructor Detail

      • ViewUtils

        public ViewUtils()
    • Method Detail

      • getActivity

        @Nullable
        public static Activity getActivity​(@Nullable
                                           Context context)
        Retrieves the Activity from a given Context.

        This method will recursively traverse up the context chain if it is a ContextWrapper until it finds the first instance of the base context that is an Activity.

      • generateViewId

        public static int generateViewId​(int fallbackId)
        Generates a view id.

        In API level 17 and above, this ID is unique. Below 17, the fallback id is used instead.

        Parameters:
        fallbackId - the fallback id.
        Returns:
        the view id.
      • childHasFocus

        public static boolean childHasFocus​(@Nullable
                                            View root)
        Determines if the current view or any descendant view has focus.
        Parameters:
        root - The root view.
        Returns:
        True if the current view or any descendant view has focus.