use of com.willowtreeapps.hyperion.attr.ViewAttribute in project Hyperion-Android by willowtreeapps.
the class EditTextAttributeCollector method collect.
@NonNull
@Override
public List<ViewAttribute> collect(final EditText view, AttributeTranslator attributeTranslator) {
List<ViewAttribute> attributes = new ArrayList<>();
attributes.add(new MutableBooleanViewAttribute("FreezesText", view.getFreezesText()) {
@Override
protected void mutate(Boolean value) {
view.setFreezesText(value);
}
});
return attributes;
}
use of com.willowtreeapps.hyperion.attr.ViewAttribute in project Hyperion-Android by willowtreeapps.
the class BottomNavigationViewAttributeCollector method collect.
@NonNull
@Override
public List<ViewAttribute> collect(BottomNavigationView view, AttributeTranslator attributeTranslator) {
final Context context = view.getContext();
final Resources res = context.getResources();
List<ViewAttribute> attributes = new ArrayList<>();
attributes.add(new ViewAttribute<>("MaxItemCount", view.getMaxItemCount()));
attributes.add(Collectors.createColorAttribute(view, "ItemTint", view.getItemIconTintList()));
attributes.add(Collectors.createColorAttribute(view, "ItemTextColor", view.getItemTextColor()));
attributes.add(new ViewAttribute<>("SelectedItemId", new ResourceValue(res, view.getSelectedItemId())));
attributes.add(new ViewAttribute<>("ItemBackgroundRes", new ResourceValue(res, view.getItemBackgroundResource())));
attributes.addAll(Collectors.createMenuAttributes(context, view.getMenu()));
return attributes;
}
use of com.willowtreeapps.hyperion.attr.ViewAttribute in project Hyperion-Android by willowtreeapps.
the class TextViewAttributeCollector method collect.
@NonNull
@Override
public List<ViewAttribute> collect(final TextView view, AttributeTranslator attributeTranslator) {
List<ViewAttribute> attributes = new ArrayList<>();
attributes.add(new MutableStringViewAttribute("Text", view.getText().toString()) {
@Override
protected void mutate(CharSequence value) {
view.setText(value);
}
});
attributes.add(new MutableStringViewAttribute("Hint", view.getHint()) {
@Override
protected void mutate(CharSequence value) {
view.setHint(value);
}
});
attributes.add(new ViewAttribute<>("TextColor", new ColorValue(view.getCurrentTextColor()), new ColorDrawable(view.getCurrentTextColor())));
attributes.add(new ViewAttribute<>("HintColor", new ColorValue(view.getCurrentHintTextColor()), new ColorDrawable(view.getCurrentHintTextColor())));
attributes.add(new ViewAttribute<>("Typeface", view.getTypeface()));
attributes.add(new ViewAttribute<>("TextSize", attributeTranslator.translatePxToSp((int) view.getTextSize())));
attributes.add(new ViewAttribute<>("AutoSizeMaxTextSize", TextViewCompat.getAutoSizeMaxTextSize(view)));
attributes.add(new ViewAttribute<>("AutoSizeMinTextSize", TextViewCompat.getAutoSizeMinTextSize(view)));
attributes.add(new ViewAttribute<>("AutoSizeStepGranularity", TextViewCompat.getAutoSizeStepGranularity(view)));
attributes.add(new ViewAttribute<>("Gravity", new GravityValue(view.getGravity())));
attributes.add(new ViewAttribute<>("ImeAction", view.getImeActionId()));
attributes.add(new ViewAttribute<>("ImeActionLabel", view.getImeActionLabel()));
attributes.add(new ViewAttribute<>("ImeOptions", new ImeOptionsValue(view.getImeOptions())));
attributes.add(new ViewAttribute<>("CompoundPaddingLeft", attributeTranslator.translatePx(view.getCompoundPaddingLeft())));
attributes.add(new ViewAttribute<>("CompoundPaddingTop", attributeTranslator.translatePx(view.getCompoundPaddingTop())));
attributes.add(new ViewAttribute<>("CompoundPaddingRight", attributeTranslator.translatePx(view.getCompoundPaddingRight())));
attributes.add(new ViewAttribute<>("CompoundPaddingBottom", attributeTranslator.translatePx(view.getCompoundPaddingBottom())));
attributes.add(new ViewAttribute<>("CompoundDrawable", attributeTranslator.translatePx(view.getCompoundDrawablePadding())));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
attributes.add(Collectors.createColorAttribute(view, "CompoundDrawableTint", view.getCompoundDrawableTintList()));
attributes.add(new ViewAttribute<>("CompoundDrawableTintMode", new PorterDuffModeValue(view.getCompoundDrawableTintMode())));
}
return attributes;
}
use of com.willowtreeapps.hyperion.attr.ViewAttribute in project Hyperion-Android by willowtreeapps.
the class FrameLayoutAttributeCollector method collect.
@NonNull
@Override
public List<ViewAttribute> collect(final FrameLayout view, AttributeTranslator attributeTranslator) {
List<ViewAttribute> attributes = new ArrayList<>();
attributes.add(new MutableBooleanViewAttribute("MeasureAllChildren", view.getMeasureAllChildren()) {
@Override
protected void mutate(Boolean value) throws Exception {
view.setMeasureAllChildren(value);
}
});
return attributes;
}
use of com.willowtreeapps.hyperion.attr.ViewAttribute in project Hyperion-Android by willowtreeapps.
the class LinearLayoutAttributeCollector method collect.
@NonNull
@Override
public List<ViewAttribute> collect(final LinearLayout view, AttributeTranslator attributeTranslator) {
List<ViewAttribute> attributes = new ArrayList<>();
attributes.add(new ViewAttribute<>("Orientation", new OrientationValue(view.getOrientation())));
attributes.add(new ViewAttribute<>("WeightSum", view.getWeightSum()));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
attributes.add(new ViewAttribute<>("Gravity", new GravityValue(view.getGravity())));
}
attributes.add(new ViewAttribute<>("ShowDividers", new DividerModeValue(view.getShowDividers())));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
attributes.add(new ViewAttribute<Void>("Divider", view.getDividerDrawable()));
}
attributes.add(new ViewAttribute<>("DividerPadding", attributeTranslator.translatePx(view.getDividerPadding())));
attributes.add(new MutableBooleanViewAttribute("MeasureWithLargestChild", view.isMeasureWithLargestChildEnabled()) {
@Override
protected void mutate(Boolean value) throws Exception {
view.setMeasureWithLargestChildEnabled(value);
}
});
attributes.add(new MutableBooleanViewAttribute("BaselineAligned", view.isBaselineAligned()) {
@Override
protected void mutate(Boolean value) throws Exception {
view.setBaselineAligned(value);
}
});
attributes.add(new MutableStringViewAttribute("BaselineAlignedChildIndex", String.valueOf(view.getBaselineAlignedChildIndex())) {
@Override
protected void mutate(CharSequence value) throws Exception {
int index = Integer.parseInt(value.toString());
view.setBaselineAlignedChildIndex(index);
}
});
return attributes;
}
Aggregations