android / android/codelab-android-paging

List blinking when I restore state in fragment

Open
#167 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
Kotlin
Stars
509
Forks
268
PR merge metrics
No merged PRs in 30d

Description

I have two fragments and bottom navigation. Every fragment contain list with paging. I use RemoteMediator to get data from api.
If I use launch in fragment then I always recreate list if I navigate between first and second fragment.
```
lifecycleScope.launch {
viewModel.items.collectLatest {
adapter?.submitData(it)
}
}
```

If I use launchWhenCreated or launchWhenStarted then list save it state, but when I navigate between first and second fragment it show blank list for maybe 1 second and it's create visual blinking.
How can I save paging 3 list state and show list immediately on fragment created?

Contributor guide

Open the contributing guide

Research direction

Start with the fragment lifecycle collection shown in the issue and the RemoteMediator-backed Paging setup. Reproduce navigation between the two fragments, then determine whether the restored list is rendered immediately without a blank interval or visual blink.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.