思特奇智慧酒店云平台 v0.0.5版本的 MD5 值为:dedb172bb322639d79d7e0e26262fb5c
以下内容为反编译后的 DownloadBlobFileJSInterface.java 源代码,内容仅作参考
package com.sitech.core.util.js;
import android.content.Context;
import android.webkit.JavascriptInterface;
public class DownloadBlobFileJSInterface {
public DownloadBlobSuccessListener downloadBlobSuccessListener;
public Context mContext;
public interface DownloadBlobSuccessListener {
void downloadBlobSuccess(String str);
}
public DownloadBlobFileJSInterface(Context context) {
this.mContext = context;
}
public static String getBase64StringFromBlobUrl(String str, String str2) {
if (str.startsWith("blob")) {
return "javascript:var xhr = new XMLHttpRequest();xhr.open('GET', '" + str + "', true);xhr.setRequestHeader('Content-type','" + str2 + "');xhr.responseType = 'blob';xhr.onload = function(e) { console.log('测试:'+this.status); if (this.status == 200) { var blobFile = this.response; var reader = new FileReader(); reader.readAsDataURL(blobFile); reader.onloadend = function() { var base64data = reader.result; window.YXDownloadBlob.getBase64FromBlobData(base64data); } }};xhr.send();";
}
return "javascript: console.log('It is not a Blob URL');";
}
@JavascriptInterface
public void getBase64FromBlobData(String str) {
DownloadBlobSuccessListener downloadBlobSuccessListener = this.downloadBlobSuccessListener;
if (downloadBlobSuccessListener != null) {
downloadBlobSuccessListener.downloadBlobSuccess(str);
}
}
public void setDownloadBlobSuccessListener(DownloadBlobSuccessListener downloadBlobSuccessListener) {
this.downloadBlobSuccessListener = downloadBlobSuccessListener;
}
}