mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-13 01:17:21 -04:00
Catching exceptions if any thrown by this method since we are throwing the error when there are corrupted database error and other type of error while getting the searchResult from libzim.
* Fixed the library version issue.
This commit is contained in:
parent
c969695139
commit
2d96cde064
@ -66,7 +66,7 @@ object Versions {
|
|||||||
|
|
||||||
const val assertj_core: String = "3.25.3"
|
const val assertj_core: String = "3.25.3"
|
||||||
|
|
||||||
const val core_testing: String = "2.2.1"
|
const val core_testing: String = "2.2.0"
|
||||||
|
|
||||||
const val fragment_ktx: String = "1.2.5"
|
const val fragment_ktx: String = "1.2.5"
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ object Versions {
|
|||||||
|
|
||||||
const val core_ktx: String = "1.9.0"
|
const val core_ktx: String = "1.9.0"
|
||||||
|
|
||||||
const val libkiwix: String = "2.2.0"
|
const val libkiwix: String = "2.2.1"
|
||||||
|
|
||||||
const val material: String = "1.8.0"
|
const val material: String = "1.8.0"
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ import kotlinx.coroutines.Job
|
|||||||
import kotlinx.coroutines.sync.withLock
|
import kotlinx.coroutines.sync.withLock
|
||||||
import kotlinx.coroutines.yield
|
import kotlinx.coroutines.yield
|
||||||
import org.kiwix.kiwixmobile.core.search.adapter.SearchListItem
|
import org.kiwix.kiwixmobile.core.search.adapter.SearchListItem
|
||||||
|
import org.kiwix.kiwixmobile.core.utils.files.Log
|
||||||
|
|
||||||
data class SearchState(
|
data class SearchState(
|
||||||
val searchTerm: String,
|
val searchTerm: String,
|
||||||
@ -40,6 +41,7 @@ data class SearchState(
|
|||||||
searchResultsWithTerm.searchMutex.withLock {
|
searchResultsWithTerm.searchMutex.withLock {
|
||||||
searchResultsWithTerm.suggestionSearch?.also { yield() }?.let {
|
searchResultsWithTerm.suggestionSearch?.also { yield() }?.let {
|
||||||
val searchResults = mutableListOf<SearchListItem.RecentSearchListItem>()
|
val searchResults = mutableListOf<SearchListItem.RecentSearchListItem>()
|
||||||
|
try {
|
||||||
if (job?.isActive == false) {
|
if (job?.isActive == false) {
|
||||||
// if the previous job is cancel then do not execute the code
|
// if the previous job is cancel then do not execute the code
|
||||||
return@getVisibleResults searchResults
|
return@getVisibleResults searchResults
|
||||||
@ -58,6 +60,13 @@ data class SearchState(
|
|||||||
val entry = searchIterator.next()
|
val entry = searchIterator.next()
|
||||||
searchResults.add(SearchListItem.RecentSearchListItem(entry.title, entry.path))
|
searchResults.add(SearchListItem.RecentSearchListItem(entry.title, entry.path))
|
||||||
}
|
}
|
||||||
|
} catch (ignore: Exception) {
|
||||||
|
Log.e(
|
||||||
|
"SearchState",
|
||||||
|
"Could not get the searched result for searchTerm $searchTerm\n" +
|
||||||
|
"Original exception = $ignore"
|
||||||
|
)
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Returns null if there are no suggestions left in the iterator.
|
* Returns null if there are no suggestions left in the iterator.
|
||||||
* We check this in SearchFragment to avoid unnecessary data loading
|
* We check this in SearchFragment to avoid unnecessary data loading
|
||||||
|
Loading…
x
Reference in New Issue
Block a user