@@ -264,6 +264,14 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
264
264
}
265
265
}
266
266
267
+ public void imgFormatNotSupportedDialog () {
268
+
269
+ AlertDialog .Builder alertDialogBuilder = new AlertDialog .Builder (this ).setMessage (getString (R .string .Image_format_not_supported )).setPositiveButton (getString (R .string .ok ), (dialog1 , which ) -> dialog1 .cancel ());
270
+
271
+ AlertDialog alertDialog = alertDialogBuilder .create ();
272
+ alertDialog .show ();
273
+ }
274
+
267
275
public void addSpriteFromUri (final Uri uri ) {
268
276
final Scene currentScene = ProjectManager .getInstance ().getCurrentlyEditedScene ();
269
277
@@ -295,12 +303,15 @@ public void addSpriteFromUri(final Uri uri) {
295
303
currentScene .addSprite (sprite );
296
304
try {
297
305
File imageDirectory = new File (currentScene .getDirectory (), IMAGE_DIRECTORY_NAME );
298
- File file = StorageOperations
299
- .copyUriToDir (getContentResolver (), uri , imageDirectory , lookFileName );
300
-
306
+ File file = StorageOperations .copyUriToDir (getContentResolver (), uri , imageDirectory , lookFileName );
301
307
LookData lookData = new LookData (textInput , file );
302
- sprite .getLookList ().add (lookData );
303
- lookData .getCollisionInformation ().calculate ();
308
+ if (lookData .getImageMimeType () == null ) {
309
+ imgFormatNotSupportedDialog ();
310
+ currentScene .removeSprite (sprite );
311
+ } else {
312
+ sprite .getLookList ().add (lookData );
313
+ lookData .getCollisionInformation ().calculate ();
314
+ }
304
315
} catch (IOException e ) {
305
316
Log .e (TAG , Log .getStackTraceString (e ));
306
317
}
0 commit comments