StorytellerListViewDelegate

A StorytellerListViewDelegate has methods for managing StorytellerRowView and StorytellerGridView events. Please see the dedicated StorytellerDelegate for handling other events.

How To Use

To use StorytellerListViewDelegate, implement the StorytellerListViewDelegate interface and override the required methods:

  • onStoryDataLoadStarted() - Called when the network request to load data for all stories has started
  • onStoryDataLoadComplete(success: Boolean, error: Error?, dataCount: Int) - Called when the data loading network request is complete
    • success: whether or not the request was successful
    • error: the HTTP error if the request was not successful
    • dataCount: the number of stories loaded
  • onStoryDismissed() - Called when any story has been dismissed
  • tileBecameVisible(storyIndex: Int) - called whenever a tile is visible in the story view

Example:

    val storytellerRowView = StorytellerRowView()
    storytellerRowView.delegate = myDelegate

Error Handling

By using the callback function onStoryDataLoadComplete 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 existing StorytellerRowView at any given time

Example:

    ...
    override fun onStoryDataLoadComplete(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 onStoryDataLoadComplete(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
        }
    }

Tile Visibility

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 storyIndex parameter which starts counting at 1 and is the index of the current tile in the carousel.

Example:

    override fun tileBecameVisible(storyIndex: Int) {
        // for example, report to an analytics library which story was seen by the user
    }
PREVIOUS
Forward Arrow