Skip to content

Commit

Permalink
Removed redundant oldCardID attribute, and corresponding simplificati…
Browse files Browse the repository at this point in the history
…ons.
  • Loading branch information
Scapesfear committed Jan 13, 2025
1 parent 7b4a64a commit ae2957c
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions AnkiDroid/src/main/java/com/ichi2/anki/CardBrowser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ open class CardBrowser :
private lateinit var deckSpinnerSelection: DeckSpinnerSelection
private var lastSelectedPosition = 0
private var oldCardTopOffset: Int = 0
private var oldCardId: Long? = null

@VisibleForTesting
lateinit var cardsListView: RecyclerView
Expand Down Expand Up @@ -356,14 +355,12 @@ open class CardBrowser :
if (viewModel.isInMultiSelectMode && viewModel.lastSelectedId != null) {
viewModel.selectRowsBetween(viewModel.lastSelectedId!!, id)
} else {
launchCatchingTask {
val position = cardsAdapter.getPositionForId(id)
val position = cardsAdapter.getPositionForId(id)

lastSelectedPosition = position
saveScrollingState(position)
lastSelectedPosition = position
saveScrollingState(position)

viewModel.toggleRowSelection(id)
}
viewModel.toggleRowSelection(id)
}
}

Expand Down Expand Up @@ -1921,9 +1918,8 @@ open class CardBrowser :
): Intent = NoteEditorLauncher.AddNoteFromCardBrowser(viewModel).getIntent(context)
}

private suspend fun saveScrollingState(position: Int) {
// Save the current card id and the top offset of the card
oldCardId = viewModel.queryCardIdAtPosition(position)
private fun saveScrollingState(position: Int) {
// Save the top offset of the card
oldCardTopOffset = viewModel.calculateTopOffset(cardsListView, position)
}

Expand Down

0 comments on commit ae2957c

Please sign in to comment.