Increase suggestion count

This commit is contained in:
seven332 committed 2018-12-14 15:49:11 +08:00
1 parent 0553fda3fa
commit 70ceb83205
2 files changed
+4 -4

No files matched your search

@@ -166,7 +166,7 @@ public class SearchBar extends CardView implements View.OnClickListener,
private void updateSuggestions() {
String prefix = mEditText.getText().toString();
String[] suggestions = mSearchDatabase.getSuggestions(prefix);
String[] suggestions = mSearchDatabase.getSuggestions(prefix, 128);
mSuggestionList.clear();
Collections.addAll(mSuggestionList, suggestions);
if (mSuggestionList.size() == 0) {
@@ -57,10 +57,10 @@ public final class SearchDatabase {
mDatabase = databaseHelper.getWritableDatabase();
}
public String[] getSuggestions(String prefix) {
public String[] getSuggestions(String prefix, int limit) {
List<String> queryList = new LinkedList<>();
limit = Math.max(0, limit);
// TODO add limit
StringBuilder sb = new StringBuilder();
sb.append("SELECT * FROM ").append(TABLE_SUGGESTIONS);
if (!TextUtils.isEmpty(prefix)) {
@@ -68,7 +68,7 @@ public final class SearchDatabase {
.append(SqlUtils.sqlEscapeString(prefix)).append("%'");
}
sb.append(" ORDER BY ").append(COLUMN_DATE).append(" DESC")
.append(" LIMIT 5");
.append(" LIMIT ").append(limit);
Cursor cursor = mDatabase.rawQuery(sb.toString(), null);
int queryIndex = cursor.getColumnIndex(COLUMN_QUERY);
if (cursor.moveToFirst()) {