From 2731fa71fe68b862f476eac6c93f9503c695706b Mon Sep 17 00:00:00 2001 From: arangelov Date: Wed, 18 Mar 2020 20:24:03 +0000 Subject: [PATCH] Call setAdapter from handleLayoutChanged. Test: manual Fixes: 150918223 Fixes: 150922090 Fixes: 151329221 Fixes: 151077241 Change-Id: I723634840cfdc40eb307f2ce4e170178692f12f3 --- .../android/internal/app/ChooserActivity.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/core/java/com/android/internal/app/ChooserActivity.java b/core/java/com/android/internal/app/ChooserActivity.java index 3696c83d566b2..503a867825a25 100644 --- a/core/java/com/android/internal/app/ChooserActivity.java +++ b/core/java/com/android/internal/app/ChooserActivity.java @@ -2416,13 +2416,20 @@ public class ChooserActivity extends ResolverActivity implements if (isLayoutUpdated || mLastNumberOfChildren != recyclerView.getChildCount()) { mCurrAvailableWidth = availableWidth; - if (isLayoutUpdated - && mChooserMultiProfilePagerAdapter.getCurrentUserHandle() != getUser()) { - // This fixes b/150936654 - empty work tab in share sheet when swiping - mChooserMultiProfilePagerAdapter.getActiveAdapterView() - .setAdapter(mChooserMultiProfilePagerAdapter.getCurrentRootAdapter()); + if (isLayoutUpdated) { + // It is very important we call setAdapter from here. Otherwise in some cases + // the resolver list doesn't get populated, such as b/150922090, b/150918223 + // and b/150936654 + recyclerView.setAdapter(gridAdapter); + ((GridLayoutManager) recyclerView.getLayoutManager()).setSpanCount( + gridAdapter.getMaxTargetsPerRow()); + } + + if (mChooserMultiProfilePagerAdapter.getCurrentUserHandle() != getUser()) { return; - } else if (mChooserMultiProfilePagerAdapter.getCurrentUserHandle() != getUser()) { + } + + if (mLastNumberOfChildren == recyclerView.getChildCount()) { return; }