File tree 2 files changed +17
-2
lines changed
app/src/main/java/fr/gaulupeau/apps/Poche
2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -31,23 +31,34 @@ public class FtsDao {
31
31
"article_content_after_delete_tr"
32
32
};
33
33
34
+ public static boolean isFtsSupported () {
35
+ // https://www.sqlite.org/changes.html#version_3_7_9 is required for the 'content' option
36
+ return Build .VERSION .SDK_INT >= Build .VERSION_CODES .JELLY_BEAN ; // https://stackoverflow.com/a/4377116
37
+ }
38
+
34
39
public static String getQueryString () {
35
40
return "select " + COLUMN_ID + " from " + TABLE_NAME + " where " + TABLE_NAME + " match " ;
36
41
}
37
42
38
43
public static void createAll (Database db , boolean ifNotExists ) {
44
+ if (!isFtsSupported ()) return ;
45
+
39
46
createViewForFts (db , ifNotExists );
40
47
createTable (db , ifNotExists );
41
48
createTriggers (db , ifNotExists );
42
49
}
43
50
44
51
public static void dropAll (Database db , boolean ifExists ) {
52
+ if (!isFtsSupported ()) return ;
53
+
45
54
dropTriggers (db , ifExists );
46
55
dropTable (db , ifExists );
47
56
dropViewForFts (db , ifExists );
48
57
}
49
58
50
59
public static void deleteAllArticles (Database db ) {
60
+ if (!isFtsSupported ()) return ;
61
+
51
62
dropTable (db , true );
52
63
createTable (db , true );
53
64
}
Original file line number Diff line number Diff line change @@ -219,8 +219,12 @@ private QueryBuilder<Article> getQueryBuilder() {
219
219
}
220
220
221
221
if (!TextUtils .isEmpty (searchQuery )) {
222
- qb .where (new WhereCondition .PropertyCondition (ArticleDao .Properties .Id , " IN (" +
223
- FtsDao .getQueryString () + DatabaseUtils .sqlEscapeString (searchQuery ) + ")" ));
222
+ if (FtsDao .isFtsSupported ()) {
223
+ qb .where (new WhereCondition .PropertyCondition (ArticleDao .Properties .Id , " IN (" +
224
+ FtsDao .getQueryString () + DatabaseUtils .sqlEscapeString (searchQuery ) + ")" ));
225
+ } else {
226
+ qb .where (ArticleDao .Properties .Title .like ("%" + searchQuery + "%" ));
227
+ }
224
228
}
225
229
226
230
switch (sortOrder ) {
You can’t perform that action at this time.
0 commit comments