Java Code Examples for com.ipaulpro.afilechooser.utils.FileUtils#getPath()

The following examples show how to use com.ipaulpro.afilechooser.utils.FileUtils#getPath() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FileChooser.java    From filechooser with MIT License 6 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if( requestCode == REQUEST_CODE) {
            // If the file selection was successful
            if (resultCode == Activity.RESULT_OK) {
                if (data != null) {
                    // Get the URI of the selected file
                    final Uri uri = data.getData();
                    Log.i(TAG, "Uri = " + uri.toString());
                    JSONObject obj = new JSONObject();
                    try {
                        // Get the file path from the URI
                        final String path = FileUtils.getPath(this.cordova.getActivity(), uri);
                        obj.put("filepath", path);
                        this.callbackContext.success(obj);
                    } catch (Exception e) {
                        Log.e("FileChooser", "File select error", e);
                        this.callbackContext.error(e.getMessage());
                    }
                }
            }
    }
}
 
Example 2
Source File: QuickStartVideoExampleActivity.java    From qiniu-lab-android with MIT License 6 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
        case REQUEST_CODE:
            // If the file selection was successful
            if (resultCode == RESULT_OK) {
                if (data != null) {
                    // Get the URI of the selected file
                    final Uri uri = data.getData();
                    try {
                        // Get the file path from the URI
                        final String path = FileUtils.getPath(this, uri);
                        this.uploadFilePath = path;
                    } catch (Exception e) {
                        Toast.makeText(
                                context,
                                context.getString(R.string.qiniu_get_upload_file_failed),
                                Toast.LENGTH_LONG).show();
                    }
                }
            }
            break;
    }
    super.onActivityResult(requestCode, resultCode, data);
}
 
Example 3
Source File: QuickStartImageExampleActivity.java    From qiniu-lab-android with MIT License 6 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
        case REQUEST_CODE:
            // If the file selection was successful
            if (resultCode == RESULT_OK) {
                if (data != null) {
                    // Get the URI of the selected file
                    final Uri uri = data.getData();
                    try {
                        // Get the file path from the URI
                        final String path = FileUtils.getPath(this, uri);
                        this.uploadFilePath = path;
                    } catch (Exception e) {
                        Toast.makeText(
                                context,
                                context.getString(R.string.qiniu_get_upload_file_failed),
                                Toast.LENGTH_LONG).show();
                    }
                }
            }
            break;
    }
    super.onActivityResult(requestCode, resultCode, data);
}
 
Example 4
Source File: MainActivity.java    From Readily with MIT License 6 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data){
	switch (requestCode){
		case FILE_SELECT_CODE:
			if (resultCode == RESULT_OK){
				if (data != null){
					String relativePath = FileUtils.getPath(this, data.getData());
					if (FileStorable.isExtensionValid(FileUtils.getExtension(relativePath))){
						ReceiverActivity.startReceiverActivity(this, Readable.TYPE_FILE, relativePath);
					} else {
						Toast.makeText(this, R.string.wrong_ext, Toast.LENGTH_SHORT).show();
					}
				}
			}
			break;
	}
	super.onActivityResult(requestCode, resultCode, data);
}
 
Example 5
Source File: SimpleUploadUseSaveKeyActivity.java    From qiniu-lab-android with MIT License 5 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
        case REQUEST_CODE:
            // If the file selection was successful
            if (resultCode == RESULT_OK) {
                if (data != null) {
                    // Get the URI of the selected file
                    final Uri uri = data.getData();
                    try {
                        // Get the file path from the URI
                        final String path = FileUtils.getPath(this, uri);
                        this.uploadFilePath = path;
                        this.clearLog();
                        this.writeLog(context
                                .getString(R.string.qiniu_select_upload_file)
                                + path);
                    } catch (Exception e) {
                        Toast.makeText(
                                context,
                                context.getString(R.string.qiniu_get_upload_file_failed),
                                Toast.LENGTH_LONG).show();
                    }
                }
            }
            break;
    }
    super.onActivityResult(requestCode, resultCode, data);
}
 
Example 6
Source File: SimpleUploadWithMimeTypeActivity.java    From qiniu-lab-android with MIT License 5 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
        case REQUEST_CODE:
            // If the file selection was successful
            if (resultCode == RESULT_OK) {
                if (data != null) {
                    // Get the URI of the selected file
                    final Uri uri = data.getData();
                    try {
                        // Get the file path from the URI
                        final String path = FileUtils.getPath(this, uri);
                        this.uploadFilePath = path;
                        this.clearLog();
                        this.writeLog(context
                                .getString(R.string.qiniu_select_upload_file)
                                + path);
                    } catch (Exception e) {
                        Toast.makeText(
                                context,
                                context.getString(R.string.qiniu_get_upload_file_failed),
                                Toast.LENGTH_LONG).show();
                    }
                }
            }
            break;
    }
    super.onActivityResult(requestCode, resultCode, data);
}
 
Example 7
Source File: CallbackUploadWithKeyInJsonFormatActivity.java    From qiniu-lab-android with MIT License 5 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
        case REQUEST_CODE:
            // If the file selection was successful
            if (resultCode == RESULT_OK) {
                if (data != null) {
                    // Get the URI of the selected file
                    final Uri uri = data.getData();
                    try {
                        // Get the file path from the URI
                        final String path = FileUtils.getPath(this, uri);
                        this.uploadFilePath = path;
                        this.clearLog();
                        this.writeLog(context
                                .getString(R.string.qiniu_select_upload_file)
                                + path);
                    } catch (Exception e) {
                        Toast.makeText(
                                context,
                                context.getString(R.string.qiniu_get_upload_file_failed),
                                Toast.LENGTH_LONG).show();
                    }
                }
            }
            break;
    }
    super.onActivityResult(requestCode, resultCode, data);
}
 
Example 8
Source File: ResumableUploadWithoutKeyActivity.java    From qiniu-lab-android with MIT License 5 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
        case REQUEST_CODE:
            // If the file selection was successful
            if (resultCode == RESULT_OK) {
                if (data != null) {
                    // Get the URI of the selected file
                    final Uri uri = data.getData();
                    try {
                        // Get the file path from the URI
                        final String path = FileUtils.getPath(this, uri);
                        this.uploadFilePath = path;
                        this.clearLog();
                        this.writeLog(context
                                .getString(R.string.qiniu_select_upload_file)
                                + path);
                    } catch (Exception e) {
                        Toast.makeText(
                                context,
                                context.getString(R.string.qiniu_get_upload_file_failed),
                                Toast.LENGTH_LONG).show();
                    }
                }
            }
            break;
    }
    super.onActivityResult(requestCode, resultCode, data);
}
 
Example 9
Source File: SimpleUploadUseFsizeLimitActivity.java    From qiniu-lab-android with MIT License 5 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
        case REQUEST_CODE:
            // If the file selection was successful
            if (resultCode == RESULT_OK) {
                if (data != null) {
                    // Get the URI of the selected file
                    final Uri uri = data.getData();
                    try {
                        // Get the file path from the URI
                        final String path = FileUtils.getPath(this, uri);
                        this.uploadFilePath = path;
                        this.clearLog();
                        this.writeLog(context
                                .getString(R.string.qiniu_select_upload_file)
                                + path);
                    } catch (Exception e) {
                        Toast.makeText(
                                context,
                                context.getString(R.string.qiniu_get_upload_file_failed),
                                Toast.LENGTH_LONG).show();
                    }
                }
            }
            break;
    }
    super.onActivityResult(requestCode, resultCode, data);
}
 
Example 10
Source File: ResumableUploadWithKeyActivity.java    From qiniu-lab-android with MIT License 5 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
        case REQUEST_CODE:
            // If the file selection was successful
            if (resultCode == RESULT_OK) {
                if (data != null) {
                    // Get the URI of the selected file
                    final Uri uri = data.getData();
                    try {
                        // Get the file path from the URI
                        final String path = FileUtils.getPath(this, uri);
                        this.uploadFilePath = path;
                        this.clearLog();
                        this.writeLog(context
                                .getString(R.string.qiniu_select_upload_file)
                                + path);
                    } catch (Exception e) {
                        Toast.makeText(
                                context,
                                context.getString(R.string.qiniu_get_upload_file_failed),
                                Toast.LENGTH_LONG).show();
                    }
                }
            }
            break;
    }
    super.onActivityResult(requestCode, resultCode, data);
}
 
Example 11
Source File: SimpleUploadOverwriteExistingFileActivity.java    From qiniu-lab-android with MIT License 5 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
        case REQUEST_CODE:
            // If the file selection was successful
            if (resultCode == RESULT_OK) {
                if (data != null) {
                    // Get the URI of the selected file
                    final Uri uri = data.getData();
                    try {
                        // Get the file path from the URI
                        final String path = FileUtils.getPath(this, uri);
                        this.uploadFilePath = path;
                        this.clearLog();
                        this.writeLog(context
                                .getString(R.string.qiniu_select_upload_file)
                                + path);
                    } catch (Exception e) {
                        Toast.makeText(
                                context,
                                context.getString(R.string.qiniu_get_upload_file_failed),
                                Toast.LENGTH_LONG).show();
                    }
                }
            }
            break;
    }
    super.onActivityResult(requestCode, resultCode, data);
}
 
Example 12
Source File: SimpleUploadUseReturnBodyActivity.java    From qiniu-lab-android with MIT License 5 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
        case REQUEST_CODE:
            // If the file selection was successful
            if (resultCode == RESULT_OK) {
                if (data != null) {
                    // Get the URI of the selected file
                    final Uri uri = data.getData();
                    try {
                        // Get the file path from the URI
                        final String path = FileUtils.getPath(this, uri);
                        this.uploadFilePath = path;
                        this.clearLog();
                        this.writeLog(context
                                .getString(R.string.qiniu_select_upload_file)
                                + path);
                    } catch (Exception e) {
                        Toast.makeText(
                                context,
                                context.getString(R.string.qiniu_get_upload_file_failed),
                                Toast.LENGTH_LONG).show();
                    }
                }
            }
            break;
    }
    super.onActivityResult(requestCode, resultCode, data);
}
 
Example 13
Source File: SimpleUploadUseSaveKeyFromXParamActivity.java    From qiniu-lab-android with MIT License 5 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
        case REQUEST_CODE:
            // If the file selection was successful
            if (resultCode == RESULT_OK) {
                if (data != null) {
                    // Get the URI of the selected file
                    final Uri uri = data.getData();
                    try {
                        // Get the file path from the URI
                        final String path = FileUtils.getPath(this, uri);
                        this.uploadFilePath = path;
                        this.clearLog();
                        this.writeLog(context
                                .getString(R.string.qiniu_select_upload_file)
                                + path);
                    } catch (Exception e) {
                        Toast.makeText(
                                context,
                                context.getString(R.string.qiniu_get_upload_file_failed),
                                Toast.LENGTH_LONG).show();
                    }
                }
            }
            break;
    }
    super.onActivityResult(requestCode, resultCode, data);
}
 
Example 14
Source File: SimpleUploadWithoutKeyActivity.java    From qiniu-lab-android with MIT License 5 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
        case REQUEST_CODE:
            // If the file selection was successful
            if (resultCode == RESULT_OK) {
                if (data != null) {
                    // Get the URI of the selected file
                    final Uri uri = data.getData();
                    try {
                        // Get the file path from the URI
                        final String path = FileUtils.getPath(this, uri);
                        this.uploadFilePath = path;
                        this.clearLog();
                        this.writeLog(context
                                .getString(R.string.qiniu_select_upload_file)
                                + path);
                    } catch (Exception e) {
                        Toast.makeText(
                                context,
                                context.getString(R.string.qiniu_get_upload_file_failed),
                                Toast.LENGTH_LONG).show();
                    }
                }
            }
            break;
    }
    super.onActivityResult(requestCode, resultCode, data);
}
 
Example 15
Source File: SimpleUploadUseMimeLimitActivity.java    From qiniu-lab-android with MIT License 5 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
        case REQUEST_CODE:
            // If the file selection was successful
            if (resultCode == RESULT_OK) {
                if (data != null) {
                    // Get the URI of the selected file
                    final Uri uri = data.getData();
                    try {
                        // Get the file path from the URI
                        final String path = FileUtils.getPath(this, uri);
                        this.uploadFilePath = path;
                        this.clearLog();
                        this.writeLog(context
                                .getString(R.string.qiniu_select_upload_file)
                                + path);
                    } catch (Exception e) {
                        Toast.makeText(
                                context,
                                context.getString(R.string.qiniu_get_upload_file_failed),
                                Toast.LENGTH_LONG).show();
                    }
                }
            }
            break;
    }
    super.onActivityResult(requestCode, resultCode, data);
}
 
Example 16
Source File: SimpleUploadEnableCrc32CheckActivity.java    From qiniu-lab-android with MIT License 5 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
        case REQUEST_CODE:
            // If the file selection was successful
            if (resultCode == RESULT_OK) {
                if (data != null) {
                    // Get the URI of the selected file
                    final Uri uri = data.getData();
                    try {
                        // Get the file path from the URI
                        final String path = FileUtils.getPath(this, uri);
                        this.uploadFilePath = path;
                        this.clearLog();
                        this.writeLog(context
                                .getString(R.string.qiniu_select_upload_file)
                                + path);
                    } catch (Exception e) {
                        Toast.makeText(
                                context,
                                context.getString(R.string.qiniu_get_upload_file_failed),
                                Toast.LENGTH_LONG).show();
                    }
                }
            }
            break;
    }
    super.onActivityResult(requestCode, resultCode, data);
}
 
Example 17
Source File: CallbackUploadWithKeyInUrlFormatActivity.java    From qiniu-lab-android with MIT License 5 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
        case REQUEST_CODE:
            // If the file selection was successful
            if (resultCode == RESULT_OK) {
                if (data != null) {
                    // Get the URI of the selected file
                    final Uri uri = data.getData();
                    try {
                        // Get the file path from the URI
                        final String path = FileUtils.getPath(this, uri);
                        this.uploadFilePath = path;
                        this.clearLog();
                        this.writeLog(context
                                .getString(R.string.qiniu_select_upload_file)
                                + path);
                    } catch (Exception e) {
                        Toast.makeText(
                                context,
                                context.getString(R.string.qiniu_get_upload_file_failed),
                                Toast.LENGTH_LONG).show();
                    }
                }
            }
            break;
    }
    super.onActivityResult(requestCode, resultCode, data);
}
 
Example 18
Source File: SimpleUploadWithKeyActivity.java    From qiniu-lab-android with MIT License 5 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
        case REQUEST_CODE:
            // If the file selection was successful
            if (resultCode == RESULT_OK) {
                if (data != null) {
                    // Get the URI of the selected file
                    final Uri uri = data.getData();
                    try {
                        // Get the file path from the URI
                        final String path = FileUtils.getPath(this, uri);
                        this.uploadFilePath = path;
                        this.clearLog();
                        this.writeLog(context
                                .getString(R.string.qiniu_select_upload_file)
                                + path);
                    } catch (Exception e) {
                        Toast.makeText(
                                context,
                                context.getString(R.string.qiniu_get_upload_file_failed),
                                Toast.LENGTH_LONG).show();
                    }
                }
            }
            break;
    }
    super.onActivityResult(requestCode, resultCode, data);
}
 
Example 19
Source File: MainActivity.java    From geopackage-mapcache-android with MIT License 5 votes vote down vote up
/**
     * Handle the URI from an intent for opening or importing a GeoPackage
     *
     * @param uri
     */
    private void handleIntentUri(final Uri uri, Intent intent) {
        String path = FileUtils.getPath(this, uri);
        String name = MapCacheFileUtils.getDisplayName(this, uri, path);
        try {
            if (path != null) {
//                managerFragment.importGeoPackageExternalLinkWithPermissions(name, uri, path);
                mapFragment.startImportTaskWithPermissions(name, uri, path, intent);

            } else {
//                managerFragment.importGeoPackage(name, uri, path);
                mapFragment.startImportTask(name, uri, path, intent);
            }
        } catch (final Exception e) {
            try {
                runOnUiThread(
                        new Runnable() {
                            @Override
                            public void run() {
                                GeoPackageUtils.showMessage(MainActivity.this,
                                        "Open GeoPackage",
                                        "Could not open file as a GeoPackage"
                                                + "\n\n"
                                                + e.getMessage());
                            }
                        });
            } catch (Exception e2) {
                // eat
            }
        }
    }
 
Example 20
Source File: FileStorable.java    From Readily with MIT License 4 votes vote down vote up
public static String takePath(Context context, String s){
	String candidate = FileUtils.getPath(context, Uri.parse(s));
	if (TextUtils.isEmpty(candidate)){ return s; }
	return candidate;
}