Skip to content

Commit

Permalink
Improved JavaScript TTS initialization process
Browse files Browse the repository at this point in the history
Fixed a problem that null may be passed
as an argument when initializing JavaScriptTTS.
Changed to refer to context from within the class
instead of the argument when initializing JavaScriptTTS.
  • Loading branch information
mikunimaru committed Jul 7, 2021
1 parent bbc78fa commit cd7fbf8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ public abstract class AbstractFlashcardViewer extends NavigationDrawerActivity i
private boolean mFocusTypeAnswer;

/** Text to speech */
private JavaScriptTTS mTalker = new JavaScriptTTS(AbstractFlashcardViewer.this);
private JavaScriptTTS mTalker = new JavaScriptTTS();

// ----------------------------------------------------------------------------
// LISTENERS
Expand Down
5 changes: 3 additions & 2 deletions AnkiDroid/src/main/java/com/ichi2/anki/JavaScriptTTS.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ public class JavaScriptTTS implements TextToSpeech.OnInitListener {
private static boolean mTtsOk;
private static final Bundle mTtsParams = new Bundle();

JavaScriptTTS(Context context) {
mTts = new TextToSpeech(context, this);
JavaScriptTTS() {
Context mContext = AnkiDroidApp.getInstance().getApplicationContext();
mTts = new TextToSpeech(mContext, this);
}

/** OnInitListener method to receive the TTS engine status */
Expand Down

0 comments on commit cd7fbf8

Please sign in to comment.