mirror of
https://github.com/ankidroid/Anki-Android.git
synced 2024-09-20 12:02:16 +02:00
fixed: deck search not scrolling to current deck in statistics (#12030)
* fixed: deck search not scrolling to current deck in statistics
This commit is contained in:
parent
8721e8ac30
commit
0fb16b89cd
@ -238,6 +238,10 @@ class DeckSpinnerSelection(
|
||||
decks.removeIf { x: SelectableDeck -> x.deckId == Consts.DEFAULT_DECK_ID }
|
||||
}
|
||||
val dialog = DeckSelectionDialog.newInstance(context.getString(R.string.search_deck), null, false, decks)
|
||||
val did: DeckId? = (context as? Statistics)?.getCurrentDeckId()
|
||||
if (did != null) {
|
||||
dialog.requireArguments().putLong("currentDeckId", did)
|
||||
}
|
||||
AnkiActivity.showDialogFragment(mFragmentManagerSupplier.getFragmentManager(), dialog)
|
||||
}
|
||||
|
||||
|
@ -489,6 +489,10 @@ class Statistics : NavigationDrawerActivity(), DeckSelectionListener, SubtitleLi
|
||||
}
|
||||
}
|
||||
|
||||
fun getCurrentDeckId(): DeckId {
|
||||
return mStatsDeckId
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val TODAYS_STATS_TAB_POSITION = 0
|
||||
const val FORECAST_TAB_POSITION = 1
|
||||
|
@ -94,6 +94,11 @@ open class DeckSelectionDialog : AnalyticsDialogFragment() {
|
||||
val adapter = DecksArrayAdapter(decks)
|
||||
recyclerView.adapter = adapter
|
||||
adjustToolbar(dialogView, adapter)
|
||||
val args = requireArguments()
|
||||
if (args.containsKey("currentDeckId")) {
|
||||
val did = args.getLong("currentDeckId")
|
||||
recyclerView.scrollToPosition(getPositionOfDeck(did, adapter.getCurrentlyDisplayedDecks()))
|
||||
}
|
||||
mDialog = MaterialDialog(requireActivity())
|
||||
.neutralButton(R.string.dialog_cancel) // Shouldn't it be negative button?
|
||||
.customView(view = dialogView, noVerticalPadding = true)
|
||||
@ -105,6 +110,9 @@ open class DeckSelectionDialog : AnalyticsDialogFragment() {
|
||||
return mDialog!!
|
||||
}
|
||||
|
||||
private fun getPositionOfDeck(did: DeckId, decks: List<SelectableDeck>) =
|
||||
decks.indexOfFirst { it.deckId == did }
|
||||
|
||||
private fun getSummaryMessage(arguments: Bundle): String? {
|
||||
return arguments.getString(SUMMARY_MESSAGE)
|
||||
}
|
||||
@ -282,6 +290,10 @@ open class DeckSelectionDialog : AnalyticsDialogFragment() {
|
||||
return DecksFilter()
|
||||
}
|
||||
|
||||
fun getCurrentlyDisplayedDecks(): List<SelectableDeck> {
|
||||
return mCurrentlyDisplayedDecks
|
||||
}
|
||||
|
||||
private inner class DecksFilter : TypedFilter<SelectableDeck>(mAllDecksList) {
|
||||
override fun filterResults(constraint: CharSequence, items: List<SelectableDeck>): List<SelectableDeck> {
|
||||
val filterPattern = constraint.toString().lowercase(Locale.getDefault()).trim { it <= ' ' }
|
||||
|
Loading…
Reference in New Issue
Block a user