Skip to content

Commit a516192

Browse files
committed
- Fixed #16
- Fixed a possible NullPointerException on Android when selecting a new folder using SAF
1 parent ed690a3 commit a516192

File tree

5 files changed

+19
-12
lines changed

5 files changed

+19
-12
lines changed
Binary file not shown.

Assets/Plugins/SimpleFileBrowser/Scripts/FileBrowser.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -796,11 +796,12 @@ private void OnOperationSuccessful( string path )
796796

797797
Hide();
798798

799-
if( onSuccess != null )
800-
onSuccess( path );
801-
799+
OnSuccess _onSuccess = onSuccess;
802800
onSuccess = null;
803801
onCancel = null;
802+
803+
if( _onSuccess != null )
804+
_onSuccess( path );
804805
}
805806

806807
private void OnOperationCanceled( bool invokeCancelCallback )
@@ -810,11 +811,12 @@ private void OnOperationCanceled( bool invokeCancelCallback )
810811

811812
Hide();
812813

813-
if( invokeCancelCallback && onCancel != null )
814-
onCancel();
815-
814+
OnCancel _onCancel = onCancel;
816815
onSuccess = null;
817816
onCancel = null;
817+
818+
if( invokeCancelCallback && _onCancel != null )
819+
_onCancel();
818820
}
819821

820822
public void OnPathChanged( string newPath )

JAR Source/FileBrowser.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -300,10 +300,15 @@ public static void ReadFromSAFEntry( Context context, String rawUri, String dest
300300
}
301301
finally
302302
{
303-
if( output != null )
304-
output.close();
305-
306-
input.close();
303+
try
304+
{
305+
if( output != null )
306+
output.close();
307+
}
308+
finally
309+
{
310+
input.close();
311+
}
307312
}
308313
}
309314
catch( Exception e )

JAR Source/FileBrowserDirectoryPickerFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public void onActivityResult( int requestCode, int resultCode, Intent data )
5656

5757
String rawUri = "";
5858
String name = "";
59-
if( resultCode == Activity.RESULT_OK )
59+
if( resultCode == Activity.RESULT_OK && data != null )
6060
{
6161
Uri directoryUri = data.getData();
6262
if( directoryUri != null )

JAR Source/FileBrowserPermissionFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,4 @@ public void onRequestPermissionsResult( int requestCode, String[] permissions, i
115115
Log.e( "Unity", "Exception (resume):", e );
116116
}
117117
}
118-
}
118+
}

0 commit comments

Comments
 (0)