-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
didikeeLuanon
committed
Jan 1, 2020
1 parent
883a852
commit 1c44549
Showing
5 changed files
with
84 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
androidx/src/main/java/com/androidx/picker/AbsMediaLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.androidx.picker; | ||
|
||
import android.text.TextUtils; | ||
|
||
import java.io.File; | ||
|
||
/** | ||
* user author: didikee | ||
* create time: 2020-01-01 20:01 | ||
* description: | ||
*/ | ||
public abstract class AbsMediaLoader { | ||
|
||
protected String[] getParentInfoFromData(String data) { | ||
if (!TextUtils.isEmpty(data)) { | ||
// 根据java系统来判断 | ||
File file = new File(data); | ||
if (file.exists() && file.length() > 0) { | ||
File imageParentFile = file.getParentFile(); | ||
if (imageParentFile != null) { | ||
String parentName = imageParentFile.getName(); | ||
String parentPath = imageParentFile.getAbsolutePath(); | ||
return new String[]{parentName, parentPath}; | ||
} | ||
} | ||
} | ||
return new String[]{"", ""}; | ||
} | ||
|
||
protected String[] getParentInfoFromRelativePath(String relativePath) { | ||
if (!TextUtils.isEmpty(relativePath)) { | ||
// 根据相对路径来判断 | ||
// DCIM/MY FOLDER/SUB/demo.png | ||
// android 10 DCIM/MY FOLDER/SUB | ||
String parentName = ""; | ||
String parentPath = ""; | ||
if (!TextUtils.isEmpty(relativePath) && relativePath.contains(File.separator)) { | ||
int lastIndexOf = relativePath.lastIndexOf(File.separator); | ||
if (lastIndexOf != -1) { | ||
parentName = relativePath.substring(lastIndexOf + 1); | ||
parentPath = relativePath.substring(0, lastIndexOf); | ||
} | ||
} else { | ||
parentName = relativePath; | ||
parentPath = relativePath; | ||
} | ||
return new String[]{parentName, parentPath}; | ||
} | ||
return new String[]{"", ""}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters