Fix App crash while downloading transcripts
package org.edx.mobile.view;
import android.annotation.SuppressLint;
+import android.app.Activity;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.Handler;
@@ -181,15 +182,18 @@ public abstract class BaseCourseUnitVideoFragment extends CourseUnitFragment
@Override
public void downloadTranscript() {
+ Activity activity = getActivity();
+ if (activity != null) {
TranscriptModel transcript = getTranscriptModel();
- String transcriptUrl = LocaleUtils.getTranscriptURL(getActivity(), transcript);
+ String transcriptUrl = LocaleUtils.getTranscriptURL(activity, transcript);
transcriptManager.downloadTranscriptsForVideo(transcriptUrl, (TimedTextObject transcriptTimedTextObject) -> {
subtitlesObj = transcriptTimedTextObject;
- if (!getActivity().isDestroyed()) {
+ if (!activity.isDestroyed()) {
initTranscripts();
}
});
}
+ }
@Override
public void updateTranscriptCallbackStatus(boolean attach) {
