Fix code review comments
Addresses code review comments on I6e25b77e73ca7b7b6869c283e2496bfa14242248
Change-Id: I8420221cc95e33d0b0b6f070814c1cf92cbb667a
diff --git a/src/com/android/quicksearchbox/Suggestions.java b/src/com/android/quicksearchbox/Suggestions.java
index ab849d8..5102e1f 100644
--- a/src/com/android/quicksearchbox/Suggestions.java
+++ b/src/com/android/quicksearchbox/Suggestions.java
@@ -34,8 +34,9 @@
private static final boolean DBG = false;
private static final String TAG = "QSB.Suggestions";
- private static int id = 0;
- private int mId;
+ private static int sId = 0;
+ // Object ID for debugging
+ private final int mId;
private final int mMaxPromoted;
@@ -83,12 +84,10 @@
mExpectedCorpora = expectedCorpora;
mCorpusResults = new ArrayList<CorpusResult>(mExpectedCorpora.size());
mPromoted = null; // will be set by updatePromoted()
+ mId = sId++;
if (DBG) {
- mId = id++;
- Log.v(TAG, "new Suggestions [" + mId + "] query \"" + query + "\" expected corpora:");
- for(Corpus c : mExpectedCorpora) {
- Log.v(TAG, " " + c.getName());
- }
+ Log.d(TAG, "new Suggestions [" + mId + "] query \"" + query
+ + "\" expected corpora: " + mExpectedCorpora);
}
}
@@ -249,18 +248,22 @@
+ mMaxPromoted + ") = " + mPromoted);
}
} else {
- mPromoted = null;
- for (CorpusResult result : mCorpusResults) {
- if (result.getCorpus() == mSingleCorpusFilter) {
- mPromoted = result;
- }
- }
+ mPromoted = getCorpusResult(mSingleCorpusFilter);
if (mPromoted == null) {
mPromoted = new ListSuggestionCursor(mQuery);
}
}
}
+ private CorpusResult getCorpusResult(Corpus corpus) {
+ for (CorpusResult result : mCorpusResults) {
+ if (result.getCorpus().equals(mSingleCorpusFilter)) {
+ return result;
+ }
+ }
+ return null;
+ }
+
/**
* Gets the number of source results.
* Must be called on the UI thread, or before this object is seen by the UI thread.