Feed
Represents a feed of multiple T items, Used in various contexts like home, library, etc.
Feeds without Tabs
The simplest way to create a feed is to show a list of T items, you can just do the following to convert a list of T items to a Feed:
val feed = listOf<T>().toFeed()If you want to show a feed that loads more stuff when scrolled to end, you need to use the PagedData class. This class allows you to load more items as the user scrolls. And You can use the following to convert a PagedData to a feed:
val feed = pagedData.toFeed()Feeds with Tabs
Feeds can have multiple Tab items, each representing a different category. When a tab is selected, the getPagedData is called with the selected tab to retrieve a pair of PagedData and Buttons. If the tabs list is empty, the getPagedData will be called with null. An example of a feed with tabs:
val feed = Feed(
listOf("Tab1", "Tab2").map { Tab(it, it) }
) { tab ->
val pagedData = when (tab?.id) {
"Tab1" -> loadPagedDataForTab1()
"Tab2" -> loadPagedDataForTab2()
else -> throw IllegalArgumentException("Unknown tab")
}
pagedData.toFeedData()
}Buttons And Background
Feeds can also have Buttons shown below the tabs. Echo automatically handles searching and filtering depending on the data provided in the items. You can provide a custom track list to be used when play/shuffle button is clicked. You can send the buttons as null, if you want echo to use the default buttons for the feed. Use the Buttons.EMPTY to force a feed to have no buttons.
An example of converting PagedData to Feed.Data with Buttons:
val feedData = pagedData.toFeedData(
buttons = Feed.Buttons(showPlayAndShuffle = true),
background = "https://example.com/background.jpg".toImageHolder()
)See also
Constructors
Types
Represents the loaded data of the Feed.