Skip to content

Commit cd7fbf8

Browse files
committed
Improved JavaScript TTS initialization process
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.
1 parent bbc78fa commit cd7fbf8

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

AnkiDroid/src/main/java/com/ichi2/anki/AbstractFlashcardViewer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ public abstract class AbstractFlashcardViewer extends NavigationDrawerActivity i
393393
private boolean mFocusTypeAnswer;
394394

395395
/** Text to speech */
396-
private JavaScriptTTS mTalker = new JavaScriptTTS(AbstractFlashcardViewer.this);
396+
private JavaScriptTTS mTalker = new JavaScriptTTS();
397397

398398
// ----------------------------------------------------------------------------
399399
// LISTENERS

AnkiDroid/src/main/java/com/ichi2/anki/JavaScriptTTS.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ public class JavaScriptTTS implements TextToSpeech.OnInitListener {
3838
private static boolean mTtsOk;
3939
private static final Bundle mTtsParams = new Bundle();
4040

41-
JavaScriptTTS(Context context) {
42-
mTts = new TextToSpeech(context, this);
41+
JavaScriptTTS() {
42+
Context mContext = AnkiDroidApp.getInstance().getApplicationContext();
43+
mTts = new TextToSpeech(mContext, this);
4344
}
4445

4546
/** OnInitListener method to receive the TTS engine status */

0 commit comments

Comments
 (0)