コード例 #1
0
 public void buildCorpusGroups() {
   Suggestions suggestions = getSuggestions();
   SuggestionCursor promoted = getCurrentPromotedSuggestions();
   HashSet<String> promotedSuggestions = new HashSet<String>();
   if (promoted != null && promoted.getCount() > 0) {
     promoted.moveTo(0);
     do {
       promotedSuggestions.add(SuggestionUtils.getSuggestionKey(promoted));
     } while (promoted.moveToNext());
   }
   if (suggestions == null) {
     mCorpusGroups = null;
   } else {
     if (mCorpusGroups == null) {
       mCorpusGroups = new ArrayList<SuggestionCursor>();
     } else {
       mCorpusGroups.clear();
     }
     for (CorpusResult result : suggestions.getCorpusResults()) {
       ListSuggestionCursor corpusSuggestions = new ListSuggestionCursor(result.getUserQuery());
       for (int i = 0; i < result.getCount(); ++i) {
         result.moveTo(i);
         if (!result.isWebSearchSuggestion()) {
           if (!promotedSuggestions.contains(SuggestionUtils.getSuggestionKey(result))) {
             corpusSuggestions.add(new SuggestionPosition(result, i));
           }
         }
       }
       if (corpusSuggestions.getCount() > 0) {
         mCorpusGroups.add(corpusSuggestions);
       }
       corpusSuggestions.close();
     }
   }
 }
コード例 #2
0
 @Override
 public Suggestion getChild(int groupPosition, int childPosition) {
   SuggestionCursor c = getGroup(groupPosition);
   if (c != null) {
     c.moveTo(childPosition);
     return new SuggestionPosition(c, childPosition);
   }
   return null;
 }
コード例 #3
0
 private int promotedCount() {
   SuggestionCursor promoted = getCurrentPromotedSuggestions();
   return (promoted == null ? 0 : promoted.getCount());
 }
コード例 #4
0
 @Override
 public int getChildrenCount(int groupPosition) {
   SuggestionCursor group = getGroup(groupPosition);
   return group == null ? 0 : group.getCount();
 }