Skip to content

Commit

Permalink
Removed unused class SearchNotes
Browse files Browse the repository at this point in the history
  • Loading branch information
thedroiddiv authored and BrayanDSO committed Sep 25, 2022
1 parent 1da4f52 commit 046f4bb
Showing 1 changed file with 0 additions and 59 deletions.
59 changes: 0 additions & 59 deletions AnkiDroid/src/main/java/com/ichi2/async/CollectionTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,13 @@ import com.ichi2.anki.StudyOptionsFragment.DeckStudyData
import com.ichi2.anki.exception.ConfirmModSchemaException
import com.ichi2.anki.exception.ImportExportException
import com.ichi2.anki.servicelayer.NoteService
import com.ichi2.anki.servicelayer.SearchService.SearchCardsResult
import com.ichi2.libanki.*
import com.ichi2.libanki.Collection
import com.ichi2.libanki.Collection.CheckDatabaseResult
import com.ichi2.libanki.importer.AnkiPackageImporter
import com.ichi2.libanki.sched.DeckDueTreeNode
import com.ichi2.libanki.sched.TreeNode
import com.ichi2.utils.*
import net.ankiweb.rsdroid.BackendFactory
import org.apache.commons.compress.archivers.zip.ZipFile
import timber.log.Timber
import java.io.File
Expand Down Expand Up @@ -438,63 +436,6 @@ open class CollectionTask<Progress, Result>(val task: TaskDelegateBase<Progress,
}
}

class SearchNotes(private val query: String, private val order: SortOrder, private val numCardsToRender: Int, private val column1Index: Int, private val column2Index: Int) : TaskDelegate<List<CardCache>, SearchCardsResult>() {
override fun task(col: Collection, collectionTask: ProgressSenderAndCancelListener<List<CardCache>>): SearchCardsResult {
Timber.d("doInBackgroundSearchCards")
if (collectionTask.isCancelled()) {
Timber.d("doInBackgroundSearchCards was cancelled so return null")
return SearchCardsResult.invalidResult()
}
val searchResult: MutableList<CardCache> = ArrayList()
val searchResult_: List<Long>

if (BackendFactory.defaultLegacySchema) {
searchResult_ = try {
col.findOneCardByNote(query).requireNoNulls()
} catch (e: Exception) {
// exception can occur via normal operation
Timber.w(e)
return SearchCardsResult.error(e)
}
Timber.d("The search found %d cards", searchResult_.size)
var position = 0
for (cid in searchResult_) {
val card = CardCache(cid, col, position++, true)
searchResult.add(card)
}
} else {
searchResult_ = try {
col.findNotes(query, order).requireNoNulls()
} catch (e: Exception) {
// exception can occur via normal operation
Timber.w(e)
return SearchCardsResult.error(e)
}
Timber.d("The search found %d notes", searchResult_.size)
var position = 0
for (nid in searchResult_) {
val card = CardCache(Note(col, nid).firstCard().id, col, position++, false)
searchResult.add(card)
}
}
// Render the first few items
for (i in 0 until Math.min(numCardsToRender, searchResult.size)) {
if (collectionTask.isCancelled()) {
Timber.d("doInBackgroundSearchCards was cancelled so return null")
return SearchCardsResult.invalidResult()
}
searchResult[i].load(false, column1Index, column2Index)
}
// Finish off the task
return if (collectionTask.isCancelled()) {
Timber.d("doInBackgroundSearchCards was cancelled so return null")
SearchCardsResult.invalidResult()
} else {
SearchCardsResult.success(searchResult)
}
}
}

class RenderBrowserQA(private val cards: CardCollection<CardCache>, private val startPos: Int, private val n: Int, private val column1Index: Int, private val column2Index: Int) : TaskDelegate<Int, Pair<CardCollection<CardCache>, List<Long>>?>() {
override fun task(col: Collection, collectionTask: ProgressSenderAndCancelListener<Int>): Pair<CardCollection<CardCache>, List<Long>>? {
Timber.d("doInBackgroundRenderBrowserQA")
Expand Down

0 comments on commit 046f4bb

Please sign in to comment.