Fix text overlap issue when flinging in ManageApplication
The issue is we have a background handler to find app size and set to summary asynchronously. When flinging quickly, the view being request to update by the background handler could be scrolled off screen already. This change forces onPackageSizeChanged update to only happen when it's not scrolling. Change-Id: Ia7ccab776c3c789c8d4c0b55104b48e257b9cebf Fixes: 76176014 Test: manually fling
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.settings.applications.manageapplications;
|
||||
|
||||
import static android.support.v7.widget.RecyclerView.SCROLL_STATE_DRAGGING;
|
||||
import static android.support.v7.widget.RecyclerView.SCROLL_STATE_IDLE;
|
||||
import static com.android.settings.applications.manageapplications.AppFilterRegistry.FILTER_APPS_ALL;
|
||||
import static com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_MAIN;
|
||||
import static com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_NOTIFICATION;
|
||||
@@ -229,6 +231,40 @@ public class ManageApplicationsTest {
|
||||
verify(loadingViewController).showContent(true /* animate */);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void notifyItemChange_recyclerViewIdle_shouldNotify() {
|
||||
final RecyclerView recyclerView = mock(RecyclerView.class);
|
||||
final ManageApplications.ApplicationsAdapter adapter =
|
||||
spy(new ManageApplications.ApplicationsAdapter(mState,
|
||||
mock(ManageApplications.class),
|
||||
AppFilterRegistry.getInstance().get(FILTER_APPS_ALL), new Bundle()));
|
||||
|
||||
adapter.onAttachedToRecyclerView(recyclerView);
|
||||
adapter.mOnScrollListener.onScrollStateChanged(recyclerView, SCROLL_STATE_IDLE);
|
||||
adapter.mOnScrollListener.postNotifyItemChange(0 /* index */);
|
||||
|
||||
verify(adapter).notifyItemChanged(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void notifyItemChange_recyclerViewScrolling_shouldNotifyWhenIdle() {
|
||||
final RecyclerView recyclerView = mock(RecyclerView.class);
|
||||
final ManageApplications.ApplicationsAdapter adapter =
|
||||
spy(new ManageApplications.ApplicationsAdapter(mState,
|
||||
mock(ManageApplications.class),
|
||||
AppFilterRegistry.getInstance().get(FILTER_APPS_ALL), new Bundle()));
|
||||
|
||||
adapter.onAttachedToRecyclerView(recyclerView);
|
||||
adapter.mOnScrollListener.onScrollStateChanged(recyclerView, SCROLL_STATE_DRAGGING);
|
||||
adapter.mOnScrollListener.postNotifyItemChange(0 /* index */);
|
||||
|
||||
verify(adapter, never()).notifyItemChanged(0);
|
||||
verify(adapter, never()).notifyDataSetChanged();
|
||||
|
||||
adapter.mOnScrollListener.onScrollStateChanged(recyclerView, SCROLL_STATE_IDLE);
|
||||
verify(adapter).notifyDataSetChanged();
|
||||
}
|
||||
|
||||
private void setUpOptionMenus() {
|
||||
when(mMenu.findItem(anyInt())).thenAnswer(invocation -> {
|
||||
final Object[] args = invocation.getArguments();
|
||||
|
Reference in New Issue
Block a user