Class Loader

    • Constructor Detail

      • Loader

        public Loader​(String threadNameSuffix)
        Parameters:
        threadNameSuffix - A name suffix for the loader's thread. This should be the name of the component using the loader.
    • Method Detail

      • createRetryAction

        public static Loader.LoadErrorAction createRetryAction​(boolean resetErrorCount,
                                                               long retryDelayMillis)
        Creates a Loader.LoadErrorAction for retrying with the given parameters.
        Parameters:
        resetErrorCount - Whether the previous error count should be set to zero.
        retryDelayMillis - The number of milliseconds to wait before retrying.
        Returns:
        A Loader.LoadErrorAction for retrying with the given parameters.
      • clearFatalError

        public void clearFatalError()
        Clears any stored fatal error.
      • isLoading

        public boolean isLoading()
        Returns whether the loader is currently loading.
      • cancelLoading

        public void cancelLoading()
        Cancels the current load.
        Throws:
        IllegalStateException - If the loader is not currently loading.
      • release

        public void release()
        Releases the loader. This method should be called when the loader is no longer required.
      • release

        public void release​(@Nullable
                            Loader.ReleaseCallback callback)
        Releases the loader. This method should be called when the loader is no longer required.
        Parameters:
        callback - An optional callback to be called on the loading thread once the loader has been released.
      • maybeThrowError

        public void maybeThrowError​(int minRetryCount)
                             throws IOException
        Description copied from interface: LoaderErrorThrower
        Throws a fatal error, or a non-fatal error if loading is currently backed off and the current Loader.Loadable has incurred a number of errors greater than the specified minimum number of retries. Else does nothing.
        Specified by:
        maybeThrowError in interface LoaderErrorThrower
        Parameters:
        minRetryCount - A minimum retry count that must be exceeded for a non-fatal error to be thrown. Should be non-negative.
        Throws:
        IOException - The error.