Program: 28529
Project: 28529
Buggy source:
protected void prepareHandlers(){
  addHandler(Attributes.View.OnClick,new EventProcessor<V>(){
    @Override public void setOnEventListener(    final V view,    final LayoutParser parser){
      view.setOnClickListener(new View.OnClickListener(){
        @Override public void onClick(        View v){
          fireEvent((ProteusView)view,EventType.OnClick,parser);
        }
      }
);
    }
  }
);
  addHandler(Attributes.View.Background,new DrawableResourceProcessor<V>(){
    @Override public void setDrawable(    V view,    Drawable drawable){
      if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        view.setBackgroundDrawable(drawable);
      }
 else {
        view.setBackground(drawable);
      }
    }
  }
);
  addHandler(Attributes.View.Height,new DimensionAttributeProcessor<V>(){
    @Override public void setDimension(    V view,    String key,    float dimension,    LayoutParser parser){
      ViewGroup.LayoutParams layoutParams=view.getLayoutParams();
      if (layoutParams != null) {
        layoutParams.height=(int)dimension;
        view.setLayoutParams(layoutParams);
      }
    }
  }
);
  addHandler(Attributes.View.Width,new DimensionAttributeProcessor<V>(){
    @Override public void setDimension(    V view,    String key,    float dimension,    LayoutParser parser){
      ViewGroup.LayoutParams layoutParams=view.getLayoutParams();
      if (layoutParams != null) {
        layoutParams.width=(int)dimension;
        view.setLayoutParams(layoutParams);
      }
    }
  }
);
  addHandler(Attributes.View.Weight,new StringAttributeProcessor<V>(){
    @Override public void handle(    String attributeKey,    String attributeValue,    V view){
      LinearLayout.LayoutParams layoutParams;
      if (view.getLayoutParams() instanceof LinearLayout.LayoutParams) {
        layoutParams=(LinearLayout.LayoutParams)view.getLayoutParams();
        layoutParams.weight=ParseHelper.parseFloat(attributeValue);
        view.setLayoutParams(layoutParams);
      }
 else {
        if (ProteusConstants.isLoggingEnabled()) {
          Log.e(TAG,attributeKey + "String_Node_Str");
        }
      }
    }
  }
);
  addHandler(Attributes.View.LayoutGravity,new StringAttributeProcessor<V>(){
    @Override public void handle(    String attributeKey,    String attributeValue,    V view){
      ViewGroup.LayoutParams layoutParams=view.getLayoutParams();
      if (layoutParams instanceof LinearLayout.LayoutParams) {
        LinearLayout.LayoutParams linearLayoutParams=(LinearLayout.LayoutParams)layoutParams;
        linearLayoutParams.gravity=ParseHelper.parseGravity(attributeValue);
        view.setLayoutParams(layoutParams);
      }
 else       if (layoutParams instanceof FrameLayout.LayoutParams) {
        FrameLayout.LayoutParams linearLayoutParams=(FrameLayout.LayoutParams)layoutParams;
        linearLayoutParams.gravity=ParseHelper.parseGravity(attributeValue);
        view.setLayoutParams(layoutParams);
      }
 else {
        if (ProteusConstants.isLoggingEnabled()) {
          Log.e(TAG,attributeKey + "String_Node_Str");
        }
      }
    }
  }
);
  addHandler(Attributes.View.Padding,new DimensionAttributeProcessor<V>(){
    @Override public void setDimension(    V view,    String key,    float dimension,    LayoutParser parser){
      view.setPadding((int)dimension,(int)dimension,(int)dimension,(int)dimension);
    }
  }
);
  addHandler(Attributes.View.PaddingLeft,new DimensionAttributeProcessor<V>(){
    @Override public void setDimension(    V view,    String key,    float dimension,    LayoutParser parser){
      view.setPadding((int)dimension,view.getPaddingTop(),view.getPaddingRight(),view.getPaddingBottom());
    }
  }
);
  addHandler(Attributes.View.PaddingTop,new DimensionAttributeProcessor<V>(){
    @Override public void setDimension(    V view,    String key,    float dimension,    LayoutParser parser){
      view.setPadding(view.getPaddingLeft(),(int)dimension,view.getPaddingRight(),view.getPaddingBottom());
    }
  }
);
  addHandler(Attributes.View.PaddingRight,new DimensionAttributeProcessor<V>(){
    @Override public void setDimension(    V view,    String key,    float dimension,    LayoutParser parser){
      view.setPadding(view.getPaddingLeft(),view.getPaddingTop(),(int)dimension,view.getPaddingBottom());
    }
  }
);
  addHandler(Attributes.View.PaddingBottom,new DimensionAttributeProcessor<V>(){
    @Override public void setDimension(    V view,    String key,    float dimension,    LayoutParser parser){
      view.setPadding(view.getPaddingLeft(),view.getPaddingTop(),view.getPaddingRight(),(int)dimension);
    }
  }
);
  addHandler(Attributes.View.Margin,new DimensionAttributeProcessor<V>(){
    @Override public void setDimension(    V view,    String key,    float dimension,    LayoutParser parser){
      if (view.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
        ViewGroup.MarginLayoutParams layoutParams;
        layoutParams=(ViewGroup.MarginLayoutParams)view.getLayoutParams();
        layoutParams.setMargins((int)dimension,(int)dimension,(int)dimension,(int)dimension);
        view.setLayoutParams(layoutParams);
      }
 else {
        if (ProteusConstants.isLoggingEnabled()) {
          Log.e(TAG,"String_Node_Str");
        }
      }
    }
  }
);
  addHandler(Attributes.View.MarginLeft,new DimensionAttributeProcessor<V>(){
    @Override public void setDimension(    V view,    String key,    float dimension,    LayoutParser parser){
      if (view.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
        ViewGroup.MarginLayoutParams layoutParams;
        layoutParams=(ViewGroup.MarginLayoutParams)view.getLayoutParams();
        layoutParams.setMargins((int)dimension,layoutParams.topMargin,layoutParams.rightMargin,layoutParams.bottomMargin);
        view.setLayoutParams(layoutParams);
      }
 else {
        if (ProteusConstants.isLoggingEnabled()) {
          Log.e(TAG,"String_Node_Str");
        }
      }
    }
  }
);
  addHandler(Attributes.View.MarginTop,new DimensionAttributeProcessor<V>(){
    @Override public void setDimension(    V view,    String key,    float dimension,    LayoutParser parser){
      if (view.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
        ViewGroup.MarginLayoutParams layoutParams;
        layoutParams=(ViewGroup.MarginLayoutParams)view.getLayoutParams();
        layoutParams.setMargins(layoutParams.leftMargin,(int)dimension,layoutParams.rightMargin,layoutParams.bottomMargin);
        view.setLayoutParams(layoutParams);
      }
 else {
        if (ProteusConstants.isLoggingEnabled()) {
          Log.e(TAG,"String_Node_Str");
        }
      }
    }
  }
);
  addHandler(Attributes.View.MarginRight,new DimensionAttributeProcessor<V>(){
    @Override public void setDimension(    V view,    String key,    float dimension,    LayoutParser parser){
      if (view.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
        ViewGroup.MarginLayoutParams layoutParams;
        layoutParams=(ViewGroup.MarginLayoutParams)view.getLayoutParams();
        layoutParams.setMargins(layoutParams.leftMargin,layoutParams.topMargin,(int)dimension,layoutParams.bottomMargin);
        view.setLayoutParams(layoutParams);
      }
 else {
        if (ProteusConstants.isLoggingEnabled()) {
          Log.e(TAG,"String_Node_Str");
        }
      }
    }
  }
);
  addHandler(Attributes.View.MarginBottom,new DimensionAttributeProcessor<V>(){
    @Override public void setDimension(    V view,    String key,    float dimension,    LayoutParser parser){
      if (view.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
        ViewGroup.MarginLayoutParams layoutParams;
        layoutParams=(ViewGroup.MarginLayoutParams)view.getLayoutParams();
        layoutParams.setMargins(layoutParams.leftMargin,layoutParams.topMargin,layoutParams.rightMargin,(int)dimension);
        view.setLayoutParams(layoutParams);
      }
 else {
        if (ProteusConstants.isLoggingEnabled()) {
          Log.e(TAG,"String_Node_Str");
        }
      }
    }
  }
);
  addHandler(Attributes.View.MinHeight,new DimensionAttributeProcessor<V>(){
    @Override public void setDimension(    V view,    String key,    float dimension,    LayoutParser parser){
      view.setMinimumHeight((int)dimension);
    }
  }
);
  addHandler(Attributes.View.MinWidth,new DimensionAttributeProcessor<V>(){
    @Override public void setDimension(    V view,    String key,    float dimension,    LayoutParser parser){
      view.setMinimumWidth((int)dimension);
    }
  }
);
  addHandler(Attributes.View.Elevation,new DimensionAttributeProcessor<V>(){
    @Override public void setDimension(    V view,    String key,    float dimension,    LayoutParser parser){
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        view.setElevation(dimension);
      }
    }
  }
);
  addHandler(Attributes.View.Alpha,new StringAttributeProcessor<V>(){
    @Override public void handle(    String attributeKey,    String attributeValue,    V view){
      view.setAlpha(ParseHelper.parseFloat(attributeValue));
    }
  }
);
  addHandler(Attributes.View.Visibility,new AttributeProcessor<V>(){
    @Override public void handle(    V view,    String key,    LayoutParser parser){
      view.setVisibility(ParseHelper.parseVisibility(parser));
    }
  }
);
  addHandler(Attributes.View.Invisibility,new AttributeProcessor<V>(){
    @Override public void handle(    V view,    String key,    LayoutParser parser){
      view.setVisibility(ParseHelper.parseInvisibility(parser));
    }
  }
);
  addHandler(Attributes.View.Id,new StringAttributeProcessor<V>(){
    @Override public void handle(    String attributeKey,    String attributeValue,    final V view){
      if (view instanceof ProteusView) {
        view.setId(((ProteusView)view).getViewManager().getUniqueViewId(attributeValue));
      }
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        final String resourceName=attributeValue;
        view.setAccessibilityDelegate(new View.AccessibilityDelegate(){
          @Override public void onInitializeAccessibilityNodeInfo(          View host,          AccessibilityNodeInfo info){
            super.onInitializeAccessibilityNodeInfo(host,info);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
              String normalizedResourceName;
              if (!TextUtils.isEmpty(resourceName)) {
                String id;
                if (resourceName.startsWith(ID_STRING_START_PATTERN)) {
                  id=resourceName.substring(ID_STRING_START_PATTERN.length());
                }
 else                 if (resourceName.startsWith(ID_STRING_START_PATTERN1)) {
                  id=resourceName.substring(ID_STRING_START_PATTERN1.length());
                }
 else {
                  id=resourceName;
                }
                normalizedResourceName=view.getContext().getPackageName() + ID_STRING_NORMALIZED_PATTERN + id;
              }
 else {
                normalizedResourceName="String_Node_Str";
              }
              info.setViewIdResourceName(normalizedResourceName);
            }
          }
        }
);
      }
    }
  }
);
  addHandler(Attributes.View.ContentDescription,new StringAttributeProcessor<V>(){
    @Override public void handle(    String attributeKey,    String attributeValue,    V view){
      view.setContentDescription(attributeValue);
    }
  }
);
  addHandler(Attributes.View.Clickable,new StringAttributeProcessor<V>(){
    @Override public void handle(    String attributeKey,    String attributeValue,    V view){
      boolean clickable=ParseHelper.parseBoolean(attributeValue);
      view.setClickable(clickable);
    }
  }
);
  addHandler(Attributes.View.Tag,new StringAttributeProcessor<V>(){
    @Override public void handle(    String attributeKey,    String attributeValue,    V view){
      view.setTag(attributeValue);
    }
  }
);
  addHandler(Attributes.View.Border,new AttributeProcessor<V>(){
    @Override public void handle(    V view,    String key,    LayoutParser parser){
      Drawable border=Utils.getBorderDrawable(parser,view.getContext());
      if (border == null) {
        return;
      }
      if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        view.setBackgroundDrawable(border);
      }
 else {
        view.setBackground(border);
      }
    }
  }
);
  addHandler(Attributes.View.Enabled,new StringAttributeProcessor<V>(){
    @Override public void handle(    String attributeKey,    String attributeValue,    V view){
      boolean enabled=ParseHelper.parseBoolean(attributeValue);
      view.setEnabled(enabled);
    }
  }
);
  addHandler(Attributes.View.Style,new StringAttributeProcessor<V>(){
    @Override public void handle(    String attributeKey,    String attributeValue,    V view){
      ProteusViewManager viewManager=((ProteusView)view).getViewManager();
      LayoutParser parser=viewManager.getLayoutParser();
      Styles styles=viewManager.getStyles();
      TypeHandler handler=viewManager.getProteusLayoutInflater().getHandler(parser.getType());
      if (styles == null) {
        return;
      }
      String[] styleSet=attributeValue.split(ProteusConstants.STYLE_DELIMITER);
      for (      String styleName : styleSet) {
        if (styles.contains(styleName)) {
          process(parser.getValueParser(styles.getStyle(styleName)),parser,(ProteusView)view,(handler != null ? handler : ViewParser.this),viewManager.getProteusLayoutInflater());
        }
      }
    }
    private void process(    LayoutParser style,    LayoutParser layout,    ProteusView proteusView,    TypeHandler handler,    ProteusLayoutInflater builder){
      while (style.hasNext()) {
        style.next();
        style.peek();
        String key=layout.getName();
        if (!layout.isNull(key)) {
          continue;
        }
        builder.handleAttribute(handler,proteusView,key,style);
      }
    }
  }
);
  addHandler(Attributes.View.TransitionName,new StringAttributeProcessor<V>(){
    @Override public void handle(    String attributeKey,    String attributeValue,    V view){
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        view.setTransitionName(attributeValue);
      }
    }
  }
);
  addHandler(Attributes.View.RequiresFadingEdge,new StringAttributeProcessor<V>(){
    private final String NONE="String_Node_Str";
    private final String BOTH="String_Node_Str";
    private final String VERTICAL="String_Node_Str";
    private final String HORIZONTAL="String_Node_Str";
    @Override public void handle(    String attributeKey,    String attributeValue,    V view){
switch (attributeValue) {
case NONE:
        view.setVerticalFadingEdgeEnabled(false);
      view.setHorizontalFadingEdgeEnabled(false);
    break;
case BOTH:
  view.setVerticalFadingEdgeEnabled(true);
view.setHorizontalFadingEdgeEnabled(true);
break;
case VERTICAL:
view.setVerticalFadingEdgeEnabled(true);
view.setHorizontalFadingEdgeEnabled(false);
break;
case HORIZONTAL:
view.setVerticalFadingEdgeEnabled(false);
view.setHorizontalFadingEdgeEnabled(true);
break;
default :
view.setVerticalFadingEdgeEnabled(false);
view.setHorizontalFadingEdgeEnabled(false);
break;
}
}
}
);
addHandler(Attributes.View.FadingEdgeLength,new StringAttributeProcessor<V>(){
@Override public void handle(String attributeKey,String attributeValue,V view){
view.setFadingEdgeLength(ParseHelper.parseInt(attributeValue));
}
}
);
final HashMap<String,Integer> relativeLayoutParams=new HashMap<>();
relativeLayoutParams.put(Attributes.View.Above.getName(),RelativeLayout.ABOVE);
relativeLayoutParams.put(Attributes.View.AlignBaseline.getName(),RelativeLayout.ALIGN_BASELINE);
relativeLayoutParams.put(Attributes.View.AlignBottom.getName(),RelativeLayout.ALIGN_BOTTOM);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
relativeLayoutParams.put(Attributes.View.AlignEnd.getName(),RelativeLayout.ALIGN_END);
}
relativeLayoutParams.put(Attributes.View.AlignLeft.getName(),RelativeLayout.ALIGN_LEFT);
relativeLayoutParams.put(Attributes.View.AlignParentBottom.getName(),RelativeLayout.ALIGN_PARENT_BOTTOM);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
relativeLayoutParams.put(Attributes.View.AlignParentEnd.getName(),RelativeLayout.ALIGN_PARENT_END);
}
relativeLayoutParams.put(Attributes.View.AlignParentLeft.getName(),RelativeLayout.ALIGN_PARENT_LEFT);
relativeLayoutParams.put(Attributes.View.AlignParentRight.getName(),RelativeLayout.ALIGN_PARENT_RIGHT);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
relativeLayoutParams.put(Attributes.View.AlignParentStart.getName(),RelativeLayout.ALIGN_PARENT_START);
}
relativeLayoutParams.put(Attributes.View.AlignParentTop.getName(),RelativeLayout.ALIGN_PARENT_TOP);
relativeLayoutParams.put(Attributes.View.AlignRight.getName(),RelativeLayout.ALIGN_RIGHT);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
relativeLayoutParams.put(Attributes.View.AlignStart.getName(),RelativeLayout.ALIGN_START);
}
relativeLayoutParams.put(Attributes.View.AlignTop.getName(),RelativeLayout.ALIGN_TOP);
relativeLayoutParams.put(Attributes.View.Below.getName(),RelativeLayout.BELOW);
relativeLayoutParams.put(Attributes.View.CenterHorizontal.getName(),RelativeLayout.CENTER_HORIZONTAL);
relativeLayoutParams.put(Attributes.View.CenterInParent.getName(),RelativeLayout.CENTER_IN_PARENT);
relativeLayoutParams.put(Attributes.View.CenterVertical.getName(),RelativeLayout.CENTER_VERTICAL);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
relativeLayoutParams.put(Attributes.View.ToEndOf.getName(),RelativeLayout.END_OF);
}
relativeLayoutParams.put(Attributes.View.ToLeftOf.getName(),RelativeLayout.LEFT_OF);
relativeLayoutParams.put(Attributes.View.ToRightOf.getName(),RelativeLayout.RIGHT_OF);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
relativeLayoutParams.put(Attributes.View.ToStartOf.getName(),RelativeLayout.START_OF);
}
StringAttributeProcessor<V> relativeLayoutProcessor=new StringAttributeProcessor<V>(){
@Override public void handle(String attributeKey,String attributeValue,V view){
if (view instanceof ProteusView) {
int id=((ProteusView)view).getViewManager().getUniqueViewId(attributeValue);
Integer rule=relativeLayoutParams.get(attributeKey);
if (rule != null) {
ParseHelper.addRelativeLayoutRule(view,rule,id);
}
}
}
}
;
StringAttributeProcessor<V> relativeLayoutBooleanProcessor=new StringAttributeProcessor<V>(){
@Override public void handle(String attributeKey,String attributeValue,V view){
int trueOrFalse=ParseHelper.parseRelativeLayoutBoolean(attributeValue);
Integer rule=relativeLayoutParams.get(attributeKey);
if (rule != null) {
ParseHelper.addRelativeLayoutRule(view,rule,trueOrFalse);
}
}
}
;
addHandler(Attributes.View.Above,relativeLayoutProcessor);
addHandler(Attributes.View.AlignBaseline,relativeLayoutProcessor);
addHandler(Attributes.View.AlignBottom,relativeLayoutProcessor);
addHandler(Attributes.View.AlignEnd,relativeLayoutProcessor);
addHandler(Attributes.View.AlignLeft,relativeLayoutProcessor);
addHandler(Attributes.View.AlignRight,relativeLayoutProcessor);
addHandler(Attributes.View.AlignStart,relativeLayoutProcessor);
addHandler(Attributes.View.AlignTop,relativeLayoutProcessor);
addHandler(Attributes.View.Below,relativeLayoutProcessor);
addHandler(Attributes.View.ToEndOf,relativeLayoutProcessor);
addHandler(Attributes.View.ToLeftOf,relativeLayoutProcessor);
addHandler(Attributes.View.ToRightOf,relativeLayoutProcessor);
addHandler(Attributes.View.ToStartOf,relativeLayoutProcessor);
addHandler(Attributes.View.AlignParentBottom,relativeLayoutBooleanProcessor);
addHandler(Attributes.View.AlignParentEnd,relativeLayoutBooleanProcessor);
addHandler(Attributes.View.AlignParentLeft,relativeLayoutBooleanProcessor);
addHandler(Attributes.View.AlignParentRight,relativeLayoutBooleanProcessor);
addHandler(Attributes.View.AlignParentStart,relativeLayoutBooleanProcessor);
addHandler(Attributes.View.AlignParentTop,relativeLayoutBooleanProcessor);
addHandler(Attributes.View.CenterHorizontal,relativeLayoutBooleanProcessor);
addHandler(Attributes.View.CenterInParent,relativeLayoutBooleanProcessor);
addHandler(Attributes.View.CenterVertical,relativeLayoutBooleanProcessor);
addHandler(Attributes.View.Animation,new TweenAnimationResourceProcessor<V>(){
@Override public void setAnimation(V view,Animation animation){
view.setAnimation(animation);
}
}
);
addHandler(Attributes.View.TextAlignment,new StringAttributeProcessor<V>(){
@Override public void handle(String attributeKey,String attributeValue,V view){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
Integer textAlignment=ParseHelper.parseTextAlignment(attributeValue);
if (null != textAlignment) {
view.setTextAlignment(textAlignment);
}
}
}
}
);
}

Fixed version (ground truth):
protected void prepareHandlers(){
  addHandler(Attributes.View.OnClick,new EventProcessor<V>(){
    @Override public void setOnEventListener(    final V view,    final LayoutParser parser){
      view.setOnClickListener(new View.OnClickListener(){
        @Override public void onClick(        View v){
          fireEvent((ProteusView)view,EventType.OnClick,parser);
        }
      }
);
    }
  }
);
  addHandler(Attributes.View.Background,new DrawableResourceProcessor<V>(){
    @Override public void setDrawable(    V view,    Drawable drawable){
      if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        view.setBackgroundDrawable(drawable);
      }
 else {
        view.setBackground(drawable);
      }
    }
  }
);
  addHandler(Attributes.View.Height,new DimensionAttributeProcessor<V>(){
    @Override public void setDimension(    V view,    String key,    float dimension,    LayoutParser parser){
      ViewGroup.LayoutParams layoutParams=view.getLayoutParams();
      if (layoutParams != null) {
        layoutParams.height=(int)dimension;
        view.setLayoutParams(layoutParams);
      }
    }
  }
);
  addHandler(Attributes.View.Width,new DimensionAttributeProcessor<V>(){
    @Override public void setDimension(    V view,    String key,    float dimension,    LayoutParser parser){
      ViewGroup.LayoutParams layoutParams=view.getLayoutParams();
      if (layoutParams != null) {
        layoutParams.width=(int)dimension;
        view.setLayoutParams(layoutParams);
      }
    }
  }
);
  addHandler(Attributes.View.Weight,new StringAttributeProcessor<V>(){
    @Override public void handle(    String attributeKey,    String attributeValue,    V view){
      LinearLayout.LayoutParams layoutParams;
      if (view.getLayoutParams() instanceof LinearLayout.LayoutParams) {
        layoutParams=(LinearLayout.LayoutParams)view.getLayoutParams();
        layoutParams.weight=ParseHelper.parseFloat(attributeValue);
        view.setLayoutParams(layoutParams);
      }
 else {
        if (ProteusConstants.isLoggingEnabled()) {
          Log.e(TAG,attributeKey + "String_Node_Str");
        }
      }
    }
  }
);
  addHandler(Attributes.View.LayoutGravity,new StringAttributeProcessor<V>(){
    @Override public void handle(    String attributeKey,    String attributeValue,    V view){
      ViewGroup.LayoutParams layoutParams=view.getLayoutParams();
      if (layoutParams instanceof LinearLayout.LayoutParams) {
        LinearLayout.LayoutParams linearLayoutParams=(LinearLayout.LayoutParams)layoutParams;
        linearLayoutParams.gravity=ParseHelper.parseGravity(attributeValue);
        view.setLayoutParams(layoutParams);
      }
 else       if (layoutParams instanceof FrameLayout.LayoutParams) {
        FrameLayout.LayoutParams linearLayoutParams=(FrameLayout.LayoutParams)layoutParams;
        linearLayoutParams.gravity=ParseHelper.parseGravity(attributeValue);
        view.setLayoutParams(layoutParams);
      }
 else {
        if (ProteusConstants.isLoggingEnabled()) {
          Log.e(TAG,attributeKey + "String_Node_Str");
        }
      }
    }
  }
);
  addHandler(Attributes.View.Padding,new DimensionAttributeProcessor<V>(){
    @Override public void setDimension(    V view,    String key,    float dimension,    LayoutParser parser){
      view.setPadding((int)dimension,(int)dimension,(int)dimension,(int)dimension);
    }
  }
);
  addHandler(Attributes.View.PaddingLeft,new DimensionAttributeProcessor<V>(){
    @Override public void setDimension(    V view,    String key,    float dimension,    LayoutParser parser){
      view.setPadding((int)dimension,view.getPaddingTop(),view.getPaddingRight(),view.getPaddingBottom());
    }
  }
);
  addHandler(Attributes.View.PaddingTop,new DimensionAttributeProcessor<V>(){
    @Override public void setDimension(    V view,    String key,    float dimension,    LayoutParser parser){
      view.setPadding(view.getPaddingLeft(),(int)dimension,view.getPaddingRight(),view.getPaddingBottom());
    }
  }
);
  addHandler(Attributes.View.PaddingRight,new DimensionAttributeProcessor<V>(){
    @Override public void setDimension(    V view,    String key,    float dimension,    LayoutParser parser){
      view.setPadding(view.getPaddingLeft(),view.getPaddingTop(),(int)dimension,view.getPaddingBottom());
    }
  }
);
  addHandler(Attributes.View.PaddingBottom,new DimensionAttributeProcessor<V>(){
    @Override public void setDimension(    V view,    String key,    float dimension,    LayoutParser parser){
      view.setPadding(view.getPaddingLeft(),view.getPaddingTop(),view.getPaddingRight(),(int)dimension);
    }
  }
);
  addHandler(Attributes.View.Margin,new DimensionAttributeProcessor<V>(){
    @Override public void setDimension(    V view,    String key,    float dimension,    LayoutParser parser){
      if (view.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
        ViewGroup.MarginLayoutParams layoutParams;
        layoutParams=(ViewGroup.MarginLayoutParams)view.getLayoutParams();
        layoutParams.setMargins((int)dimension,(int)dimension,(int)dimension,(int)dimension);
        view.setLayoutParams(layoutParams);
      }
 else {
        if (ProteusConstants.isLoggingEnabled()) {
          Log.e(TAG,"String_Node_Str");
        }
      }
    }
  }
);
  addHandler(Attributes.View.MarginLeft,new DimensionAttributeProcessor<V>(){
    @Override public void setDimension(    V view,    String key,    float dimension,    LayoutParser parser){
      if (view.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
        ViewGroup.MarginLayoutParams layoutParams;
        layoutParams=(ViewGroup.MarginLayoutParams)view.getLayoutParams();
        layoutParams.setMargins((int)dimension,layoutParams.topMargin,layoutParams.rightMargin,layoutParams.bottomMargin);
        view.setLayoutParams(layoutParams);
      }
 else {
        if (ProteusConstants.isLoggingEnabled()) {
          Log.e(TAG,"String_Node_Str");
        }
      }
    }
  }
);
  addHandler(Attributes.View.MarginTop,new DimensionAttributeProcessor<V>(){
    @Override public void setDimension(    V view,    String key,    float dimension,    LayoutParser parser){
      if (view.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
        ViewGroup.MarginLayoutParams layoutParams;
        layoutParams=(ViewGroup.MarginLayoutParams)view.getLayoutParams();
        layoutParams.setMargins(layoutParams.leftMargin,(int)dimension,layoutParams.rightMargin,layoutParams.bottomMargin);
        view.setLayoutParams(layoutParams);
      }
 else {
        if (ProteusConstants.isLoggingEnabled()) {
          Log.e(TAG,"String_Node_Str");
        }
      }
    }
  }
);
  addHandler(Attributes.View.MarginRight,new DimensionAttributeProcessor<V>(){
    @Override public void setDimension(    V view,    String key,    float dimension,    LayoutParser parser){
      if (view.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
        ViewGroup.MarginLayoutParams layoutParams;
        layoutParams=(ViewGroup.MarginLayoutParams)view.getLayoutParams();
        layoutParams.setMargins(layoutParams.leftMargin,layoutParams.topMargin,(int)dimension,layoutParams.bottomMargin);
        view.setLayoutParams(layoutParams);
      }
 else {
        if (ProteusConstants.isLoggingEnabled()) {
          Log.e(TAG,"String_Node_Str");
        }
      }
    }
  }
);
  addHandler(Attributes.View.MarginBottom,new DimensionAttributeProcessor<V>(){
    @Override public void setDimension(    V view,    String key,    float dimension,    LayoutParser parser){
      if (view.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
        ViewGroup.MarginLayoutParams layoutParams;
        layoutParams=(ViewGroup.MarginLayoutParams)view.getLayoutParams();
        layoutParams.setMargins(layoutParams.leftMargin,layoutParams.topMargin,layoutParams.rightMargin,(int)dimension);
        view.setLayoutParams(layoutParams);
      }
 else {
        if (ProteusConstants.isLoggingEnabled()) {
          Log.e(TAG,"String_Node_Str");
        }
      }
    }
  }
);
  addHandler(Attributes.View.MinHeight,new DimensionAttributeProcessor<V>(){
    @Override public void setDimension(    V view,    String key,    float dimension,    LayoutParser parser){
      view.setMinimumHeight((int)dimension);
    }
  }
);
  addHandler(Attributes.View.MinWidth,new DimensionAttributeProcessor<V>(){
    @Override public void setDimension(    V view,    String key,    float dimension,    LayoutParser parser){
      view.setMinimumWidth((int)dimension);
    }
  }
);
  addHandler(Attributes.View.Elevation,new DimensionAttributeProcessor<V>(){
    @Override public void setDimension(    V view,    String key,    float dimension,    LayoutParser parser){
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        view.setElevation(dimension);
      }
    }
  }
);
  addHandler(Attributes.View.Alpha,new StringAttributeProcessor<V>(){
    @Override public void handle(    String attributeKey,    String attributeValue,    V view){
      view.setAlpha(ParseHelper.parseFloat(attributeValue));
    }
  }
);
  addHandler(Attributes.View.Visibility,new AttributeProcessor<V>(){
    @Override public void handle(    V view,    String key,    LayoutParser parser){
      view.setVisibility(ParseHelper.parseVisibility(parser));
    }
  }
);
  addHandler(Attributes.View.Invisibility,new AttributeProcessor<V>(){
    @Override public void handle(    V view,    String key,    LayoutParser parser){
      view.setVisibility(ParseHelper.parseInvisibility(parser));
    }
  }
);
  addHandler(Attributes.View.Id,new StringAttributeProcessor<V>(){
    @Override public void handle(    String attributeKey,    String attributeValue,    final V view){
      if (view instanceof ProteusView) {
        view.setId(((ProteusView)view).getViewManager().getUniqueViewId(attributeValue));
      }
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        final String resourceName=attributeValue;
        view.setAccessibilityDelegate(new View.AccessibilityDelegate(){
          @Override public void onInitializeAccessibilityNodeInfo(          View host,          AccessibilityNodeInfo info){
            super.onInitializeAccessibilityNodeInfo(host,info);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
              String normalizedResourceName;
              if (!TextUtils.isEmpty(resourceName)) {
                String id;
                if (resourceName.startsWith(ID_STRING_START_PATTERN)) {
                  id=resourceName.substring(ID_STRING_START_PATTERN.length());
                }
 else                 if (resourceName.startsWith(ID_STRING_START_PATTERN1)) {
                  id=resourceName.substring(ID_STRING_START_PATTERN1.length());
                }
 else {
                  id=resourceName;
                }
                normalizedResourceName=view.getContext().getPackageName() + ID_STRING_NORMALIZED_PATTERN + id;
              }
 else {
                normalizedResourceName="String_Node_Str";
              }
              info.setViewIdResourceName(normalizedResourceName);
            }
          }
        }
);
      }
    }
  }
);
  addHandler(Attributes.View.ContentDescription,new StringAttributeProcessor<V>(){
    @Override public void handle(    String attributeKey,    String attributeValue,    V view){
      view.setContentDescription(attributeValue);
    }
  }
);
  addHandler(Attributes.View.Clickable,new StringAttributeProcessor<V>(){
    @Override public void handle(    String attributeKey,    String attributeValue,    V view){
      boolean clickable=ParseHelper.parseBoolean(attributeValue);
      view.setClickable(clickable);
    }
  }
);
  addHandler(Attributes.View.Tag,new StringAttributeProcessor<V>(){
    @Override public void handle(    String attributeKey,    String attributeValue,    V view){
      view.setTag(attributeValue);
    }
  }
);
  addHandler(Attributes.View.Border,new AttributeProcessor<V>(){
    @Override public void handle(    V view,    String key,    LayoutParser parser){
      Drawable border=Utils.getBorderDrawable(parser,view.getContext());
      if (border == null) {
        return;
      }
      if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        view.setBackgroundDrawable(border);
      }
 else {
        view.setBackground(border);
      }
    }
  }
);
  addHandler(Attributes.View.Enabled,new StringAttributeProcessor<V>(){
    @Override public void handle(    String attributeKey,    String attributeValue,    V view){
      boolean enabled=ParseHelper.parseBoolean(attributeValue);
      view.setEnabled(enabled);
    }
  }
);
  addHandler(Attributes.View.Style,new StringAttributeProcessor<V>(){
    @Override public void handle(    String attributeKey,    String attributeValue,    V view){
      ProteusViewManager viewManager=((ProteusView)view).getViewManager();
      LayoutParser parser=viewManager.getLayoutParser();
      Styles styles=viewManager.getStyles();
      TypeHandler handler=viewManager.getProteusLayoutInflater().getHandler(parser.getType());
      if (styles == null) {
        return;
      }
      String[] styleSet=attributeValue.split(ProteusConstants.STYLE_DELIMITER);
      for (      String styleName : styleSet) {
        if (styles.contains(styleName)) {
          process(parser.getValueParser(styles.getStyle(styleName)),parser,(ProteusView)view,(handler != null ? handler : ViewParser.this),viewManager.getProteusLayoutInflater());
        }
      }
    }
    private void process(    LayoutParser style,    LayoutParser layout,    ProteusView proteusView,    TypeHandler handler,    ProteusLayoutInflater builder){
      while (style.hasNext()) {
        style.next();
        String key=style.getName();
        if (!layout.isNull(key)) {
          continue;
        }
        builder.handleAttribute(handler,proteusView,key,style.peek());
      }
    }
  }
);
  addHandler(Attributes.View.TransitionName,new StringAttributeProcessor<V>(){
    @Override public void handle(    String attributeKey,    String attributeValue,    V view){
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        view.setTransitionName(attributeValue);
      }
    }
  }
);
  addHandler(Attributes.View.RequiresFadingEdge,new StringAttributeProcessor<V>(){
    private final String NONE="String_Node_Str";
    private final String BOTH="String_Node_Str";
    private final String VERTICAL="String_Node_Str";
    private final String HORIZONTAL="String_Node_Str";
    @Override public void handle(    String attributeKey,    String attributeValue,    V view){
switch (attributeValue) {
case NONE:
        view.setVerticalFadingEdgeEnabled(false);
      view.setHorizontalFadingEdgeEnabled(false);
    break;
case BOTH:
  view.setVerticalFadingEdgeEnabled(true);
view.setHorizontalFadingEdgeEnabled(true);
break;
case VERTICAL:
view.setVerticalFadingEdgeEnabled(true);
view.setHorizontalFadingEdgeEnabled(false);
break;
case HORIZONTAL:
view.setVerticalFadingEdgeEnabled(false);
view.setHorizontalFadingEdgeEnabled(true);
break;
default :
view.setVerticalFadingEdgeEnabled(false);
view.setHorizontalFadingEdgeEnabled(false);
break;
}
}
}
);
addHandler(Attributes.View.FadingEdgeLength,new StringAttributeProcessor<V>(){
@Override public void handle(String attributeKey,String attributeValue,V view){
view.setFadingEdgeLength(ParseHelper.parseInt(attributeValue));
}
}
);
final HashMap<String,Integer> relativeLayoutParams=new HashMap<>();
relativeLayoutParams.put(Attributes.View.Above.getName(),RelativeLayout.ABOVE);
relativeLayoutParams.put(Attributes.View.AlignBaseline.getName(),RelativeLayout.ALIGN_BASELINE);
relativeLayoutParams.put(Attributes.View.AlignBottom.getName(),RelativeLayout.ALIGN_BOTTOM);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
relativeLayoutParams.put(Attributes.View.AlignEnd.getName(),RelativeLayout.ALIGN_END);
}
relativeLayoutParams.put(Attributes.View.AlignLeft.getName(),RelativeLayout.ALIGN_LEFT);
relativeLayoutParams.put(Attributes.View.AlignParentBottom.getName(),RelativeLayout.ALIGN_PARENT_BOTTOM);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
relativeLayoutParams.put(Attributes.View.AlignParentEnd.getName(),RelativeLayout.ALIGN_PARENT_END);
}
relativeLayoutParams.put(Attributes.View.AlignParentLeft.getName(),RelativeLayout.ALIGN_PARENT_LEFT);
relativeLayoutParams.put(Attributes.View.AlignParentRight.getName(),RelativeLayout.ALIGN_PARENT_RIGHT);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
relativeLayoutParams.put(Attributes.View.AlignParentStart.getName(),RelativeLayout.ALIGN_PARENT_START);
}
relativeLayoutParams.put(Attributes.View.AlignParentTop.getName(),RelativeLayout.ALIGN_PARENT_TOP);
relativeLayoutParams.put(Attributes.View.AlignRight.getName(),RelativeLayout.ALIGN_RIGHT);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
relativeLayoutParams.put(Attributes.View.AlignStart.getName(),RelativeLayout.ALIGN_START);
}
relativeLayoutParams.put(Attributes.View.AlignTop.getName(),RelativeLayout.ALIGN_TOP);
relativeLayoutParams.put(Attributes.View.Below.getName(),RelativeLayout.BELOW);
relativeLayoutParams.put(Attributes.View.CenterHorizontal.getName(),RelativeLayout.CENTER_HORIZONTAL);
relativeLayoutParams.put(Attributes.View.CenterInParent.getName(),RelativeLayout.CENTER_IN_PARENT);
relativeLayoutParams.put(Attributes.View.CenterVertical.getName(),RelativeLayout.CENTER_VERTICAL);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
relativeLayoutParams.put(Attributes.View.ToEndOf.getName(),RelativeLayout.END_OF);
}
relativeLayoutParams.put(Attributes.View.ToLeftOf.getName(),RelativeLayout.LEFT_OF);
relativeLayoutParams.put(Attributes.View.ToRightOf.getName(),RelativeLayout.RIGHT_OF);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
relativeLayoutParams.put(Attributes.View.ToStartOf.getName(),RelativeLayout.START_OF);
}
StringAttributeProcessor<V> relativeLayoutProcessor=new StringAttributeProcessor<V>(){
@Override public void handle(String attributeKey,String attributeValue,V view){
if (view instanceof ProteusView) {
int id=((ProteusView)view).getViewManager().getUniqueViewId(attributeValue);
Integer rule=relativeLayoutParams.get(attributeKey);
if (rule != null) {
ParseHelper.addRelativeLayoutRule(view,rule,id);
}
}
}
}
;
StringAttributeProcessor<V> relativeLayoutBooleanProcessor=new StringAttributeProcessor<V>(){
@Override public void handle(String attributeKey,String attributeValue,V view){
int trueOrFalse=ParseHelper.parseRelativeLayoutBoolean(attributeValue);
Integer rule=relativeLayoutParams.get(attributeKey);
if (rule != null) {
ParseHelper.addRelativeLayoutRule(view,rule,trueOrFalse);
}
}
}
;
addHandler(Attributes.View.Above,relativeLayoutProcessor);
addHandler(Attributes.View.AlignBaseline,relativeLayoutProcessor);
addHandler(Attributes.View.AlignBottom,relativeLayoutProcessor);
addHandler(Attributes.View.AlignEnd,relativeLayoutProcessor);
addHandler(Attributes.View.AlignLeft,relativeLayoutProcessor);
addHandler(Attributes.View.AlignRight,relativeLayoutProcessor);
addHandler(Attributes.View.AlignStart,relativeLayoutProcessor);
addHandler(Attributes.View.AlignTop,relativeLayoutProcessor);
addHandler(Attributes.View.Below,relativeLayoutProcessor);
addHandler(Attributes.View.ToEndOf,relativeLayoutProcessor);
addHandler(Attributes.View.ToLeftOf,relativeLayoutProcessor);
addHandler(Attributes.View.ToRightOf,relativeLayoutProcessor);
addHandler(Attributes.View.ToStartOf,relativeLayoutProcessor);
addHandler(Attributes.View.AlignParentBottom,relativeLayoutBooleanProcessor);
addHandler(Attributes.View.AlignParentEnd,relativeLayoutBooleanProcessor);
addHandler(Attributes.View.AlignParentLeft,relativeLayoutBooleanProcessor);
addHandler(Attributes.View.AlignParentRight,relativeLayoutBooleanProcessor);
addHandler(Attributes.View.AlignParentStart,relativeLayoutBooleanProcessor);
addHandler(Attributes.View.AlignParentTop,relativeLayoutBooleanProcessor);
addHandler(Attributes.View.CenterHorizontal,relativeLayoutBooleanProcessor);
addHandler(Attributes.View.CenterInParent,relativeLayoutBooleanProcessor);
addHandler(Attributes.View.CenterVertical,relativeLayoutBooleanProcessor);
addHandler(Attributes.View.Animation,new TweenAnimationResourceProcessor<V>(){
@Override public void setAnimation(V view,Animation animation){
view.setAnimation(animation);
}
}
);
addHandler(Attributes.View.TextAlignment,new StringAttributeProcessor<V>(){
@Override public void handle(String attributeKey,String attributeValue,V view){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
Integer textAlignment=ParseHelper.parseTextAlignment(attributeValue);
if (null != textAlignment) {
view.setTextAlignment(textAlignment);
}
}
}
}
);
}