Allows double quote in search

This commit is contained in:
tom79 2019-08-19 16:02:31 +02:00
parent a64f31cffe
commit 4c550ea3b0
1 changed files with 13 additions and 6 deletions

View File

@ -154,13 +154,20 @@ public class TimelineCacheDAO {
try {
Cursor c;
if (word != null){
String[] searches = word.split(" ");
StringBuilder query = new StringBuilder(" (");
for(String search: searches){
query.append(Sqlite.COL_CACHE + " LIKE '%").append(search).append("%' OR ");
StringBuilder query;
if( !word.contains("\"")) {
String[] searches = word.split(" ");
query = new StringBuilder(" (");
for (String search : searches) {
query.append(Sqlite.COL_CACHE + " LIKE '%").append(search).append("%' OR ");
}
query = new StringBuilder(query.substring(0, query.length() - 3));
query.append(") ");
}else{
String search = word.replace("\"","");
query = new StringBuilder(Sqlite.COL_CACHE + " LIKE '%").append(search).append("%'");
}
query = new StringBuilder(query.substring(0, query.length() - 3));
query.append(") ");
if (max_id != null) {
c = db.query(Sqlite.TABLE_TIMELINE_CACHE, null, Sqlite.COL_INSTANCE + " = \"" + instance + "\" AND " + Sqlite.COL_USER_ID + " = \"" + userId + "\" AND " + Sqlite.COL_STATUS_ID + " < '" + max_id + "' AND " + query, null, null, null, Sqlite.COL_STATUS_ID + " DESC", "40");
return cursorToListStatus(c);