Adding market search.

Change-Id: Id41615653cd4fa76213add4595418ad0cc6e7852
This commit is contained in:
Winson Chung authored and Winson committed 2015-08-06 12:22:38 -07:00
1 parent d1ea63f24a
commit bedf9232eb
27 files changed
+327 -88

No files matched your search

@@ -81,12 +81,12 @@ public class AlphabeticalAppsList {
public int position;
// The type of this item
public int viewType;
// The row that this item shows up on
public int rowIndex;
/** Section & App properties */
// The section for this item
public SectionInfo sectionInfo;
// The row that this item shows up on
public int rowIndex;
/** App-only properties */
// The section name of this app. Note that there can be multiple items with different
@@ -111,14 +111,14 @@ public class AlphabeticalAppsList {
}
public static AdapterItem asPredictedApp(int pos, SectionInfo section, String sectionName,
int sectionAppIndex, AppInfo appInfo, int appIndex) {
int sectionAppIndex, AppInfo appInfo, int appIndex) {
AdapterItem item = asApp(pos, section, sectionName, sectionAppIndex, appInfo, appIndex);
item.viewType = AllAppsGridAdapter.PREDICTION_ICON_VIEW_TYPE;
return item;
}
public static AdapterItem asApp(int pos, SectionInfo section, String sectionName,
int sectionAppIndex, AppInfo appInfo, int appIndex) {
int sectionAppIndex, AppInfo appInfo, int appIndex) {
AdapterItem item = new AdapterItem();
item.viewType = AllAppsGridAdapter.ICON_VIEW_TYPE;
item.position = pos;
@@ -129,6 +129,27 @@ public class AlphabeticalAppsList {
item.appIndex = appIndex;
return item;
}
public static AdapterItem asEmptySearch(int pos) {
AdapterItem item = new AdapterItem();
item.viewType = AllAppsGridAdapter.EMPTY_SEARCH_VIEW_TYPE;
item.position = pos;
return item;
}
public static AdapterItem asDivider(int pos) {
AdapterItem item = new AdapterItem();
item.viewType = AllAppsGridAdapter.SEARCH_MARKET_DIVIDER_VIEW_TYPE;
item.position = pos;
return item;
}
public static AdapterItem asMarketSearch(int pos) {
AdapterItem item = new AdapterItem();
item.viewType = AllAppsGridAdapter.SEARCH_MARKET_VIEW_TYPE;
item.position = pos;
return item;
}
}
/**
@@ -167,6 +188,7 @@ public class AlphabeticalAppsList {
private int mNumAppsPerRow;
private int mNumPredictedAppsPerRow;
private int mNumAppRowsInAdapter;
private boolean mDisableEmptyText;
public AlphabeticalAppsList(Context context) {
mLauncher = (Launcher) context;
@@ -193,6 +215,13 @@ public class AlphabeticalAppsList {
mAdapter = adapter;
}
/**
* Disables the empty text message when there are no search results.
*/
public void disableEmptyText() {
mDisableEmptyText = true;
}
/**
* Returns all the apps.
*/
@@ -221,13 +250,6 @@ public class AlphabeticalAppsList {
return mAdapterItems;
}
/**
* Returns the number of applications in this list.
*/
public int getSize() {
return mFilteredApps.size();
}
/**
* Returns the number of rows of applications (not including predictions)
*/
@@ -235,6 +257,13 @@ public class AlphabeticalAppsList {
return mNumAppRowsInAdapter;
}
/**
* Returns the number of applications in this list.
*/
public int getNumFilteredApps() {
return mFilteredApps.size();
}
/**
* Returns whether there are is a filter set.
*/
@@ -457,6 +486,16 @@ public class AlphabeticalAppsList {
mFilteredApps.add(info);
}
// Append the search market item if we are currently searching
if (hasFilter()) {
if (hasNoFilteredResults()) {
mAdapterItems.add(AdapterItem.asEmptySearch(position++));
} else {
mAdapterItems.add(AdapterItem.asDivider(position++));
}
mAdapterItems.add(AdapterItem.asMarketSearch(position++));
}
// Merge multiple sections together as requested by the merge strategy for this device
mergeSections();