/** * Adds a list of corpus results. Must be called on the UI thread, or before this object is seen * by the UI thread. */ public void addCorpusResults(List<CorpusResult> corpusResults) { if (isClosed()) { for (CorpusResult corpusResult : corpusResults) { corpusResult.close(); } return; } for (CorpusResult corpusResult : corpusResults) { if (DBG) { Log.d( TAG, "addCorpusResult[" + hashCode() + "] corpus:" + corpusResult.getCorpus().getName() + " results:" + corpusResult.getCount()); } if (!mQuery.equals(corpusResult.getUserQuery())) { throw new IllegalArgumentException( "Got result for wrong query: " + mQuery + " != " + corpusResult.getUserQuery()); } Integer pos = mCorpusPositions.get(corpusResult.getCorpus().getName()); if (pos == null) { Log.w(TAG, "Got unexpected CorpusResult from corpus " + corpusResult.getCorpus().getName()); corpusResult.close(); } else { mCorpusResults[pos] = corpusResult; if (corpusResult.getCorpus().isWebCorpus()) { mWebResult = corpusResult; } } } notifyDataSetChanged(); }