refactor: Convert Sched to Kotlin #12301
Conversation
com.ichi2.libanki.sched.Sched
lukstbit
left a comment
There was a problem hiding this comment.
Looks good, just some minor cleanups.
bb98a75 to
bb026c8
Compare
Arthur-Milchior
left a comment
There was a problem hiding this comment.
I probably missed some cleanup, this class is incredibly long. (And I plead guilty for part of it)
Still, I believe a bunch of cleanup that may improve code eventually
| var rlim = _deckRevLimitSingle(deck, false) | ||
| if (!TextUtils.isEmpty(p)) { | ||
| Integer[] parentLims = lims.get(Decks.normalizeName(p)); | ||
| val parentLims = lims[Decks.normalizeName(p)] |
There was a problem hiding this comment.
I'd consider putting the !! here, to make clear that it's directly non null
There was a problem hiding this comment.
This breaks the Assert below
| List<Long> ids = getCol().findCards(search, orderLimit); | ||
| private fun _fillDyn(deck: Deck): List<Long> { | ||
| val terms = deck.getJSONArray("terms").getJSONArray(0) | ||
| var search = terms.getString(0) |
There was a problem hiding this comment.
KotlinCleanup: transform this into val
There was a problem hiding this comment.
This breaks libAnki compat
| private fun _rescheduleRev(card: Card, @BUTTON_TYPE ease: Int) { | ||
| // update interval | ||
| card.setLastIvl(card.getIvl()); | ||
| card.lastIvl = card.ivl |
There was a problem hiding this comment.
KotlinCleanup: Either card.apply or even define it as Card._rescheduleRev.
Same for other methods rescheduling cards
There was a problem hiding this comment.
This breaks libAnki compat
com.ichi2.libanki.sched.Sched
bb026c8 to
df4b952
Compare
|
I don't recommend expending much effort on this file, since reviewing with the v1 scheduler is no longer possible since #11808 |
|
Agreed, just want to get to 0% Java so we can cut down the excess code and hopefully reduce compile times |
|
Merged. If we don't care about cleanup because the code will disappear, no need to wait for the cleanup |
No description provided.