mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-03 09:26:51 +00:00
Implementing support for item diffing instead of creating out the
complete UI on every update Bug: 229860311 Test: Verified locally Change-Id: I5712b5d76878a0ed72cc1392ede59b3778b7a1dc
This commit is contained in:
@@ -88,10 +88,8 @@ public abstract class BaseAllAppsAdapter<T extends Context & ActivityContext> ex
|
||||
*/
|
||||
public static class AdapterItem {
|
||||
/** Common properties */
|
||||
// The index of this adapter item in the list
|
||||
public int position;
|
||||
// The type of this item
|
||||
public int viewType;
|
||||
public final int viewType;
|
||||
|
||||
// The row that this item shows up on
|
||||
public int rowIndex;
|
||||
@@ -100,50 +98,37 @@ public abstract class BaseAllAppsAdapter<T extends Context & ActivityContext> ex
|
||||
// The associated ItemInfoWithIcon for the item
|
||||
public AppInfo itemInfo = null;
|
||||
|
||||
public AdapterItem(int viewType) {
|
||||
this.viewType = viewType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory method for AppIcon AdapterItem
|
||||
*/
|
||||
public static AdapterItem asApp(int pos, AppInfo appInfo) {
|
||||
AdapterItem item = new AdapterItem();
|
||||
item.viewType = VIEW_TYPE_ICON;
|
||||
item.position = pos;
|
||||
public static AdapterItem asApp(AppInfo appInfo) {
|
||||
AdapterItem item = new AdapterItem(VIEW_TYPE_ICON);
|
||||
item.itemInfo = appInfo;
|
||||
return item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory method for empty search results view
|
||||
*/
|
||||
public static AdapterItem asEmptySearch(int pos) {
|
||||
AdapterItem item = new AdapterItem();
|
||||
item.viewType = VIEW_TYPE_EMPTY_SEARCH;
|
||||
item.position = pos;
|
||||
return item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory method for a dividerView in AllAppsSearch
|
||||
*/
|
||||
public static AdapterItem asAllAppsDivider(int pos) {
|
||||
AdapterItem item = new AdapterItem();
|
||||
item.viewType = VIEW_TYPE_ALL_APPS_DIVIDER;
|
||||
item.position = pos;
|
||||
return item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory method for a market search button
|
||||
*/
|
||||
public static AdapterItem asMarketSearch(int pos) {
|
||||
AdapterItem item = new AdapterItem();
|
||||
item.viewType = VIEW_TYPE_SEARCH_MARKET;
|
||||
item.position = pos;
|
||||
return item;
|
||||
}
|
||||
|
||||
protected boolean isCountedForAccessibility() {
|
||||
return viewType == VIEW_TYPE_ICON || viewType == VIEW_TYPE_SEARCH_MARKET;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the items represent the same object
|
||||
*/
|
||||
public boolean isSameAs(AdapterItem other) {
|
||||
return (other.viewType != viewType) && (other.getClass() == getClass());
|
||||
}
|
||||
|
||||
/**
|
||||
* This is called only if {@link #isSameAs} returns true to check if the contents are same
|
||||
* as well. Returning true will prevent redrawing of thee item.
|
||||
*/
|
||||
public boolean isContentSame(AdapterItem other) {
|
||||
return itemInfo == null && other.itemInfo == null;
|
||||
}
|
||||
}
|
||||
|
||||
protected final T mActivityContext;
|
||||
|
||||
Reference in New Issue
Block a user