|
@@ -371,7 +371,7 @@ public class MainActivity extends AppCompatActivity implements RAWebView.WebView
|
|
|
|
|
|
|
|
private void setWebImageForPath(String path) {
|
|
private void setWebImageForPath(String path) {
|
|
|
if (path != null) {
|
|
if (path != null) {
|
|
|
-// String imgBase64 = FileManager.base64StringFromFile(path);
|
|
|
|
|
|
|
+ String imgBase64 = FileManager.base64StringFromFile(path);
|
|
|
// setWebImageWithBase64(imgBase64);
|
|
// setWebImageWithBase64(imgBase64);
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -379,7 +379,10 @@ public class MainActivity extends AppCompatActivity implements RAWebView.WebView
|
|
|
* 如果直接写file://xxxx 那么webview不会加载
|
|
* 如果直接写file://xxxx 那么webview不会加载
|
|
|
* 建议写为http://local/file://
|
|
* 建议写为http://local/file://
|
|
|
* */
|
|
* */
|
|
|
- evaluateCurrentAction(String.format("%s%s",RALocalFileScheme,path));
|
|
|
|
|
|
|
+// evaluateCurrentAction(String.format("%s%s",RALocalFileScheme,path));
|
|
|
|
|
+
|
|
|
|
|
+ String base64 = String.format("data:image/jpg;base64,%s",imgBase64);
|
|
|
|
|
+ evaluateCurrentAction(base64);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1060,8 +1063,38 @@ public class MainActivity extends AppCompatActivity implements RAWebView.WebView
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public String FileBase64(String msg) {
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ JSONObject json = new JSONObject(msg);
|
|
|
|
|
+
|
|
|
|
|
+ String path = json.getString("path");
|
|
|
|
|
+
|
|
|
|
|
+ // http://local/file:///data/user_de/0/com.usai.apex.apexcrm/cache/20190128_150550
|
|
|
|
|
+// path = "http://local/file:///data/user_de/0/com.usai.apex.apexcrm/cache/20190128_150550";
|
|
|
|
|
+ if (path != null) {
|
|
|
|
|
+ path = path.replace(RALocalFileScheme, "");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String imageWithBase64 = base64(path);
|
|
|
|
|
+ String base64 = String.format("data:image/jpg;base64,%s",imageWithBase64);
|
|
|
|
|
+
|
|
|
|
|
+ return base64;
|
|
|
|
|
+
|
|
|
|
|
+ } catch (JSONException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ private static String base64(String path) {
|
|
|
|
|
+
|
|
|
|
|
+ return FileManager.base64StringFromFile(path);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// region Loac Callback
|
|
// region Loac Callback
|
|
|
|
|
|
|
|
private boolean initialize = false; // 首页加载完成
|
|
private boolean initialize = false; // 首页加载完成
|