BookLibraryController
The main entry point for the Book Library UI SDK.
Most interaction with the SDK is through this class. Call start as early as possible in your app's lifecycle to allow feeds to update as soon as possible.
In the activity that is going to host the book library, call showLibraryInView.
BookLibraryController
needs to know about a few things that are going on in the host Activity
's overridden methods (a more automated solution is pending, but for now this is required for correct functionality):
In
onRestoreInstanceState
, callBookLibraryController.verifyViewStateAfterActivityRestore()
.In
onBackPressed
, call:
if (!BookLibraryController.handleBackPressed()) {
super.onBackPressed()
}
... or something similar, based on your own needs. This is required for proper back button handling in the SDK.
Important: currently, only one instance of BookLibraryController may be created during the lifetime of the hosting application. This may change in the future.
tokenProvider provides the token that's required for various access checks, either when downloading books or checking access to books on disk.
A BookOpening implementation can optionally be added if a token check is not sufficient for checking the user's access to a book. If bookOpening is null
, a default implementation that always returns true
is used.
By default, Book Library UI uses books on disk as the content of the library tab. Add readingListHost if you need to customize this to show a custom list of books, in addition to books on disk.
Books may have reviews or other extra articles attached to them. These articles may contain an id for opening the article in question in the host app or the web. Set articleOpener with your ArticleOpener implementation to be informed when the user clicks a button to open these articles.
navigationDelegate is an optional LibraryNavigationDelegate implementation. If using the default action bar controller, this informs the host app of when the user either navigates away from or back to the top level of navigation.
coverOverlayProvider is an optional BookCoverOverlayProvider implementation. When it returns a overlay description for a book, an overlay is drawn on top of the cover image.
categoryListIconProvider is an optional CategoryListIconProvider implementation. It's used in the category list view.
If passing in an Editions instance (editions), Editions.initialize must have been called before doing so. The SDK will call Editions.updateFeed on startup. Analytics events should be forwarded to fi.richie.booklibraryui.analytics.EditionsEventLogger. (or use the class directly)
You may provider font and color providers (fontProvider and colorProvider respectively), which will, as the names imply, used as sources for fonts and colors. This can be useful if your colors are defined via an external app config, for example. If no providers are given, defaults are used, which can also be overridden via XML resources. Note that the providers can only be set in start, so the providers should be able to update their value definitions themselves.
Constructors
Properties
Getter for AudioPlayerGateway. Use to check or listen to the audio player's state.
Getter for ContentState. Use to follow the state of the content feed.
Analytics event logger.
Inform the SDK whether its view is currently being shown by the host app or not.
If the Books remote config has a books_review_prompt
configuration, this Observable
will be updated when its conditions are met.
Functions
Add an analytics event listener.
Close all books that are currently open. Can be useful if the user loses entitlements to content that was previously available.
Check if the SDK needed to react to the back button being pressed.
Clears views when the library view is about to be destroyed, such as when the host activity is about to be destroyed.
Notify the SDK that the reading list has changed.
Update content that's dependent on the user's login state. E.g. this refreshes the user's book ratings.
Remove an analytics event listener.
Resets all tabs to their default state, i.e. pops all tabs to the root view.
Resets content that's dependent on the user's login state. This means the following:
Set the extra attributes for analytics events. A null
extraAttributes clears it.
Show the library in the containerView in the host activity.
Starts the Book Library UI SDK, including fetching feeds and initializing the book library.
Triggers an update to all active action bars.
If you have a custom DataBindingValueProvider.Colors or DataBindingValueProvider.Fonts, call this method if their contents have changed to update the UI.
Update the token provider used by Books.
Ensures that the SDK's view states are correct after the host activity has been restored.