Instant feed rendering via two-level cache and lazy hero banner - #3142
Instant feed rendering via two-level cache and lazy hero banner#3142cloudflix-x wants to merge 8 commits into
Conversation
d6b3f66 to
ef98bba
Compare
There was a problem hiding this comment.
Good idea, and great performance testing but this pull request is way too bloated, with cache logic interspersed with normal code. Surely you can move the cache logic to APIRepository to reduce the complexity and boilerplate by a lot.
This whole pull request (excluding tests) ought to be achievable in ~200 lines, not 700.
|
@fire-light42 My bad for the messy diff before — had some messy merge/cherry-pick conflicts from my dev branch that pulled in unrelated stuff. It's clean and minimal now. |
|
This looks great now! I will review it soon, unless it's not ready for review? |
71a2720 to
fbe5b34
Compare
|
@fire-light42 Sorry for the delay, had a small issue with the hero banner when switching providers earlier. |
Summary
Implemented an intelligent Two-Level Provider & Homepage Cache Architecture (In-Memory
ConcurrentHashMap+ Persistent DiskSharedPreferencesJSON serialization) combined with Lazy Hero Banner Loading to accelerate home screen rendering, eliminate cold-start blank screens, and allow movie lists to populate instantly via a Stale-While-Revalidate pattern.Code Changes & Architecture
1. Two-Level Caching Engine (
HomeCache.kt)ConcurrentHashMapfor sub-millisecond retrieval of active feeds during session navigation.CachedHomeData,CachedHomePageResponse, andCachedSearchResponsesupporting serialization across allTvTypes (Movie,TvSeries,Anime,Live,Torrent).2. ViewModel & Lazy Hero Banner Integration (
HomeViewModel.kt)load()to immediately dispatch cached data viaHomeCache.getHomeCache(api.name), rendering movie lists directly from local disk cache.addJob = ioSafe { ... }), preventing network calls from blocking initial feed appearance.getMainPage()success without causing UI flicker or focus resets.3. API Load Response Caching (
APIRepository.kt)cacheTimeSeconds) and enabled/disabled state.4. User Preferences & Storage Management (
SettingsProviders.kt&DataStoreHelper.kt)DataStoreHelper.cacheTimeMinutes.formatShortFileSize).5. Automated Unit Tests (
HomeCacheTest.kt)Performance Impact (Xiaomi TV - Real Data)
master)feat/home-provider-cache)Validation
./gradlew testPrereleaseDebugUnitTest(AllHomeCacheTestcases passed)MiTV-MZTU0/ Android TV 14) via ADB instrumentationAI Disclosure
Screenshots
Provider Cache Settings & Duration Selector