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 {
String fileName = resPath.substring(resPath.lastIndexOf('/') + 1);
File file = getTmpFile(fileName);
if (file == null) {
Log.e("Asset", "Missing external cache dir");
if (file == null)
return Uri.EMPTY;
}
try {
AssetManager assets = context.getAssets();
......@@ -189,10 +187,8 @@ public final class AssetUtil {
private Uri getUriFromRemote(String path) {
File file = getTmpFile();
if (file == null) {
Log.e("Asset", "Missing external cache dir");
if (file == null)
return Uri.EMPTY;
}
try {
URL url = new URL(path);
......@@ -340,7 +336,11 @@ public final class AssetUtil {
File dir = context.getExternalCacheDir();
if (dir == null) {
Log.e("Asset", "Missing external cache dir");
dir = context.getCacheDir();
}
if (dir == null) {
Log.e("Asset", "Missing cache dir");
return null;
}
......@@ -360,8 +360,13 @@ public final class AssetUtil {
* @return content://...
*/
private Uri getUriFromFile(File file) {
String authority = context.getPackageName() + ".provider";
return AssetProvider.getUriForFile(context, authority, file);
try {
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