diff --git a/app/src/main/java/ai/elimu/vitabu/ui/storybook/CoverFragment.java b/app/src/main/java/ai/elimu/vitabu/ui/storybook/CoverFragment.java index 78c77b7..f77a944 100644 --- a/app/src/main/java/ai/elimu/vitabu/ui/storybook/CoverFragment.java +++ b/app/src/main/java/ai/elimu/vitabu/ui/storybook/CoverFragment.java @@ -113,12 +113,14 @@ public void onRangeStart(String utteranceId, int start, int end, int frame) { super.onRangeStart(utteranceId, start, end, frame); Log.i(getClass().getName(), "utteranceId: " + utteranceId + ", start: " + start + ", end: " + end); - - // Highlight the word being spoken - Spannable spannable = new SpannableString(audioText); - BackgroundColorSpan backgroundColorSpan = new BackgroundColorSpan(getResources().getColor(R.color.colorAccent)); - spannable.setSpan(backgroundColorSpan, start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); - audioTextView.setText(spannable); + + if (start >= 0) { + // Highlight the word being spoken + Spannable spannable = new SpannableString(audioText); + BackgroundColorSpan backgroundColorSpan = new BackgroundColorSpan(getResources().getColor(R.color.colorAccent)); + spannable.setSpan(backgroundColorSpan, start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + audioTextView.setText(spannable); + } } @Override @@ -130,6 +132,8 @@ public void onDone(String utteranceId) { if (audioListener != null) { audioListener.onAudioDone(); + } else { + onStop(utteranceId, false); } }