Skip to content

Commit

Permalink
Merge pull request #20 from drivfe/various
Browse files Browse the repository at this point in the history
improve layout templates and textview converter
  • Loading branch information
FabianTerhorst committed Jun 8, 2016
2 parents f9648ac + 9334f2c commit afdbe40
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
/**
* Created by fabianterhorst on 14.05.16.
*/
//@Layouts(all = true/*, exclude = {R.layout.item_sample}*/)
@Layouts(ids = {R.layout.activity_main, R.layout.item_sample, R.layout.card_view})
@Layouts(all = true/*, exclude = {R.layout.item_sample}*/)
//@Layouts(ids = {R.layout.activity_main, R.layout.item_sample, R.layout.card_view})
//@Layouts(layouts = {"activity_main"})
//@Layouts
public class AppLayouts {
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/card_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
app:cardElevation="2dp"
app:cardMaxElevation="@android:dimen/dialog_min_width_minor"
app:cardPreventCornerOverlap="true"
app:cardUseCompatPadding="true" >
app:cardUseCompatPadding="true"
app:contentPadding="5dp" >

<TextView
android:layout_width="match_parent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ public class TextViewLayoutConverter extends LayoutConverter {

private Object drawableRelative[] = new Object[]{null, null};//start,end

@Override
public LayoutAttribute onConvertLayoutAttributeValue(String attributeValue, String attributeName) {
switch(attributeName) {
case "android:ellipsize":
return super.onConvertLayoutAttribute(attributeValue, "android.text.TextUtils.TruncateAt."+attributeValue.toUpperCase(), attributeName, false);
}
return super.onConvertLayoutAttributeValue(attributeValue, attributeName);
}

@Override
public LayoutAttribute onConvertLayoutAttribute(String attributeStartValue, String attributeValue, String attributeName, boolean isString) {
switch (attributeName) {
Expand Down Expand Up @@ -39,6 +48,10 @@ public LayoutAttribute onConvertLayoutAttribute(String attributeStartValue, Stri
case "android:drawableEnd":
drawableRelative = new Object[]{drawableRelative[0] != null ? drawableRelative[0] : drawable[0], drawable[1], attributeValue, drawable[3]};
return new LayoutAttribute();
case "android:maxLength":
//setFilters(new InputFilter[] { new InputFilter.LengthFilter(maxlength) });
String value = String.format("new android.text.InputFilter[] { new android.text.InputFilter.LengthFilter(%s) }", attributeValue);
return new LayoutAttribute(setter("Filters", value, false));
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class ${keyWrapperClassName} extends ${rootLayout.name} implements ILayou
</#if>
</#list>
this.setLayoutParams(${rootLayout.id}LayoutParams);

<#assign parent = "this">
<#list rootLayout.children as child>
${child.id} = new ${child.name}(<#list child.attributes as attribute><#if attribute.isLayoutConstructor()>${attribute.value}<#if !attribute.last>,</#if></#if></#list>);
Expand All @@ -57,6 +58,7 @@ public class ${keyWrapperClassName} extends ${rootLayout.name} implements ILayou
</#if>
</#list>
${child.parent}.addView(${child.id}, ${child.id}LayoutParams);

</#list>
}

Expand Down

0 comments on commit afdbe40

Please sign in to comment.