Skip to content

Commit

Permalink
refactor: extract baseUrl to viewModel
Browse files Browse the repository at this point in the history
  • Loading branch information
BrayanDSO committed May 27, 2024
1 parent 32aa338 commit 8007834
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import com.ichi2.anki.R
import com.ichi2.anki.ViewerResourceHandler
import com.ichi2.anki.dialogs.TtsVoicesDialogFragment
import com.ichi2.anki.localizedErrorMessage
import com.ichi2.anki.pages.AnkiServer
import com.ichi2.anki.snackbar.showSnackbar
import com.ichi2.anki.utils.ext.packageManager
import com.ichi2.compat.CompatHelper.Companion.resolveActivityCompat
Expand Down Expand Up @@ -89,7 +88,7 @@ abstract class CardViewerFragment(@LayoutRes layout: Int) : Fragment(layout) {
}

loadDataWithBaseURL(
"http://${AnkiServer.LOCALHOST}/",
viewModel.baseUrl(),
stdHtml(requireContext(), Themes.currentTheme.isNightMode),
"text/html",
null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import com.ichi2.anki.cardviewer.MediaErrorHandler
import com.ichi2.anki.cardviewer.SoundErrorBehavior
import com.ichi2.anki.cardviewer.SoundErrorListener
import com.ichi2.anki.launchCatchingIO
import com.ichi2.anki.pages.AnkiServer
import com.ichi2.libanki.Card
import com.ichi2.libanki.Sound
import com.ichi2.libanki.TtsPlayer
Expand Down Expand Up @@ -78,6 +79,8 @@ abstract class CardViewerViewModel(
*/
abstract fun onPageFinished(isAfterRecreation: Boolean)

open fun baseUrl(): String = "http://${AnkiServer.LOCALHOST}/"

fun setSoundPlayerEnabled(isEnabled: Boolean) {
cardMediaPlayer.isEnabled = isEnabled
}
Expand Down

0 comments on commit 8007834

Please sign in to comment.