kopia lustrzana https://github.com/olgamiller/SSTVEncoder2
WaveFileOutputContext: Moved getContentValues-method under constructor, renamed createWaveOutputStream-method and clear-method
rodzic
e0ca7e9eff
commit
b55e518a0a
|
@ -451,7 +451,7 @@ public class MainActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void completeSaving(WaveFileOutputContext context) {
|
public void completeSaving(WaveFileOutputContext context) {
|
||||||
context.clear();
|
context.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -65,7 +65,7 @@ class WaveFileOutput implements IOutput {
|
||||||
|
|
||||||
private void InitOutputStream() {
|
private void InitOutputStream() {
|
||||||
try {
|
try {
|
||||||
mOutputStream = new BufferedOutputStream(mContext.createWaveOutputStream());
|
mOutputStream = new BufferedOutputStream(mContext.getOutputStream());
|
||||||
} catch (Exception ignore) {
|
} catch (Exception ignore) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,21 +43,6 @@ public class WaveFileOutputContext {
|
||||||
mFile = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC), mFileName);
|
mFile = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC), mFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFileName() {
|
|
||||||
return mFileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OutputStream createWaveOutputStream() {
|
|
||||||
try {
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q)
|
|
||||||
return mContentResolver.openOutputStream(mUri);
|
|
||||||
else
|
|
||||||
return new FileOutputStream(mFile);
|
|
||||||
} catch (Exception ignore) {
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ContentValues getContentValues(String fileName) {
|
private ContentValues getContentValues(String fileName) {
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
values.put(MediaStore.Audio.Media.MIME_TYPE, "audio/wav");
|
values.put(MediaStore.Audio.Media.MIME_TYPE, "audio/wav");
|
||||||
|
@ -73,7 +58,22 @@ public class WaveFileOutputContext {
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clear() {
|
public String getFileName() {
|
||||||
|
return mFileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OutputStream getOutputStream() {
|
||||||
|
try {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||||
|
return mContentResolver.openOutputStream(mUri);
|
||||||
|
} else
|
||||||
|
return new FileOutputStream(mFile);
|
||||||
|
} catch (Exception ignore) {
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update() {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||||
if (mUri != null && mValues != null) {
|
if (mUri != null && mValues != null) {
|
||||||
mValues.clear();
|
mValues.clear();
|
||||||
|
|
Ładowanie…
Reference in New Issue