kopia lustrzana https://github.com/olgamiller/SSTVEncoder2
Show error instead of send it, if image size is invalid (e.g. -1 x -1)
rodzic
82710aa7e2
commit
2e68bb431a
|
@ -180,7 +180,7 @@ public class CropView extends ImageView {
|
|||
invalidate();
|
||||
}
|
||||
|
||||
public void setBitmap(@NonNull InputStream stream) throws IOException {
|
||||
public void setBitmap(@NonNull InputStream stream) throws IOException, IllegalArgumentException {
|
||||
mImageOK = false;
|
||||
mOrientation = 0;
|
||||
recycle();
|
||||
|
@ -188,7 +188,7 @@ public class CropView extends ImageView {
|
|||
invalidate();
|
||||
}
|
||||
|
||||
private void loadImage(InputStream stream) throws IOException {
|
||||
private void loadImage(InputStream stream) throws IOException, IllegalArgumentException {
|
||||
// app6 + exif
|
||||
int bufferBytes = 1048576;
|
||||
if (!stream.markSupported())
|
||||
|
@ -212,7 +212,11 @@ public class CropView extends ImageView {
|
|||
|
||||
if (mCacheBitmap == null && mRegionDecoder == null) {
|
||||
String size = options.outWidth + "x" + options.outHeight;
|
||||
throw new IOException("Stream could not be decoded. Image size: " + size);
|
||||
String message = "Stream could not be decoded. Image size: " + size;
|
||||
if (mImageWidth <= 0 || mImageHeight <= 0)
|
||||
throw new IllegalArgumentException(message);
|
||||
else
|
||||
throw new IOException(message);
|
||||
}
|
||||
|
||||
mImageOK = true;
|
||||
|
|
|
@ -130,6 +130,9 @@ public class MainActivity extends AppCompatActivity {
|
|||
private boolean loadImage(InputStream stream, ContentResolver resolver, Uri uri) {
|
||||
try {
|
||||
mCropView.setBitmap(stream);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
Toast.makeText(this, ex.getMessage(), Toast.LENGTH_LONG).show();
|
||||
return false;
|
||||
} catch (Exception ex) {
|
||||
String s = Utility.createMessage(ex) + "\n\n" + uri;
|
||||
showErrorMessage(getString(R.string.load_img_err_title), ex.getMessage(), s);
|
||||
|
|
Ładowanie…
Reference in New Issue