Convert HTML width/height digits only

pull/159/head
M66B 6 years ago
parent 44a8381290
commit 9d234aa9a4

@ -238,21 +238,19 @@ public class HtmlHelper {
int width = 0; int width = 0;
int height = 0; int height = 0;
try {
String awidth = img.attr("width"); String awidth = img.attr("width");
if (!TextUtils.isEmpty(awidth) && !"auto".equals(awidth.toLowerCase())) for (int i = 0; i < awidth.length(); i++)
width = Integer.parseInt(awidth); if (Character.isDigit(awidth.charAt(i)))
} catch (NumberFormatException ex) { width = width * 10 + (byte) awidth.charAt(i) - (byte) '0';
Log.w(ex); else
} break;
try {
String aheight = img.attr("height"); String aheight = img.attr("height");
if (!TextUtils.isEmpty(aheight) && !"auto".equals(aheight.toLowerCase())) for (int i = 0; i < aheight.length(); i++)
height = Integer.parseInt(aheight); if (Character.isDigit(aheight.charAt(i)))
} catch (NumberFormatException ex) { height = height * 10 + (byte) aheight.charAt(i) - (byte) '0';
Log.w(ex); else
} break;
if (width != 0 || height != 0) { if (width != 0 || height != 0) {
String src = img.attr("src"); String src = img.attr("src");

Loading…
Cancel
Save