handle `OutOfMemoryError | IllegalArgumentException`

This commit is contained in:
Pratyush 2022-10-02 18:44:35 +05:30 committed by Daniel Micay
parent 5fadf7f47d
commit ee87e43bcb
2 changed files with 7 additions and 3 deletions

View File

@ -7,7 +7,12 @@ import java.io.IOException
import java.io.InputStream
import java.io.OutputStream
@Throws(FileNotFoundException::class, IOException::class)
@Throws(
FileNotFoundException::class,
IOException::class,
IllegalArgumentException::class,
OutOfMemoryError::class
)
fun saveAs(context: Context, existingUri: Uri, saveAs: Uri) {
context.asInputStream(existingUri)?.use { inputStream ->

View File

@ -709,8 +709,7 @@ public class PdfViewer extends AppCompatActivity implements LoaderManager.Loader
private void saveDocumentAs(Uri uri) {
try {
KtUtilsKt.saveAs(this, mUri, uri);
} catch (IOException e) {
e.printStackTrace();
} catch (IOException | OutOfMemoryError | IllegalArgumentException e) {
snackbar.setText(R.string.error_while_saving).show();
}
}