ZZomato·Tech KnowledgeL3Machine Coding

Implementing Infinite Scroll and Live Badge Counts

Problem Given a feature requirement such as "implement infinite scroll with pull-to-refresh" or "show a badge count that updates in real time", how would you implement it on Android?

Be ready to discuss

  • Infinite scroll: RecyclerView with Paging 3 (PagingSource, RemoteMediator for network+DB) versus a manual scroll-listener that loads the next page near the end — and why the library exists (dedupe in-flight requests, retry, placeholders).
  • Pull-to-refresh: SwipeRefreshLayout versus a custom gesture detector, and how refresh interacts with paging state (invalidate the source rather than clearing the adapter).
  • Configuration changes: surviving rotation without losing scroll position or refetching — ViewModel scope, saved state, and stable adapter item IDs.
  • Real-time badge count: LiveData/StateFlow observing a repository backed by a WebSocket or push notification, with a local cache as the source of truth so the UI renders instantly and reconciles on reconnect.
  • Lifecycle-awareness: collecting flows with repeatOnLifecycle/flowWithLifecycle so a backgrounded screen stops consuming, and tearing down sockets to avoid leaks.
  • Error and edge states: empty, loading, end-of-list, and network-failure states, plus offline behavior and retry/backoff.
  • What's evaluated: reasoning about lifecycle, state restoration, and Android's component model — not just a generic pagination algorithm.
asked …
LeaderboardSalaryAccount