title: How to distinguish between initial load and content change in Android Paging 3?
body: <p>I have a RecyclerView that uses a PagingDataAdapter to show its items. On initial load of the entire page, I want to show a Shimmer loading placeholder. However, when I try to do this, the loading placeholder also shows up for a small content change of a single item. This makes the entire screen flicker because it hides the RecyclerView during loading and reshows it once the content change has been loaded. I don't want the loading placeholder to show for a single content change.</p>
  <p>I am checking the loading state in the load state listener for the adapter:</p>
  <pre><code>addLoadStateListener {
      val taskListState = when (it.refresh) { // triggered for both initial load and content change
          is LoadState.Loading -&gt; ScheduleViewModel.TaskListState.LOADING
          // I want something like if (loadStateIsForInitialLoad()) ScheduleViewModel.TaskListState.LOADING else ScheduleViewModel.TaskListState.PRESENT
          is LoadState.Error -&gt; ScheduleViewModel.TaskListState.ERROR
          is LoadState.NotLoading -&gt;
              if (it.append.endOfPaginationReached &amp;&amp; itemCount &lt; 1) {
                  ScheduleViewModel.TaskListState.EMPTY
              } else {
                  ScheduleViewModel.TaskListState.PRESENT
              }
      }
      scheduleViewModel.setTaskListState(taskListState)
  }
  </code></pre>
  <p>The content change goes through the database:</p>
  <pre><code>class ScheduleViewModel @Inject constructor(private val taskRepository: TaskRepository) :
          ViewModel() {
  
    fun updateDoneState(task: TaskItem) {
      viewModelScope.launch(Dispatchers.IO) {
          if (task.isDone) {
              taskRepository.markUndone(task.id)
          } else {
              taskRepository.markDone(task.id)
          }
      }
    }
  }
  </code></pre>
  <p>Layout:</p>
  <pre><code>&lt;layout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
          xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;&gt;
      &lt;data&gt;
          &lt;variable name=&quot;viewModel&quot; type=&quot;ogbe.eva.prompt.ui.schedule.ScheduleViewModel&quot;/&gt;
      &lt;/data&gt;
      &lt;FrameLayout
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;match_parent&quot;&gt;
  
          &lt;com.facebook.shimmer.ShimmerFrameLayout
                  android:id=&quot;@+id/shimmerFrameLayout&quot;
                  android:layout_width=&quot;match_parent&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  app:isVisible=&quot;@{viewModel.isLoading}&quot;&gt;
  
              &lt;LinearLayout
                      android:layout_width=&quot;match_parent&quot;
                      android:layout_height=&quot;wrap_content&quot;
                      android:orientation=&quot;vertical&quot;&gt;
  
                  &lt;include layout=&quot;@layout/item_task_placeholder&quot;/&gt;
  
                  &lt;include layout=&quot;@layout/item_task_placeholder&quot;/&gt;
  
                  &lt;include layout=&quot;@layout/item_task_placeholder&quot;/&gt;
  
                  &lt;include layout=&quot;@layout/item_task_placeholder&quot;/&gt;
  
                  &lt;include layout=&quot;@layout/item_task_placeholder&quot;/&gt;
  
              &lt;/LinearLayout&gt;
  
          &lt;/com.facebook.shimmer.ShimmerFrameLayout&gt;
  
          &lt;androidx.recyclerview.widget.RecyclerView
                  android:id=&quot;@+id/task_list&quot;
                  android:layout_width=&quot;match_parent&quot;
                  android:layout_height=&quot;match_parent&quot;
                  android:padding=&quot;@dimen/spacing_sm&quot;
                  app:isVisible=&quot;@{viewModel.isPresent}&quot;/&gt;
  
      &lt;/FrameLayout&gt;
  &lt;/layout&gt;
  </code></pre>
  <p>It looks like CombinedLoadStates only has one refresh load state for both initial load and content changes. Is there some other way to distinguish them?</p>