ResourceProvider

You use a ResourceProvider to fetch resources from a "resource container". A resource container can for example be:

  • a ZIP archive.

  • a directory in a file system.

You can fetch a resource from a ResourceProvider by calling the fetch method with the resource's path. How the ResourceProvider fetches the resource is an implementation detail.

You can load container-based publication formats such as EPUBs into the ReadingSystemEngine by using a ResourceProvider. In this case, you create a ResourceProvider that can fetch resources from the EPUB and pass it to ReadingSystemEngine.loadEpub. For normal EPUB files, you use the ZipResourceProvider which extract resources from ZIP archives. You can also create your own ResourceProvider implementation to provide resources from the device or from a remote server.

Note that all ResourceProvider methods executes synchronously, and should be NOT called using the Main thread. All methods and properties must be thread safe.

Functions

Link copied to clipboard
abstract fun fetch(path: String, options: ResourceRequestOptions = ResourceRequestOptions()): ResourceResponse

Synchronously fetches a resource from this ResourceProvider. The method returns when a response is available.

Link copied to clipboard
abstract fun fetchMetadata(path: String, options: ResourceRequestOptions = ResourceRequestOptions()): ResourceMetadata

Same as fetch(), but only returns metadata about the resource.

Properties

Link copied to clipboard

Get a list of all resources available in this ResourceProvider.

Inheritors

Link copied to clipboard