Class HeadRepository
-
- All Implemented Interfaces:
public abstract class HeadRepositoryModule repository, it contains all the methods required for the Main app to get data from the Module, abstract functions infoPage and sourceData are required, all other functions are optional.
<b>Sample usage</b>
class Repository : HeadRepository(){ override fun infoPage(link: String, bypassModel: BypassModel): Flow<InfoModel?> { return flow { emit(null) } } override fun sourceData(link: String, bypassModel: BypassModel): Flow<SourceData?> { return flow { emit(null) } } override suspend fun recentsPager(bypassModel: BypassModel): Flow<PagingData<RecentModel>> { return Pager( config = PagingConfig( pageSize = 20, enablePlaceholders = false ), pagingSourceFactory = { RecentsSource() } ).flow } }
-
-
Constructor Summary
Constructors Constructor Description HeadRepository()
-
Method Summary
Modifier and Type Method Description abstract Flow<InfoModel>infoPage(String link, BypassModel bypassModel)This function is called when loading the information page for any of this items:It's required that this 3 properties have the same link. abstract SourceData<?>sourceData(ContentItemMin content, BypassModel bypassModel)This function is called when loading the sources for a ContentItemModel it can be a VideoSource, GallerySource or a WebSource. PagerData<?, RecentModel>recentsPagerData(BypassModel bypassModel)This function is called only if HeadConfig.isRecentsAvailable is enabled, it's used for loading the recents section in Home. NotifyData.ResponselastRecents(NotifyData.Request data)This function is called only if HeadConfig.isRecentsAvailable and HeadConfig.isNotifyRecentsEnabled are enabled, it's used to get the latest sublist of recents. PagerData<?, DirectoryModel>directoryPagerData(BypassModel bypassModel, FilterRequest filters)This function is called only if HeadConfig.isDirectoryAvailable is enabled, it's used to load the directory of items. List<FilterData>directoryFilters(BypassModel bypassModel)This function is used to declare the custom filters to be used in directoryPagerData. PagerData<?, DirectoryModel>searchPagerData(String query, BypassModel bypassModel, FilterRequest filters)This function is called only if HeadConfig.isSearchAvailable is enabled, it's used to search items in the module. List<FilterData>searchFilters(BypassModel bypassModel)This function is used to declare the custom filters to be used in searchPagerData. List<String>searchSuggestions(String query, BypassModel bypassModel)This function is called only if HeadConfig.isSearchSuggestionsAvailable is enabled, it's used for search autocompletion. PagerData<?, DirectoryModel>calendarByDayData(BypassModel bypassModel, CalendarDay day)This function is called only if HeadConfig.isCalendarEnabled is enabled, it's used to create a daily calendar. List<SectionData>customHomeSections(BypassModel bypassModel)Declare custom Home sections Flow<List<DirectoryModel>>analyticsRecommended(BypassModel bypassModel, List<Analytics.Event> events)This function is called only if HeadConfig.analyticsSettings is declared, it's used to load a list of recommendations based on the user behaviour and the module configuration. BooleansendReview(BypassModel bypassModel, Integer id, ReviewResult reviewResult)This function is called only if HeadConfig.reviewConfig is declared, it's called whe the user sends a review. PagerData<?, DirectoryModel>extraDirectoryPagerData(BypassModel bypassModel, ExtraDirectoryRequest request)Load a filtered list of the directory based on the payload from ClickAction.ExtraDirectory or Tag.payload Flow<ProfileModel>userProfile(BypassModel bypassModel, InfoModel.ProfileData profileData)Load a profile with custom sections declared in the ProfileModel. -
-
Method Detail
-
infoPage
abstract Flow<InfoModel> infoPage(String link, BypassModel bypassModel)
This function is called when loading the information page for any of this items:
It's required that this 3 properties have the same link.
- Parameters:
link- Information link, it can be any string, if your module need a content id or something like that you can send it as the link, it's not required to be an http link.bypassModel- Cloudflare bypass information extracted by the Main app, if your module doesn't require a bypass you can disable it in HeadConfig.bypassBehavior.- Returns:
A flow containing the InfoModel for this link or null if there was an error.
-
sourceData
abstract SourceData<?> sourceData(ContentItemMin content, BypassModel bypassModel)
This function is called when loading the sources for a ContentItemModel it can be a VideoSource, GallerySource or a WebSource.
- Parameters:
content- The minimized version en the ContentItemModel declared in InfoModel.contentDatabypassModel- Cloudflare bypass information extracted by the Main app, if your module doesn't require a bypass you can disable it in HeadConfig.bypassBehavior.- Returns:
A SourceData declaring the data type for this content or null if there was an error.
-
recentsPagerData
PagerData<?, RecentModel> recentsPagerData(BypassModel bypassModel)
This function is called only if HeadConfig.isRecentsAvailable is enabled, it's used for loading the recents section in Home.
- Parameters:
bypassModel- Cloudflare bypass information extracted by the Main app, if your module doesn't require a bypass you can disable it in HeadConfig.bypassBehavior.- Returns:
A PagerData containing a PagingData for the recents.
-
lastRecents
NotifyData.Response lastRecents(NotifyData.Request data)
This function is called only if HeadConfig.isRecentsAvailable and HeadConfig.isNotifyRecentsEnabled are enabled, it's used to get the latest sublist of recents.
The system works like this:
Every X minutes the app will call this method with a NotifyData.Request, it includes the latest BypassModel for the module and the last RecentModel send in a NotifyData.Request or null if it's the first request.
The module needs to load the latest recents until the item in the request and send them in a NotifyData.Response, the response needs to include the new latest recent.
The Main app won't notify the first time it sends a request so if the item in the request is null you can send a response only containing the latest recent.
If the latest in the Response is null, the app will send the same latest in the next request.
The amount of notifications is limited to 5 per request, if the response contains more than 5 recents the Main app will only take the first 5 elements.
- Parameters:
data- The request for latest recents- Returns:
The response containing the list of latest recents and the latest recent to record
-
directoryPagerData
PagerData<?, DirectoryModel> directoryPagerData(BypassModel bypassModel, FilterRequest filters)
This function is called only if HeadConfig.isDirectoryAvailable is enabled, it's used to load the directory of items.
This section can be filtered if directoryFilters is declared.
- Parameters:
bypassModel- Cloudflare bypass information extracted by the Main app, if your module doesn't require a bypass you can disable it in HeadConfig.bypassBehavior.filters- Requested filters by the user.- Returns:
A PagerData containing a PagingData for the directory.
-
directoryFilters
List<FilterData> directoryFilters(BypassModel bypassModel)
This function is used to declare the custom filters to be used in directoryPagerData.
See FilterData for more information.
- Parameters:
bypassModel- Cloudflare bypass information extracted by the Main app, if your module doesn't require a bypass you can disable it in HeadConfig.bypassBehavior.- Returns:
A list of FilterData that represents the filters available for the directory.
-
searchPagerData
PagerData<?, DirectoryModel> searchPagerData(String query, BypassModel bypassModel, FilterRequest filters)
This function is called only if HeadConfig.isSearchAvailable is enabled, it's used to search items in the module.
This section can be filtered if searchFilters is declared.
- Parameters:
query- The query to searchbypassModel- Cloudflare bypass information extracted by the Main app, if your module doesn't require a bypass you can disable it in HeadConfig.bypassBehavior.filters- Requested filters by the user.- Returns:
A PagerData containing a PagingData for the search result.
-
searchFilters
List<FilterData> searchFilters(BypassModel bypassModel)
This function is used to declare the custom filters to be used in searchPagerData.
See FilterData for more information.
- Parameters:
bypassModel- Cloudflare bypass information extracted by the Main app, if your module doesn't require a bypass you can disable it in HeadConfig.bypassBehavior.- Returns:
Requested filters by the user.
-
searchSuggestions
List<String> searchSuggestions(String query, BypassModel bypassModel)
This function is called only if HeadConfig.isSearchSuggestionsAvailable is enabled, it's used for search autocompletion.
- Parameters:
query- The current query to searchbypassModel- Cloudflare bypass information extracted by the Main app, if your module doesn't require a bypass you can disable it in HeadConfig.bypassBehavior.- Returns:
A list of possible titles based on the query
-
calendarByDayData
PagerData<?, DirectoryModel> calendarByDayData(BypassModel bypassModel, CalendarDay day)
This function is called only if HeadConfig.isCalendarEnabled is enabled, it's used to create a daily calendar.
If the calendar is enabled home will try to load a "Today" list calling this function with the current day as parameter.
- Parameters:
bypassModel- Cloudflare bypass information extracted by the Main app, if your module doesn't require a bypass you can disable it in HeadConfig.bypassBehavior.day- The day requested by the main app- Returns:
A PagerData containing a PagingData for the items in the request.
-
customHomeSections
List<SectionData> customHomeSections(BypassModel bypassModel)
Declare custom Home sections
- Parameters:
bypassModel- Cloudflare bypass information extracted by the Main app, if your module doesn't require a bypass you can disable it in HeadConfig.bypassBehavior.- Returns:
A list of SectionData.
-
analyticsRecommended
Flow<List<DirectoryModel>> analyticsRecommended(BypassModel bypassModel, List<Analytics.Event> events)
This function is called only if HeadConfig.analyticsSettings is declared, it's used to load a list of recommendations based on the user behaviour and the module configuration.
The main app needs to register at least 3 events to start recommending.
- Parameters:
bypassModel- Cloudflare bypass information extracted by the Main app, if your module doesn't require a bypass you can disable it in HeadConfig.bypassBehavior.events- The list of the top 3-15 events sorted by Analytics.Event.score.- Returns:
A flow containing a list of DirectoryModel with the recommendations.
-
sendReview
Boolean sendReview(BypassModel bypassModel, Integer id, ReviewResult reviewResult)
This function is called only if HeadConfig.reviewConfig is declared, it's called whe the user sends a review.
- Parameters:
bypassModel- Cloudflare bypass information extracted by the Main app, if your module doesn't require a bypass you can disable it in HeadConfig.bypassBehavior.id- The id of the reviewed InfoModel.reviewResult- The review send by the user.- Returns:
True if the review was processed successfully.
-
extraDirectoryPagerData
PagerData<?, DirectoryModel> extraDirectoryPagerData(BypassModel bypassModel, ExtraDirectoryRequest request)
Load a filtered list of the directory based on the payload from ClickAction.ExtraDirectory or Tag.payload
- Parameters:
bypassModel- Cloudflare bypass information extracted by the Main app, if your module doesn't require a bypass you can disable it in HeadConfig.bypassBehavior.request- The requested payload to load.- Returns:
A PagerData containing a PagingData for the items in the request.
-
userProfile
Flow<ProfileModel> userProfile(BypassModel bypassModel, InfoModel.ProfileData profileData)
Load a profile with custom sections declared in the ProfileModel.
- Parameters:
bypassModel- Cloudflare bypass information extracted by the Main app, if your module doesn't require a bypass you can disable it in HeadConfig.bypassBehavior.profileData- The declared InfoModel.ProfileData from InfoModel.- Returns:
A flow containing the profile from the declared InfoModel.ProfileData.
-
-
-
-