@Override public void setString(V view, String value) { view.setAlpha(ParseHelper.parseFloat(value)); } });
@Override public void setString(T view, String value) { view.setMaxLines(ParseHelper.parseInt(value)); } });
@Override public void setBoolean(V view, boolean value) { int trueOrFalse = ParseHelper.parseRelativeLayoutBoolean(value); ParseHelper.addRelativeLayoutRule(view, rule, trueOrFalse); } };
@Override public Value compile(@Nullable Value value, Context context) { int visibility = ParseHelper.parseVisibility(value); return ParseHelper.getVisibility(visibility); } });
@NonNull @Override public Value call(Context context, Value data, int dataIndex, Value... arguments) throws Exception { if (arguments.length < 1) { return ProteusConstants.TRUE; } return ParseHelper.parseBoolean(arguments[0]) ? ProteusConstants.FALSE : ProteusConstants.TRUE; }
private static Animation handleString(Context c, String value) { Animation anim = null; if (ParseHelper.isTweenAnimationResource(value)) { try { Resources r = c.getResources(); int animationId = r.getIdentifier(value, "anim", c.getPackageName()); anim = android.view.animation.AnimationUtils.loadAnimation(c, animationId); } catch (Exception ex) { System.out.println("Could not load local resource " + value); } } return anim; }
/** * Get int resource id, by just passing the string value of android:id from xml file. * Note : This method only works for @android:id or @+android:id right now * * @param fullResIdString the string id of the view * @return the number id of the view */ public static int getAndroidXmlResId(String fullResIdString) { if (fullResIdString != null) { int i = fullResIdString.indexOf("/"); if (i >= 0) { String idString = fullResIdString.substring(i + 1); return getResId(idString, android.R.id.class); } } return View.NO_ID; }
@Override public Value compile(@Nullable Value value, Context context) { if (null == value) { return NO_GRAVITY; } return ParseHelper.getGravity(value.getAsString()); }
public static Pair<Integer, Value> parseLayer(ObjectValue layer, Context context) { String id = layer.getAsString(ID_STR); int resId = View.NO_ID; if (id != null) { resId = ParseHelper.getAndroidXmlResId(id); } Value drawable = layer.get(DRAWABLE_STR); Value out = DrawableResourceProcessor.staticCompile(drawable, context); return new Pair<>(resId, out); }
@Override public void handleValue(T view, Value value) { if (!value.isObject()) { return; } int background = Color.TRANSPARENT; int progress = Color.TRANSPARENT; ObjectValue object = value.getAsObject(); String string = object.getAsString("background"); if (string != null) { background = ParseHelper.parseColor(string); } string = object.getAsString("progress"); if (string != null) { progress = ParseHelper.parseColor(string); } view.setProgressDrawable(getLayerDrawable(progress, background)); }
@Override public void setString(V view, String value) { if (view instanceof ProteusView) { int id = ((ProteusView) view).getViewManager().getContext().getInflater().getUniqueViewId(value); ParseHelper.addRelativeLayoutRule(view, rule, id); } } };
@Override public Value compile(@Nullable Value value, Context context) { return ParseHelper.parseBoolean(value) ? ProteusConstants.TRUE : ProteusConstants.FALSE; } }
private static Interpolator handleStringInterpolator(Context c, String value) { Interpolator interpolator = null; if (ParseHelper.isTweenAnimationResource(value)) { try { Resources r = c.getResources(); int interpolatorID = r.getIdentifier(value, "anim", c.getPackageName()); interpolator = android.view.animation.AnimationUtils.loadInterpolator(c, interpolatorID); } catch (Exception ex) { System.out.println("Could not load local resource " + value); } } return interpolator; }
@Override public void setString(T view, String value) { view.setRating(ParseHelper.parseFloat(value)); } });
@Override public void setString(T view, String value) { view.setNumStars(ParseHelper.parseInt(value)); } });
@NonNull @Override public Value call(Context context, Value data, int dataIndex, Value... arguments) throws Exception { Value i = arguments[0]; Value t = arguments[1]; Value e = arguments[2]; return ParseHelper.parseBoolean(i) ? t : e; }
@SuppressLint("NewApi") @Override public void setString(T view, String value) { view.setWeightSum(ParseHelper.parseFloat(value)); } });
@Override public void setString(T view, String value) { view.setAspectRatioWidth(ParseHelper.parseInt(value)); } });
@NonNull @Override public Value call(Context context, Value data, int dataIndex, Value... arguments) throws Exception { if (arguments.length < 1) { return ProteusConstants.FALSE; } boolean bool = true; for (Value argument : arguments) { bool = ParseHelper.parseBoolean(argument); if (!bool) { break; } } return bool ? ProteusConstants.TRUE : ProteusConstants.FALSE; }
@Override public void setString(T view, String value) { view.setStepSize(ParseHelper.parseFloat(value)); } });