本文整理汇总了Java中com.ipaulpro.afilechooser.utils.FileUtils.getPath方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtils.getPath方法的具体用法?Java FileUtils.getPath怎么用?Java FileUtils.getPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.ipaulpro.afilechooser.utils.FileUtils
的用法示例。
在下文中一共展示了FileUtils.getPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onActivityResult
import com.ipaulpro.afilechooser.utils.FileUtils; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case Constants.REQUEST_CHOOSER:
if (resultCode == RESULT_OK) {
final Uri uri = data.getData();
// Get the File path from the Uri
String path = FileUtils.getPath(this, uri);
Toast.makeText(this, "Choosen file: " + path,Toast.LENGTH_LONG).show();
// Alternatively, use FileUtils.getFile(Context, Uri)
if (path != null && FileUtils.isLocal(path)) {
File file = new File(path);
}
// Create the intent to start video activity
Intent i = new Intent(MainActivity.this, LocalVideoActivity.class);
i.putExtra(Constants.EXTRA_ANSWER_IS_TRUE,path);
startActivity(i);
}
break;
}
}
示例2: onActivityResult
import com.ipaulpro.afilechooser.utils.FileUtils; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
switch (requestCode) {
case REQUEST_CODE:
if (resultCode == RESULT_OK) {
final Uri uri = data.getData();
// Get the File path from the Uri
String path = FileUtils.getPath(this, uri);
// Alternatively, use FileUtils.getFile(Context, Uri)
if (path != null && FileUtils.isLocal(path)) {
File file = new File(path);
processSelectedPic(file);
}
}
break;
}
super.onActivityResult(requestCode, resultCode, data);
}
示例3: onActivityResult
import com.ipaulpro.afilechooser.utils.FileUtils; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case REQUEST_CODE_RASTER:
case REQUEST_CODE_VECTOR:
if (RESULT_OK == resultCode) {
Uri uri = data.getData();
String path = FileUtils.getPath(this, uri);
if (REQUEST_CODE_RASTER == requestCode) {
addRasterGpkg(path);
} else {
addVectorGpkg(path);
}
}
}
}
示例4: onActivityResult
import com.ipaulpro.afilechooser.utils.FileUtils; //导入方法依赖的package包/类
@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);
}
示例5: onActivityResult
import com.ipaulpro.afilechooser.utils.FileUtils; //导入方法依赖的package包/类
@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);
}
示例6: getFileNameByUri
import com.ipaulpro.afilechooser.utils.FileUtils; //导入方法依赖的package包/类
private String getFileNameByUri(Uri uri) {
String path = FileUtils.getPath(this, uri);
if (path != null && new File(path).exists())
return path;
if (uri.getScheme().equals("content")) {
Cursor cursor = getContentResolver().query(uri, null, null, null, null);
if (cursor != null && cursor.moveToFirst()) {
File downloadDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
String name = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Files.FileColumns.DISPLAY_NAME));
File file = new File(downloadDir, name);
try {
InputStream inputStream = getContentResolver().openInputStream(uri);
if (inputStream == null)
throw new IllegalStateException("Failed to import survey");
IOUtils.copy(inputStream, new FileOutputStream(file));
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
cursor.close();
return file.getAbsolutePath();
}
} else if (uri.getScheme().equals("file"))
return FileUtils.getPath(this, uri);
throw new IllegalStateException("Failed to import survey");
}
示例7: onActivityResult
import com.ipaulpro.afilechooser.utils.FileUtils; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case FORMAT_AHK:
case FORMAT_JSON:
if (resultCode == RESULT_OK) {
if (data != null) {
final Uri uri = data.getData();
// Log.i(TAG, "Uri = " + uri.toString());
try {
final String path = FileUtils.getPath(this, uri);
// Log.i(TAG, "path = " + path);
importConfirmDialog(path, requestCode);
} catch (Exception e) {
Log.e(TAG, "File select error:", e);
}
}
}
break;
}
super.onActivityResult(requestCode, resultCode, data);
}
示例8: onActivityResult
import com.ipaulpro.afilechooser.utils.FileUtils; //导入方法依赖的package包/类
@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());
}
}
}
}
}
示例9: onActivityResult
import com.ipaulpro.afilechooser.utils.FileUtils; //导入方法依赖的package包/类
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode != pickerCode || resultCode != Activity.RESULT_OK) {
return;
}
String file = FileUtils.getPath(getContext(), data.getData());
if(file == null) {
return;
}
setSummary(file);
prefs.edit().putString(getKey(), file).apply();
// Warn on potentially unsupported file
if(!file.toLowerCase(Locale.US).matches("^.+\\.(?:mp4|m4a|aac|flac|mp3|mid|ogg|wav|mkv)$")) {
Toast.makeText(getContext(), R.string.pref_toast_sound_type, Toast.LENGTH_LONG).show();
}
}
示例10: onActivityResult
import com.ipaulpro.afilechooser.utils.FileUtils; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
switch (requestCode) {
case PATH_REQUEST_CODE:
if (resultCode == RESULT_OK) {
final Uri uri = data.getData();
// Get the File path from the Uri
String path = FileUtils.getPath(this, uri);
// Alternatively, use FileUtils.getFile(Context, Uri)
if (path != null && FileUtils.isLocal(path)) {
File file = new File(path);
pathPref.setValue(file);
}
}
break;
case MAC_REQUEST_CODE:
if (resultCode == RESULT_OK) {
String name = data.getExtras().get(getString(R.string.extras_return_name)).toString();//Yay! I can't store 2 values using Preferences(extending Preferences)
String mac = data.getExtras().get(getString(R.string.extras_return_mac)).toString();
btFinderPref.setValue(mac);
}
break;
}
getPreferences(0);
}
示例11: handleIntentUri
import com.ipaulpro.afilechooser.utils.FileUtils; //导入方法依赖的package包/类
/**
* Handle the URI from an intent for opening or importing a GeoPackage
*
* @param uri
*/
private void handleIntentUri(final Uri uri) {
String path = FileUtils.getPath(this, uri);
String name = MapCacheFileUtils.getDisplayName(this, uri, path);
try {
if (path != null) {
managerFragment.importGeoPackageExternalLinkWithPermissions(name, uri, path);
} else {
managerFragment.importGeoPackage(name, uri, path);
}
} 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
}
}
}
示例12: onActivityResult
import com.ipaulpro.afilechooser.utils.FileUtils; //导入方法依赖的package包/类
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case REQUEST_CHOOSER:
if (resultCode == RESULT_OK) {
final Uri uri = data.getData();
final String path = FileUtils.getPath(this, uri);
if (path != null && FileUtils.isLocal(path)) {
showDecryptDialog(path);
}
}
break;
}
}
示例13: handleSendRawText
import com.ipaulpro.afilechooser.utils.FileUtils; //导入方法依赖的package包/类
private void handleSendRawText(Intent intent) {
String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
if (sharedText != null) {
setTextToShare(sharedText);
} else if (intent.hasExtra(Intent.EXTRA_STREAM)) {
Uri imageUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);
String filePath = FileUtils.getPath(mContext, imageUri);
if (filePath != null && filePath.startsWith("http")) {
setTextToShare(filePath);
} else {
handleSendFile(filePath);
}
}
}
示例14: onActivityResult
import com.ipaulpro.afilechooser.utils.FileUtils; //导入方法依赖的package包/类
@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);
}
示例15: setCurrentDocumentUri
import com.ipaulpro.afilechooser.utils.FileUtils; //导入方法依赖的package包/类
public void setCurrentDocumentUri(Uri newDocumentUri) {
try {
String path = FileUtils.getPath(this, newDocumentUri);
if(path != null && FileUtils.isLocal(path) && isFileFormatSupported(path)) {
currentDocumentPath = path;
} else {
Toast.makeText(this, R.string.print_file_not_supported, Toast.LENGTH_SHORT).show();
}
} catch (Exception e){
Toast.makeText(this, R.string.print_file_not_supported, Toast.LENGTH_SHORT).show();
}
}