db-boy / filechoose Goto Github PK
View Code? Open in Web Editor NEW选择文件 com.tencent.mtt.fileprovider
选择文件 com.tencent.mtt.fileprovider
改成:
File thirdPartyUriFile = getThirdPartyUriFile(uri);
if (thirdPartyUriFile != null) {
return thirdPartyUriFile.toString();
}
/**
* 处理第三方文件管理器的文件Uri
*
* @param uri
*
* @return
*/
public static File getThirdPartyUriFile(Uri uri) {
String path = uri.getPath();
if (!TextUtils.isEmpty(path)) {
// 去掉第一个'/'
path = path.substring(1);
// 去掉新path第一个'/'前面的内容
path = path.substring(path.indexOf('/'));
File file = new File(Environment.getExternalStorageDirectory(), path);
if (file.exists()) {
return file;
}
}
return null;
}
public static String getPath(final Context context, final Uri uri) {
MatchLog.E(RestRequest.TAG, "uri=" + uri);
if (DocumentsContract.isDocumentUri(context, uri)) {
if (isExternalStorageDocument(uri)) {
final String docId = DocumentsContract.getDocumentId(uri);
MatchLog.E(RestRequest.TAG, "docId=" + docId);
if (!TextUtils.isEmpty(docId) && docId.startsWith("raw:")) {
return Environment.getExternalStorageDirectory() + "/" + docId.substring(4);
}
final String[] split = docId.split(":");
/final String type = split[0];
if ("primary".equalsIgnoreCase(type)) {
return Environment.getExternalStorageDirectory() + "/" + split[1];
}/
return Environment.getExternalStorageDirectory() + "/" + split[1];
} else if (isDownloadsDocument(uri)) {
final String id = DocumentsContract.getDocumentId(uri);
if (!TextUtils.isEmpty(id) && id.startsWith("raw:")) {
return id.substring(4);
}
final Uri contentUri = ContentUris.withAppendedId(
Uri.parse("content://downloads/public_downloads"), Long.valueOf(id));
return getDataColumn(context, contentUri, null, null);
} else if (isMediaDocument(uri)) {
final String docId = DocumentsContract.getDocumentId(uri);
final String[] split = docId.split(":");
final String type = split[0];
Uri contentUri = null;
if ("image".equals(type)) {
contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
} else if ("video".equals(type)) {
contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
} else if ("audio".equals(type)) {
contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
} else {
contentUri = MediaStore.Files.getContentUri("external");
}
final String selection = "_id=?";
final String[] selectionArgs = new String[]{split[1]};
return getDataColumn(context, contentUri, selection, selectionArgs);
}
} else if ("content".equalsIgnoreCase(uri.getScheme())) {
if (isGooglePhotosUri(uri)) {
String lastPathSegment = uri.getLastPathSegment();
MatchLog.E(RestRequest.TAG, "isGooglePhotosUri=" + lastPathSegment);
return lastPathSegment;
}
if (isQQMediaDocument(uri)) {
String path = uri.getPath();
File fileDir = Environment.getExternalStorageDirectory();
File file = new File(fileDir, path.substring("/QQBrowser".length(), path.length()));
String pathStr = file.exists() ? file.toString() : null;
MatchLog.E(RestRequest.TAG, "isQQMediaDocument=" + pathStr);
return pathStr;
}
return getDataColumn(context, uri, null, null);
} else if ("file".equalsIgnoreCase(uri.getScheme())) {
return uri.getPath();
}
return null;
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.