Skip to content

Commit

Permalink
fix: previewer crash when cast to CardTemplatePreviewer
Browse files Browse the repository at this point in the history
  • Loading branch information
BrayanDSO committed Dec 10, 2023
1 parent 1747ac9 commit 349e42c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 15 deletions.
4 changes: 0 additions & 4 deletions AnkiDroid/src/main/java/com/ichi2/anki/Reviewer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1591,10 +1591,6 @@ open class Reviewer :
}
}

override fun javaScriptFunction(): AnkiDroidJsAPI {
return AnkiDroidJsAPI(this)
}

override fun getCardDataForJsApi(): AnkiDroidJsAPI.CardDataForJsApi {
val cardDataForJsAPI = AnkiDroidJsAPI.CardDataForJsApi().apply {
newCardCount = mNewCount.toString()
Expand Down
13 changes: 2 additions & 11 deletions AnkiDroid/src/main/java/com/ichi2/anki/ReviewerServer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,16 @@

package com.ichi2.anki

import androidx.fragment.app.FragmentActivity
import anki.frontend.SetSchedulingStatesRequest
import com.ichi2.anki.pages.AnkiServer
import com.ichi2.utils.AssetHelper
import timber.log.Timber
import java.io.File
import java.io.FileInputStream

class ReviewerServer(activity: FragmentActivity, val mediaDir: String) : AnkiServer(activity) {
class ReviewerServer(activity: AbstractFlashcardViewer, private val mediaDir: String) : AnkiServer(activity) {
var reviewerHtml: String = ""
private val jsApi = if (activity is Reviewer) {
reviewer().javaScriptFunction()
} else {
cardTemplatePreviewer().javaScriptFunction()
}
private val jsApi = activity.javaScriptFunction()

override fun start() {
super.start()
Expand Down Expand Up @@ -102,10 +97,6 @@ class ReviewerServer(activity: FragmentActivity, val mediaDir: String) : AnkiSer
return (activity as Reviewer)
}

private fun cardTemplatePreviewer(): CardTemplatePreviewer {
return (activity as CardTemplatePreviewer)
}

private fun getSchedulingStatesWithContext(): ByteArray {
val state = reviewer().queueState ?: return ByteArray(0)
return state.schedulingStatesWithContext().toBuilder()
Expand Down

0 comments on commit 349e42c

Please sign in to comment.