A StorytellerListViewDelegate
has methods for managing StorytellerRowView
and StorytellerGridView
events. Please see the dedicated StorytellerDelegate for handling other events.
To use StorytellerListViewDelegate
, implement the StorytellerListViewDelegate
interface and override the required methods:
The onDataLoadStarted()
method is called when the network request to load data for all Stories has started.
The onDataLoadComplete(success: Boolean, error: Error?, dataCount: Int)
method is called when the data loading network request is complete.
Property | Description |
---|---|
success |
This confirms whether or not the request was successful |
error |
The HTTP error if the request was not successful |
dataCount |
The number of Stories loaded |
onPlayerDismissed() |
This is called when any Story has been dismissed |
tileBecameVisible(contentIndex: Int) |
This is called whenever a tile is visible in the Story View |
Example:
val storytellerRowView = StorytellerRowView()
storytellerRowView.delegate = myDelegate
By using the callback function onDataLoadComplete
and the data it provides, you can handle the current state of the StorytellerRowView
appropriately in your app.
Note:
dataCount
is the total number of Stories in the existingStorytellerRowView
at any given time
Example:
...
override fun onDataLoadComplete(success: Boolean, error: Error?, dataCount: Int) {
if (success) {
// stories data has been loaded successfully
// dataCount is the current total number of stories, including newly added/removed data
} else if (error != null) {
// an error has occurred, unwrap the error value for more information
// dataCount is the total number of stories before loading began
}
}
Another example:
...
override fun onDataLoadComplete(success: Boolean, error: Error?, dataCount: Int) {
if (error != null && dataCount == 0) {
// stories have failed to load with error and there is no data to show
// you may wish to hide the `StorytellerRowView` instance here
storytellerRowView.visibility = View.GONE
}
}
The callback tileBecameVisible
is called whenever a tile is visible in the Storyteller List view. This could be useful, for example, to integrate with an analytics library on the integrating app side. The callback passes a single contentIndex
parameter which starts counting at 1 and is the index of the current tile in the list (whether a row or a grid).
Example:
override fun tileBecameVisible(contentIndex: Int) {
// for example, report to an analytics library which story was seen by the user
}