Skip to content
This repository has been archived by the owner on Sep 10, 2020. It is now read-only.

Commit

Permalink
Merge pull request #99 from JakeWharton/jw/no-dir
Browse files Browse the repository at this point in the history
Do not attempt to record if the output dir fails to create.
  • Loading branch information
JakeWharton committed Apr 3, 2016
2 parents bf44dca + be57479 commit a75b789
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import android.util.DisplayMetrics;
import android.view.Surface;
import android.view.WindowManager;
import android.widget.Toast;
import com.google.android.gms.analytics.HitBuilders;
import java.io.File;
import java.io.IOException;
Expand All @@ -49,6 +50,7 @@
import static android.media.MediaRecorder.VideoEncoder.H264;
import static android.media.MediaRecorder.VideoSource.SURFACE;
import static android.os.Environment.DIRECTORY_MOVIES;
import static android.widget.Toast.LENGTH_SHORT;

final class RecordingSession {
static final int NOTIFICATION_ID = 522592;
Expand Down Expand Up @@ -191,9 +193,11 @@ private RecordingInfo getRecordingInfo() {
private void startRecording() {
Timber.d("Starting screen recording...");

if (!outputRoot.mkdirs()) {
if (!outputRoot.exists() && !outputRoot.mkdirs()) {
Timber.e("Unable to create output directory '%s'.", outputRoot.getAbsolutePath());
// We're probably about to crash, but at least the log will indicate as to why.
Toast.makeText(context, "Unable to create output directory.\nCannot record screen.",
LENGTH_SHORT).show();
return;
}

RecordingInfo recordingInfo = getRecordingInfo();
Expand Down

0 comments on commit a75b789

Please sign in to comment.