summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2015-08-10 22:59:20 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-08-10 22:59:20 +0000
commit0396828d05a9f25791a4b9324ee5a23b7481b2e2 (patch)
tree6c211bc54fb2b57bfbd7d63ec3d3599c51ffb007 /src/com/android/launcher3/allapps/AlphabeticalAppsList.java
parent0c2c31336593685ad1336134f6a895971f267555 (diff)
parenta1ee659e748b02ed74d8cafd3796a5c8ce5f1c44 (diff)
downloadandroid_packages_apps_Trebuchet-0396828d05a9f25791a4b9324ee5a23b7481b2e2.tar.gz
android_packages_apps_Trebuchet-0396828d05a9f25791a4b9324ee5a23b7481b2e2.tar.bz2
android_packages_apps_Trebuchet-0396828d05a9f25791a4b9324ee5a23b7481b2e2.zip
am a1ee659e: Merge "Adding market search." into ub-launcher3-burnaby
* commit 'a1ee659e748b02ed74d8cafd3796a5c8ce5f1c44': Adding market search.
Diffstat (limited to 'src/com/android/launcher3/allapps/AlphabeticalAppsList.java')
-rw-r--r--src/com/android/launcher3/allapps/AlphabeticalAppsList.java59
1 files changed, 49 insertions, 10 deletions
diff --git a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
index 01e0f0cb9..ffe39cdd3 100644
--- a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
+++ b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
@@ -82,12 +82,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
@@ -112,14 +112,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;
@@ -130,6 +130,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;
+ }
}
/**
@@ -168,6 +189,7 @@ public class AlphabeticalAppsList {
private int mNumAppsPerRow;
private int mNumPredictedAppsPerRow;
private int mNumAppRowsInAdapter;
+ private boolean mDisableEmptyText;
public AlphabeticalAppsList(Context context) {
mLauncher = (Launcher) context;
@@ -195,6 +217,13 @@ public class AlphabeticalAppsList {
}
/**
+ * Disables the empty text message when there are no search results.
+ */
+ public void disableEmptyText() {
+ mDisableEmptyText = true;
+ }
+
+ /**
* Returns all the apps.
*/
public List<AppInfo> getApps() {
@@ -223,17 +252,17 @@ public class AlphabeticalAppsList {
}
/**
- * Returns the number of applications in this list.
+ * Returns the number of rows of applications (not including predictions)
*/
- public int getSize() {
- return mFilteredApps.size();
+ public int getNumAppRows() {
+ return mNumAppRowsInAdapter;
}
/**
- * Returns the number of rows of applications (not including predictions)
+ * Returns the number of applications in this list.
*/
- public int getNumAppRows() {
- return mNumAppRowsInAdapter;
+ public int getNumFilteredApps() {
+ return mFilteredApps.size();
}
/**
@@ -458,6 +487,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();