|
|
@ -380,21 +380,7 @@ public class HtmlHelper {
|
|
|
|
// Data URI
|
|
|
|
// Data URI
|
|
|
|
if (data)
|
|
|
|
if (data)
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
// "<img src=\"data:image/png;base64,iVBORw0KGgoAAA" +
|
|
|
|
return getDataDrawable(source, res);
|
|
|
|
// "ANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4" +
|
|
|
|
|
|
|
|
// "//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU" +
|
|
|
|
|
|
|
|
// "5ErkJggg==\" alt=\"Red dot\" />";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String base64 = source.substring(source.indexOf(',') + 1);
|
|
|
|
|
|
|
|
byte[] bytes = Base64.decode(base64.getBytes(), 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bitmap bm = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
|
|
|
|
|
|
|
|
if (bm == null)
|
|
|
|
|
|
|
|
throw new IllegalArgumentException("decode byte array failed");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Drawable d = new BitmapDrawable(res, bm);
|
|
|
|
|
|
|
|
d.setBounds(0, 0, bm.getWidth(), bm.getHeight());
|
|
|
|
|
|
|
|
return d;
|
|
|
|
|
|
|
|
} catch (IllegalArgumentException ex) {
|
|
|
|
} catch (IllegalArgumentException ex) {
|
|
|
|
Log.w(ex);
|
|
|
|
Log.w(ex);
|
|
|
|
Drawable d = res.getDrawable(R.drawable.baseline_broken_image_24, theme);
|
|
|
|
Drawable d = res.getDrawable(R.drawable.baseline_broken_image_24, theme);
|
|
|
@ -507,6 +493,24 @@ public class HtmlHelper {
|
|
|
|
return lld;
|
|
|
|
return lld;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static Drawable getDataDrawable(String source, Resources res) {
|
|
|
|
|
|
|
|
// "<img src=\"data:image/png;base64,iVBORw0KGgoAAA" +
|
|
|
|
|
|
|
|
// "ANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4" +
|
|
|
|
|
|
|
|
// "//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU" +
|
|
|
|
|
|
|
|
// "5ErkJggg==\" alt=\"Red dot\" />";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String base64 = source.substring(source.indexOf(',') + 1);
|
|
|
|
|
|
|
|
byte[] bytes = Base64.decode(base64.getBytes(), 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bitmap bm = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
|
|
|
|
|
|
|
|
if (bm == null)
|
|
|
|
|
|
|
|
throw new IllegalArgumentException("decode byte array failed");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Drawable d = new BitmapDrawable(res, bm);
|
|
|
|
|
|
|
|
d.setBounds(0, 0, bm.getWidth(), bm.getHeight());
|
|
|
|
|
|
|
|
return d;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static private Drawable getCachedImage(Context context, File file) {
|
|
|
|
static private Drawable getCachedImage(Context context, File file) {
|
|
|
|
if (file.exists()) {
|
|
|
|
if (file.exists()) {
|
|
|
|
Log.i("Using cached " + file);
|
|
|
|
Log.i("Using cached " + file);
|
|
|
|