Skip to content

Commit

Permalink
uri2path support asset path
Browse files Browse the repository at this point in the history
  • Loading branch information
didikee committed Aug 8, 2022
1 parent 1bfc136 commit 1eedebd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions androidx/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
defaultConfig {
minSdkVersion 19
targetSdkVersion 30
versionCode 31
versionName "1.3.1"
versionCode 32
versionName "1.3.2"
archivesBaseName = "androidx-$versionName"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
5 changes: 5 additions & 0 deletions androidx/src/main/java/com/androidx/utils/Uri2Path.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
*/

final class Uri2Path {
static final String ASSET_PREFIX = "file:///android_asset/"; //assets路径 file:///android_asset/PixelHot/01_Cryptoboyz/cryptoboyz_01.png

private Uri2Path() {
}

Expand Down Expand Up @@ -127,6 +129,9 @@ else if ("content".equalsIgnoreCase(uri.getScheme())) {
}
// File
else if ("file".equalsIgnoreCase(uri.getScheme())) {
if (uri.toString().startsWith(ASSET_PREFIX)) {
return uri.toString();
}
return uri.getPath();
}

Expand Down

0 comments on commit 1eedebd

Please sign in to comment.