Merge branch 'audiorecorder-1.1.60'

This commit is contained in:
Alexey Kuznetsov 2016-10-08 15:00:40 +03:00
commit 6232ef0f96
2 changed files with 40 additions and 31 deletions

View file

@ -8,8 +8,8 @@ android {
applicationId "com.github.axet.audiorecorder"
minSdkVersion 16
targetSdkVersion 23
versionCode 81
versionName "1.1.59"
versionCode 82
versionName "1.1.60"
}
signingConfigs {
release {

View file

@ -229,12 +229,16 @@ public class RecordingActivity extends AppCompatActivity {
@Override
public void onClick(View v) {
stopRecording(getString(R.string.encoding));
encoding(new Runnable() {
@Override
public void run() {
finish();
}
});
try {
encoding(new Runnable() {
@Override
public void run() {
finish();
}
});
} catch (RuntimeException e) {
Error(e);
}
}
});
@ -760,6 +764,7 @@ public class RecordingActivity extends AppCompatActivity {
void encoding(final Runnable run) {
final File in = storage.getTempRecording();
in.mkdirs(); // in case if it were manually deleted
final File out = targetFile;
EncoderInfo info = getInfo();
@ -811,33 +816,37 @@ public class RecordingActivity extends AppCompatActivity {
@Override
public void run() {
d.cancel();
AlertDialog.Builder builder = new AlertDialog.Builder(RecordingActivity.this);
builder.setTitle("Error");
String msg = encoder.getException().getMessage();
if (msg == null || msg.isEmpty()) {
Throwable t = encoder.getException();
while (t.getCause() != null)
t = t.getCause();
msg = t.getClass().getSimpleName();
}
builder.setMessage(msg);
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
finish();
}
});
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
});
builder.show();
Error(encoder.getException());
}
});
}
void Error(Throwable e) {
String msg = e.getMessage();
if (msg == null || msg.isEmpty()) {
Throwable t = encoder.getException();
while (t.getCause() != null)
t = t.getCause();
msg = t.getClass().getSimpleName();
}
AlertDialog.Builder builder = new AlertDialog.Builder(RecordingActivity.this);
builder.setTitle("Error");
builder.setMessage(msg);
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
finish();
}
});
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
});
builder.show();
}
@Override
public void finish() {
super.finish();