From 814b4dd00cbf5392a8caf5caf53ebc670e39bd02 Mon Sep 17 00:00:00 2001 From: Andrey Epin Date: Thu, 20 Oct 2022 20:43:37 -0700 Subject: [PATCH] Fix labels loading regression DisplayResolveInfo#getDisplayLabel() internally loads the display label if it is missing and a ResolveInfoPresentationGetter is set for the instance. Current view binding logic unconditionally calls getDisplayLabel method which could trigger label resolution on the main thread and a consequently scheduled label loading asynchronous task a no-op. Test: manual functionality testing Test: introduce artificial into LoadLabelTask, observe labels lading asynchronously and does not reload when scrolling through a long list of options. Test: atest FrameworksCoreTests:ResolverActivityTest Bug: 245934835 Change-Id: I392d6c8424617820bde58887d92ae99bc39c5b7b --- .../android/internal/app/ResolverListAdapter.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/core/java/com/android/internal/app/ResolverListAdapter.java b/core/java/com/android/internal/app/ResolverListAdapter.java index f6075b008f721..7e28f3283f14c 100644 --- a/core/java/com/android/internal/app/ResolverListAdapter.java +++ b/core/java/com/android/internal/app/ResolverListAdapter.java @@ -647,15 +647,16 @@ public class ResolverListAdapter extends BaseAdapter { if (info instanceof DisplayResolveInfo) { DisplayResolveInfo dri = (DisplayResolveInfo) info; - boolean hasLabel = dri.hasDisplayLabel(); - holder.bindLabel( - dri.getDisplayLabel(), - dri.getExtendedInfo(), - hasLabel && alwaysShowSubLabel()); - holder.bindIcon(info); - if (!hasLabel) { + if (dri.hasDisplayLabel()) { + holder.bindLabel( + dri.getDisplayLabel(), + dri.getExtendedInfo(), + alwaysShowSubLabel()); + } else { + holder.bindLabel("", "", false); loadLabel(dri); } + holder.bindIcon(info); if (!dri.hasDisplayIcon()) { loadIcon(dri); }