src/main/java/de/blau/android/util/SelectFile.java
/**
     * Handle the file selector result
     * 
     * @param code returned request code
     * @param data the returned intent
     */
Handle the file selector result

@param code returned request code
@param data the returned intent
Handle the file selector result @param code returned request code @param data the returned intent
public static void handleResult(int code, @NonNull Intent data) {
        Uri uri;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            uri = data.getData();
        } else {
            uri = Uri.fromFile(com.nononsenseapps.filepicker.Utils.getFileForUri(data.getData()));
        }
        ContentResolverUtil.persistPermissions(activity, data.getFlags(), uri);
        if (code == SAVE_FILE) {
            File file = new File(uri.getPath());
            if (file.exists()) {
                Snack.barWarning(activity, activity.getResources().getString(R.string.toast_file_exists, file.getName()), R.string.overwrite, v -> {
                    synchronized (saveCallbackLock) {
                        if (saveCallback != null) {
                            saveCallback.save(uri);
                        }
                    }
                });
            }
            synchronized (saveCallbackLock) {
                if (saveCallback != null) {
                    Log.d(DEBUG_TAG, "saving to " + uri);
                    saveCallback.save(uri);
                }
            }
        } else if (code == READ_FILE) {
            synchronized (readCallbackLock) {
                if (readCallback != null) {
                    Log.d(DEBUG_TAG, "reading " + uri);
                    readCallback.read(uri);
                }
            }
        } else if (code == READ_FILE_OLD) {
            synchronized (readCallbackLock) {
                if (readCallback != null) {
                    Log.d(DEBUG_TAG, "reading " + uri);
                    readCallback.read(uri);
                }
            }
        }
    }
public static void handleResult ( int code , @ NonNull Intent data ) { Uri uri ; if ( Build . VERSION . SDK_INT >= Build . VERSION_CODES . KITKAT ) { uri = data . getData ( ) ; } else { uri = Uri . fromFile ( com . nononsenseapps . filepicker . Utils . getFileForUri ( data . getData ( ) ) ) ; } ContentResolverUtil . persistPermissions ( activity , data . getFlags ( ) , uri ) ; if ( code == SAVE_FILE ) { File file = new File ( uri . getPath ( ) ) ; if ( file . exists ( ) ) { Snack . barWarning ( activity , activity . getResources ( ) . getString ( R . string . toast_file_exists , file . getName ( ) ) , R . string . overwrite , v -> { synchronized ( saveCallbackLock ) { if ( saveCallback != null ) { saveCallback . save ( uri ) ; } } } ) ; } synchronized ( saveCallbackLock ) { if ( saveCallback != null ) { Log . d ( DEBUG_TAG , "saving to " + uri ) ; saveCallback . save ( uri ) ; } } } else if ( code == READ_FILE ) { synchronized ( readCallbackLock ) { if ( readCallback != null ) { Log . d ( DEBUG_TAG , "reading " + uri ) ; readCallback . read ( uri ) ; } } } else if ( code == READ_FILE_OLD ) { synchronized ( readCallbackLock ) { if ( readCallback != null ) { Log . d ( DEBUG_TAG , "reading " + uri ) ; readCallback . read ( uri ) ; } } } }
Handle the file selector result
Handle the file selector result