Fix "null" string displaying in the breadcrumbs of search results. am: 24096bc912 am: fd36d87e44
am: a07fb16bd2

Change-Id: Iea66693bdd8c2b48c8373ce6a6077c0b46c4e71e
diff --git a/src/com/android/settings/intelligence/search/SearchViewHolder.java b/src/com/android/settings/intelligence/search/SearchViewHolder.java
index d669e6d..9123a70 100644
--- a/src/com/android/settings/intelligence/search/SearchViewHolder.java
+++ b/src/com/android/settings/intelligence/search/SearchViewHolder.java
@@ -96,7 +96,12 @@
             breadcrumb = context.getString(R.string.search_breadcrumb_connector,
                     breadcrumb, result.breadcrumbs.get(i));
         }
-        breadcrumbView.setText(breadcrumb);
-        breadcrumbView.setVisibility(View.VISIBLE);
+
+        if (TextUtils.isEmpty(breadcrumb) || TextUtils.isEmpty(breadcrumb.trim())) {
+            breadcrumbView.setVisibility(View.GONE);
+        } else {
+            breadcrumbView.setText(breadcrumb);
+            breadcrumbView.setVisibility(View.VISIBLE);
+        }
     }
-}
\ No newline at end of file
+}
diff --git a/src/com/android/settings/intelligence/search/sitemap/SiteMapManager.java b/src/com/android/settings/intelligence/search/sitemap/SiteMapManager.java
index 8811624..6575cab 100644
--- a/src/com/android/settings/intelligence/search/sitemap/SiteMapManager.java
+++ b/src/com/android/settings/intelligence/search/sitemap/SiteMapManager.java
@@ -62,7 +62,9 @@
             Log.w(TAG, "SiteMap is not initialized yet, skipping");
             return breadcrumbs;
         }
-        breadcrumbs.add(screenTitle);
+        if (!TextUtils.isEmpty(screenTitle)) {
+            breadcrumbs.add(screenTitle);
+        }
         String currentClass = clazz;
         String currentTitle = screenTitle;
         // Look up current page's parent, if found add it to breadcrumb string list, and repeat.
@@ -74,7 +76,10 @@
                 }
                 return breadcrumbs;
             }
-            breadcrumbs.add(0, pair.getParentTitle());
+            final String parentTitle = pair.getParentTitle();
+            if (!TextUtils.isEmpty(parentTitle)) {
+                breadcrumbs.add(0, parentTitle);
+            }
             currentClass = pair.getParentClass();
             currentTitle = pair.getParentTitle();
         }
@@ -123,4 +128,4 @@
         return null;
     }
 
-}
\ No newline at end of file
+}