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) {
|
||||
context.clear();
|
||||
context.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -65,7 +65,7 @@ class WaveFileOutput implements IOutput {
|
|||
|
||||
private void InitOutputStream() {
|
||||
try {
|
||||
mOutputStream = new BufferedOutputStream(mContext.createWaveOutputStream());
|
||||
mOutputStream = new BufferedOutputStream(mContext.getOutputStream());
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,22 +42,7 @@ public class WaveFileOutputContext {
|
|||
else
|
||||
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) {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(MediaStore.Audio.Media.MIME_TYPE, "audio/wav");
|
||||
|
@ -73,7 +58,22 @@ public class WaveFileOutputContext {
|
|||
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 (mUri != null && mValues != null) {
|
||||
mValues.clear();
|
||||
|
|
Ładowanie…
Reference in New Issue