Updating PendingAppWidgetHostView to load icon on the background thread

Bug: 21325319
Change-Id: I0886eec5a3f36f5e1ac18020c54891a56bdb5ed2
This commit is contained in:
Sunny Goyal
2017-01-03 16:52:43 -08:00
parent a167a6e04b
commit 2d7cca1e05
4 changed files with 34 additions and 43 deletions

View File

@@ -38,6 +38,7 @@ import android.view.ViewParent;
import android.widget.TextView;
import com.android.launcher3.IconCache.IconLoadRequest;
import com.android.launcher3.IconCache.ItemInfoUpdateReceiver;
import com.android.launcher3.folder.FolderIcon;
import com.android.launcher3.graphics.DrawableFactory;
import com.android.launcher3.graphics.HolographicOutlineHelper;
@@ -51,7 +52,7 @@ import java.text.NumberFormat;
* too aggressive.
*/
public class BubbleTextView extends TextView
implements BaseRecyclerViewFastScrollBar.FastScrollFocusableView {
implements BaseRecyclerViewFastScrollBar.FastScrollFocusableView, ItemInfoUpdateReceiver {
private static SparseArray<Theme> sPreloaderThemes = new SparseArray<Theme>(2);
@@ -540,7 +541,8 @@ public class BubbleTextView extends TextView
/**
* Applies the item info if it is same as what the view is pointing to currently.
*/
public void reapplyItemInfo(final ItemInfo info) {
@Override
public void reapplyItemInfo(ItemInfoWithIcon info) {
if (getTag() == info) {
FastBitmapDrawable.State prevState = FastBitmapDrawable.State.NORMAL;
if (mIcon instanceof FastBitmapDrawable) {
@@ -582,20 +584,8 @@ public class BubbleTextView extends TextView
mIconLoadRequest.cancel();
mIconLoadRequest = null;
}
if (getTag() instanceof AppInfo) {
AppInfo info = (AppInfo) getTag();
if (info.usingLowResIcon) {
mIconLoadRequest = LauncherAppState.getInstance().getIconCache()
.updateIconInBackground(BubbleTextView.this, info);
}
} else if (getTag() instanceof ShortcutInfo) {
ShortcutInfo info = (ShortcutInfo) getTag();
if (info.usingLowResIcon) {
mIconLoadRequest = LauncherAppState.getInstance().getIconCache()
.updateIconInBackground(BubbleTextView.this, info);
}
} else if (getTag() instanceof PackageItemInfo) {
PackageItemInfo info = (PackageItemInfo) getTag();
if (getTag() instanceof ItemInfoWithIcon) {
ItemInfoWithIcon info = (ItemInfoWithIcon) getTag();
if (info.usingLowResIcon) {
mIconLoadRequest = LauncherAppState.getInstance().getIconCache()
.updateIconInBackground(BubbleTextView.this, info);