@Test public void testGetFloat() throws Exception { float test_float = WXUtils.getFloat("12324.9px"); assertEquals(12324.9, test_float, 0.9); assertEquals(WXUtils.fastGetFloat("1.2345",2),1.23f); }
public static float getFloat(Object value) { if (value == null) { return Float.NaN; } String temp = value.toString().trim(); if (temp.endsWith("px")) { temp = temp.substring(0, temp.indexOf("px")); } float result = Float.NaN; try { result = Float.parseFloat(temp); } catch (NumberFormatException e) { WXLogUtils.e("Argument format error!"); } return result; }
WXUtils { public static float getFloat(Object value) { if (value == null) { return Float.NaN; } String temp = value.toString().trim(); if (temp.endsWith("px")) { temp = temp.substring(0, temp.indexOf("px")); } float result = Float.NaN; try { result = Float.parseFloat(temp); } catch (NumberFormatException e) { WXLogUtils.e("Argument format error!"); } return result; } }
WXUtils { public static float getFloat(Object value) { if (value == null) { return Float.NaN; } String temp = value.toString().trim(); if (temp.endsWith("px")) { temp = temp.substring(0, temp.indexOf("px")); } float result = Float.NaN; try { result = Float.parseFloat(temp); } catch (NumberFormatException e) { WXLogUtils.e("Argument format error!"); } return result; }  }
WXUtils { public static float getFloat(Object value) { if (value == null) { return Float.NaN; } String temp = value.toString().trim(); if (temp.endsWith("px")) { temp = temp.substring(0, temp.indexOf("px")); } float result = Float.NaN; try { result = Float.parseFloat(temp); } catch (NumberFormatException e) { WXLogUtils.e("Argument format error!"); } return result; }  static boolean isUiThread(); static boolean isUndefined(float value); static float getFloat(Object value); static Float getFloat(Object value, @Nullable Float df); static float fastGetFloat(String raw, int precision); static float fastGetFloat(String raw); static int getInt(Object value); static Integer getInteger(@Nullable Object value, @Nullable Integer df); static long getLong(Object value); static double getDouble(Object value); static boolean isTabletDevice(); static Boolean getBoolean(@Nullable Object value, @Nullable Boolean df); static long getAvailMemory(Context context); static String getString(@Nullable Object value,@Nullable String df); static int parseUnitOrPercent(String raw, int unit); }
WXUtils { public static float getFloat(Object value) { if (value == null) { return Float.NaN; } String temp = value.toString().trim(); if (temp.endsWith("px")) { temp = temp.substring(0, temp.indexOf("px")); } float result = Float.NaN; try { result = Float.parseFloat(temp); } catch (NumberFormatException e) { WXLogUtils.e("Argument format error!"); } return result; }  static boolean isUiThread(); static boolean isUndefined(float value); static float getFloat(Object value); static Float getFloat(Object value, @Nullable Float df); static float fastGetFloat(String raw, int precision); static float fastGetFloat(String raw); static int getInt(Object value); static Integer getInteger(@Nullable Object value, @Nullable Integer df); static long getLong(Object value); static double getDouble(Object value); static boolean isTabletDevice(); static Boolean getBoolean(@Nullable Object value, @Nullable Boolean df); static long getAvailMemory(Context context); static String getString(@Nullable Object value,@Nullable String df); static int parseUnitOrPercent(String raw, int unit); static final char PERCENT; }