当前位置: 首页>>代码示例>>Java>>正文


Java FileUtils.getPath方法代码示例

本文整理汇总了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;
    }
}
 
开发者ID:talayhan,项目名称:vibeapp,代码行数:27,代码来源:MainActivity.java

示例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);
}
 
开发者ID:dc914337,项目名称:PSD-Android-App,代码行数:20,代码来源:PassActivity.java

示例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);
                }
            }
    }
}
 
开发者ID:garys-esri,项目名称:gpkg-viewer-android,代码行数:18,代码来源:GpkgViewerActivity.java

示例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);
}
 
开发者ID:syniuhin,项目名称:Readily,代码行数:19,代码来源:MainActivity.java

示例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);
}
 
开发者ID:qiniudemo,项目名称:qiniu-lab-android,代码行数:26,代码来源:QuickStartVideoExampleActivity.java

示例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");
}
 
开发者ID:openforis,项目名称:collect-mobile,代码行数:27,代码来源:SurveyListActivity.java

示例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);
}
 
开发者ID:mitchtech,项目名称:XposedMacroExpand,代码行数:23,代码来源:MacroPreferenceActivity.java

示例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());
                    }
                }
            }
    }
}
 
开发者ID:cdibened,项目名称:filechooser,代码行数:24,代码来源:FileChooser.java

示例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();
    }
}
 
开发者ID:kmark,项目名称:XHangouts,代码行数:17,代码来源:FilePickerPreference.java

示例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);
}
 
开发者ID:dc914337,项目名称:PSD-Android-App,代码行数:29,代码来源:SettingsActivity.java

示例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
        }
    }
}
 
开发者ID:ngageoint,项目名称:geopackage-mapcache-android,代码行数:33,代码来源:MainActivity.java

示例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;
    }
}
 
开发者ID:BitcoinAuthenticator,项目名称:BitcoinAuthenticator-Android,代码行数:15,代码来源:Restore_Menu.java

示例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);
        }
    }
}
 
开发者ID:guiguito,项目名称:AIRShare,代码行数:15,代码来源:ShAIReHttpServer.java

示例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);
}
 
开发者ID:qiniudemo,项目名称:qiniu-lab-android,代码行数:30,代码来源:SimpleUploadUseSaveKeyActivity.java

示例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();
        }
    }
 
开发者ID:yeokm1,项目名称:nus-soc-print,代码行数:16,代码来源:MyApplication.java


注:本文中的com.ipaulpro.afilechooser.utils.FileUtils.getPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。