From 32807aa71b79830ab04957b74b172a888f2ca2f5 Mon Sep 17 00:00:00 2001 From: MohitMali Date: Wed, 26 Jul 2023 17:57:39 +0530 Subject: [PATCH] Fixed search functionality crash if any FT Xapian index not found in any zim file --- .../org/kiwix/kiwixmobile/core/reader/ZimFileReader.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/reader/ZimFileReader.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/reader/ZimFileReader.kt index 42dd73eec..fc03a0451 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/reader/ZimFileReader.kt +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/reader/ZimFileReader.kt @@ -136,8 +136,13 @@ class ZimFileReader constructor( null } - fun searchSuggestions(prefix: String): Search = - searcher.search(Query(prefix)) + fun searchSuggestions(prefix: String): Search? = + try { + searcher.search(Query(prefix)) + } catch (ignore: Exception) { + // to handled the exception if there is no FT Xapian index found in the current zim file + null + } fun getNextSuggestion(suggestionSearch: SuggestionSearch?): List { val suggestionList = mutableListOf()