Moving slice loading on a background thread
> Also fixing slice icon loading, such that the request is cancelled if views are recycled quickly > Loading widget label on dg thread and cancelling request if views are recycled quickly. Bug: 179068415 Test: verified locally Change-Id: Id5a524e2bf596862330a8170394aef9ffd708544
This commit is contained in:
1 parent
f4d19f4614
commit
79e52fc23b
8 files changed
+235
-129
No files matched your search
@@ -31,7 +31,6 @@ import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.pm.ShortcutInfo;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Handler;
|
||||
import android.os.Process;
|
||||
import android.os.UserHandle;
|
||||
import android.util.Log;
|
||||
@@ -134,7 +133,7 @@ public class IconCache extends BaseIconCache {
|
||||
* Fetches high-res icon for the provided ItemInfo and updates the caller when done.
|
||||
* @return a request ID that can be used to cancel the request.
|
||||
*/
|
||||
public IconLoadRequest updateIconInBackground(final ItemInfoUpdateReceiver caller,
|
||||
public HandlerRunnable updateIconInBackground(final ItemInfoUpdateReceiver caller,
|
||||
final ItemInfoWithIcon info) {
|
||||
Preconditions.assertUIThread();
|
||||
if (mPendingIconRequestCount <= 0) {
|
||||
@@ -142,20 +141,18 @@ public class IconCache extends BaseIconCache {
|
||||
}
|
||||
mPendingIconRequestCount ++;
|
||||
|
||||
IconLoadRequest request = new IconLoadRequest(mWorkerHandler, this::onIconRequestEnd) {
|
||||
@Override
|
||||
public void run() {
|
||||
if (info instanceof AppInfo || info instanceof WorkspaceItemInfo) {
|
||||
getTitleAndIcon(info, false);
|
||||
} else if (info instanceof PackageItemInfo) {
|
||||
getTitleAndIconForApp((PackageItemInfo) info, false);
|
||||
}
|
||||
MAIN_EXECUTOR.execute(() -> {
|
||||
caller.reapplyItemInfo(info);
|
||||
onEnd();
|
||||
});
|
||||
}
|
||||
};
|
||||
HandlerRunnable<ItemInfoWithIcon> request = new HandlerRunnable<>(mWorkerHandler,
|
||||
() -> {
|
||||
if (info instanceof AppInfo || info instanceof WorkspaceItemInfo) {
|
||||
getTitleAndIcon(info, false);
|
||||
} else if (info instanceof PackageItemInfo) {
|
||||
getTitleAndIconForApp((PackageItemInfo) info, false);
|
||||
}
|
||||
return info;
|
||||
},
|
||||
MAIN_EXECUTOR,
|
||||
caller::reapplyItemInfo,
|
||||
this::onIconRequestEnd);
|
||||
Utilities.postAsyncCallback(mWorkerHandler, request);
|
||||
return request;
|
||||
}
|
||||
@@ -336,12 +333,6 @@ public class IconCache extends BaseIconCache {
|
||||
return super.getEntryFromDB(cacheKey, entry, lowRes);
|
||||
}
|
||||
|
||||
public static abstract class IconLoadRequest extends HandlerRunnable {
|
||||
IconLoadRequest(Handler handler, Runnable endRunnable) {
|
||||
super(handler, endRunnable);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface for receiving itemInfo with high-res icon.
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user