@Override public void handleValue(final V view, Value value) { if (value.isColor()) { apply(view, value.getAsColor()); } else { process(view, precompile(value, view.getContext(), ((ProteusContext) view.getContext()).getFunctionManager())); } }
@Override public void handleValue(V view, Value value) { if (value.isPrimitive() && value.getAsPrimitive().isNumber()) { // noinspection ResourceType view.setVisibility(value.getAsInt()); } else { process(view, precompile(value, view.getContext(), ((ProteusContext) view.getContext()).getFunctionManager())); } }
@Override public final void handleValue(T view, Value value) { if (value.isDimension()) { setDimension(view, value.getAsDimension().apply(view.getContext())); } else if (value.isPrimitive()) { process(view, precompile(value, view.getContext(), ((ProteusContext) view.getContext()).getFunctionManager())); } }
@Override public void handleValue(V view, Value value) { if (value.isPrimitive() && value.getAsPrimitive().isBoolean()) { setBoolean(view, value.getAsPrimitive().getAsBoolean()); } else { process(view, precompile(value, view.getContext(), ((ProteusContext) view.getContext()).getFunctionManager())); } }
@Override public void handleValue(final V view, Value value) { if (value.isDrawable()) { DrawableValue d = value.getAsDrawable(); if (null != d) { ProteusLayoutInflater.ImageLoader loader = ((ProteusView) view).getViewManager().getContext().getLoader(); d.apply((ProteusView) view, view.getContext(), loader, new DrawableValue.Callback() { @Override public void apply(Drawable drawable) { if (null != drawable) { setDrawable(view, drawable); } } }); } } else { process(view, precompile(value, view.getContext(), ((ProteusContext) view.getContext()).getFunctionManager())); } }
@Test public void to_string_2() throws Exception { ProteusContext context = context(); String string = "@{fn:add('1','1')}"; Binding binding = Binding.valueOf(string, context, context.getFunctionManager()); assertThat(binding.toString(), is(string)); }
@Test public void evaluate_function() throws Exception { ProteusContext context = context(); Binding binding = Binding.valueOf("@{fn:add(1,1)}", context, context.getFunctionManager()); Value value = binding.evaluate(null, data(), 0); assertThat(value.getAsString(), is("2.0")); }