Convert HTML width/height digits only

pull/159/head
M66B 5 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"); for (int i = 0; i < awidth.length(); i++)
if (!TextUtils.isEmpty(awidth) && !"auto".equals(awidth.toLowerCase())) if (Character.isDigit(awidth.charAt(i)))
width = Integer.parseInt(awidth); width = width * 10 + (byte) awidth.charAt(i) - (byte) '0';
} catch (NumberFormatException ex) { else
Log.w(ex); break;
}
String aheight = img.attr("height");
try { for (int i = 0; i < aheight.length(); i++)
String aheight = img.attr("height"); if (Character.isDigit(aheight.charAt(i)))
if (!TextUtils.isEmpty(aheight) && !"auto".equals(aheight.toLowerCase())) height = height * 10 + (byte) aheight.charAt(i) - (byte) '0';
height = Integer.parseInt(aheight); else
} catch (NumberFormatException ex) { break;
Log.w(ex);
}
if (width != 0 || height != 0) { if (width != 0 || height != 0) {
String src = img.attr("src"); String src = img.attr("src");

Loading…
Cancel
Save