drop cancel file

This commit is contained in:
Alexey Kuznetsov 2016-03-12 23:34:23 +03:00
commit 52c6940077
2 changed files with 34 additions and 10 deletions

View file

@ -191,6 +191,7 @@ public class RecordingActivity extends AppCompatActivity {
@Override
public void run() {
storage.delete(storage.getTempRecording());
storage.delete(file);
finish();
}
});

View file

@ -1,9 +1,13 @@
package com.github.axet.audiorecorder.widgets;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.os.Build;
import android.os.Handler;
import android.util.AttributeSet;
import android.util.Log;
@ -50,6 +54,7 @@ public class PitchView extends ViewGroup {
public class PitchGraphView extends SurfaceView implements SurfaceHolder.Callback {
Thread thread;
Runnable draw;
int bg;
public PitchGraphView(Context context) {
this(context, null);
@ -63,6 +68,8 @@ public class PitchView extends ViewGroup {
super(context, attrs, defStyleAttr);
getHolder().addCallback(this);
bg = getThemeColor(android.R.attr.windowBackground);
}
@Override
@ -118,7 +125,7 @@ public class PitchView extends ViewGroup {
void drawHolder(Canvas canvas) {
synchronized (data) {
canvas.drawColor(Color.WHITE);
canvas.drawColor(bg);
int m = Math.min(pitchMemCount, data.size());
@ -221,20 +228,22 @@ public class PitchView extends ViewGroup {
@Override
protected void onDraw(Canvas canvas) {
if (data.size() == 0)
return;
synchronized (data) {
if (data.size() == 0)
return;
int end = data.size() - 1;
int end = data.size() - 1;
float left = data.get(end);
float right = data.get(end);
float left = data.get(end);
float right = data.get(end);
float mid = getWidth() / 2f;
float mid = getWidth() / 2f;
float y = getHeight() / 2f;
float y = getHeight() / 2f;
canvas.drawLine(mid, y, mid - mid * left, y, paint);
canvas.drawLine(mid, y, mid + mid * right, y, paint);
canvas.drawLine(mid, y, mid - mid * left, y, paint);
canvas.drawLine(mid, y, mid + mid * right, y, paint);
}
}
}
@ -289,6 +298,20 @@ public class PitchView extends ViewGroup {
return pitchTime;
}
int getThemeColor(int id) {
TypedValue typedValue = new TypedValue();
Context context = getContext();
Resources.Theme theme = context.getTheme();
if (theme.resolveAttribute(id, typedValue, true)) {
if (Build.VERSION.SDK_INT >= 23)
return context.getResources().getColor(typedValue.resourceId, theme);
else
return context.getResources().getColor(typedValue.resourceId);
} else {
return Color.TRANSPARENT;
}
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);