mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-22 00:32:55 +08:00
DataResource bugfix WebviewClient logs error for http urls.
This commit is contained in:
parent
230c635a54
commit
8f91ebf194
@ -98,8 +98,10 @@ public class FileHelper {
|
|||||||
Uri uri = Uri.parse(uriString);
|
Uri uri = Uri.parse(uriString);
|
||||||
String relativePath = uri.getPath().substring(15);
|
String relativePath = uri.getPath().substring(15);
|
||||||
return cordova.getActivity().getAssets().open(relativePath);
|
return cordova.getActivity().getAssets().open(relativePath);
|
||||||
} else {
|
} else if (uriString.startsWith("file://")) {
|
||||||
return new FileInputStream(getRealPath(uriString, cordova));
|
return new FileInputStream(getRealPath(uriString, cordova));
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
package org.apache.cordova;
|
package org.apache.cordova;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
import org.apache.cordova.api.CordovaInterface;
|
import org.apache.cordova.api.CordovaInterface;
|
||||||
import org.apache.cordova.api.DataResource;
|
import org.apache.cordova.api.DataResource;
|
||||||
@ -55,7 +56,12 @@ public class IceCreamCordovaWebViewClient extends CordovaWebViewClient {
|
|||||||
|
|
||||||
if(ret == null) {
|
if(ret == null) {
|
||||||
try {
|
try {
|
||||||
ret = new WebResourceResponse(dataResource.getMimeType(), "UTF-8", dataResource.getInputStream());
|
InputStream is;
|
||||||
|
String mimeType;
|
||||||
|
if((is = dataResource.getInputStream()) != null && (mimeType = dataResource.getMimeType()) != null) {
|
||||||
|
// If we don't know how to open this file, let the browser continue loading
|
||||||
|
ret = new WebResourceResponse(mimeType, "UTF-8", is);
|
||||||
|
}
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
LOG.e("IceCreamCordovaWebViewClient", "Error occurred while loading a file.", e);
|
LOG.e("IceCreamCordovaWebViewClient", "Error occurred while loading a file.", e);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user