Commit 16fa62f4 by Sebastián Katzer

Fallback to normal cache dir if there is no external

parent ced7c19a
...@@ -129,10 +129,8 @@ public final class AssetUtil { ...@@ -129,10 +129,8 @@ public final class AssetUtil {
String fileName = resPath.substring(resPath.lastIndexOf('/') + 1); String fileName = resPath.substring(resPath.lastIndexOf('/') + 1);
File file = getTmpFile(fileName); File file = getTmpFile(fileName);
if (file == null) { if (file == null)
Log.e("Asset", "Missing external cache dir");
return Uri.EMPTY; return Uri.EMPTY;
}
try { try {
AssetManager assets = context.getAssets(); AssetManager assets = context.getAssets();
...@@ -189,10 +187,8 @@ public final class AssetUtil { ...@@ -189,10 +187,8 @@ public final class AssetUtil {
private Uri getUriFromRemote(String path) { private Uri getUriFromRemote(String path) {
File file = getTmpFile(); File file = getTmpFile();
if (file == null) { if (file == null)
Log.e("Asset", "Missing external cache dir");
return Uri.EMPTY; return Uri.EMPTY;
}
try { try {
URL url = new URL(path); URL url = new URL(path);
...@@ -340,7 +336,11 @@ public final class AssetUtil { ...@@ -340,7 +336,11 @@ public final class AssetUtil {
File dir = context.getExternalCacheDir(); File dir = context.getExternalCacheDir();
if (dir == null) { if (dir == null) {
Log.e("Asset", "Missing external cache dir"); dir = context.getCacheDir();
}
if (dir == null) {
Log.e("Asset", "Missing cache dir");
return null; return null;
} }
...@@ -360,8 +360,13 @@ public final class AssetUtil { ...@@ -360,8 +360,13 @@ public final class AssetUtil {
* @return content://... * @return content://...
*/ */
private Uri getUriFromFile(File file) { private Uri getUriFromFile(File file) {
String authority = context.getPackageName() + ".provider"; try {
return AssetProvider.getUriForFile(context, authority, file); String authority = context.getPackageName() + ".provider";
return AssetProvider.getUriForFile(context, authority, file);
} catch (IllegalArgumentException e) {
e.printStackTrace();
return Uri.EMPTY;
}
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment