Revert "Removing some unused code from All-Apps"

Revert submission 17866780-cancel-request

Reason for revert: wrong icons

Reverted Changes:
Iedc98e5ef:Cancelling previous request and clearing UI when a...
I72394fb42:Removing some unused code from All-Apps

Change-Id: I2ecefcaf07e6105a10f86b8dc19f75089e45a3e0
This commit is contained in:
Sunny Goyal
2022-04-22 19:53:37 +00:00
parent 3946ecd441
commit 13ae6784b5
7 changed files with 107 additions and 95 deletions

View File

@@ -36,6 +36,7 @@ import com.android.launcher3.BubbleTextView;
import com.android.launcher3.R;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.model.data.AppInfo;
import com.android.launcher3.model.data.ItemInfoWithIcon;
import com.android.launcher3.views.ActivityContext;
import java.util.Arrays;
@@ -93,21 +94,31 @@ public abstract class BaseAllAppsAdapter<T extends Context & ActivityContext> ex
// The type of this item
public int viewType;
// The section name of this item. Note that there can be multiple items with different
// sectionNames in the same section
public String sectionName = null;
// The row that this item shows up on
public int rowIndex;
// The index of this app in the row
public int rowAppIndex;
// The associated ItemInfoWithIcon for the item
public AppInfo itemInfo = null;
public ItemInfoWithIcon itemInfo = null;
// The index of this app not including sections
public int appIndex = -1;
// Search section associated to result
public DecorationInfo decorationInfo = null;
/**
* Factory method for AppIcon AdapterItem
*/
public static AdapterItem asApp(int pos, AppInfo appInfo) {
public static AdapterItem asApp(int pos, String sectionName, AppInfo appInfo,
int appIndex) {
AdapterItem item = new AdapterItem();
item.viewType = VIEW_TYPE_ICON;
item.position = pos;
item.sectionName = sectionName;
item.itemInfo = appInfo;
item.appIndex = appIndex;
return item;
}
@@ -144,23 +155,6 @@ public abstract class BaseAllAppsAdapter<T extends Context & ActivityContext> ex
protected boolean isCountedForAccessibility() {
return viewType == VIEW_TYPE_ICON || viewType == VIEW_TYPE_SEARCH_MARKET;
}
public long getStableId() {
return viewType;
}
/**
* Called to check if the content of the item is same as the other item. This is called only
* if the {@link #getStableId()} matches for both the items.
*/
public boolean isContentSame(AdapterItem other) {
// We can use itemInfo for diff, but since ItemInfo objects are singleton per Model,
// this could prevent updates within this itemInfo object itself (like title change
// or flag changes). We can create a better diffing logic if we store a clone a snapshot
// of the itemInfo, but that would cause icons to be loaded lazily on the cloned object
// instead of the singleton object.
return false;
}
}
protected final T mActivityContext;
@@ -273,7 +267,11 @@ public abstract class BaseAllAppsAdapter<T extends Context & ActivityContext> ex
AdapterItem adapterItem = mApps.getAdapterItems().get(position);
BubbleTextView icon = (BubbleTextView) holder.itemView;
icon.reset();
icon.applyFromApplicationInfo(adapterItem.itemInfo);
if (adapterItem.itemInfo instanceof AppInfo) {
icon.applyFromApplicationInfo((AppInfo) adapterItem.itemInfo);
} else {
icon.applyFromItemInfoWithIcon(adapterItem.itemInfo);
}
break;
case VIEW_TYPE_EMPTY_SEARCH:
TextView emptyViewText = (TextView) holder.itemView;