feat(ui): default dimension dp

This commit is contained in:
hyb1996
2018-10-12 20:54:48 +08:00
parent 8a7966ba3c
commit aa7318bfbd
3 changed files with 11 additions and 2 deletions

View File

@@ -59,7 +59,7 @@ public class Dimensions {
if (!m.matches()) {
throw new InflateException("dimension cannot be resolved: " + dimension);
}
int unit = m.groupCount() == 2 ? UNITS.get(m.group(2)) : TypedValue.COMPLEX_UNIT_PX;
int unit = m.groupCount() == 2 ? UNITS.getOr(m.group(2), TypedValue.COMPLEX_UNIT_DIP) : TypedValue.COMPLEX_UNIT_DIP;
float value = Integer.valueOf(m.group(1));
return TypedValue.applyDimension(unit, value, context.getResources().getDisplayMetrics());
}

View File

@@ -22,6 +22,15 @@ public class ValueMapper<V> {
return this;
}
public V getOr(String key, V defValue) {
V v = mHashMap.get(key);
if (v == null) {
return defValue;
}
return v;
}
public V get(String key) {
V v = mHashMap.get(key);
if (v == null) {