static class Target { @BindInt(R.integer.twelve) int actual; }
private static @Nullable Unbinder parseBindInt(Object target, Field field, View source) { BindInt bindInt = field.getAnnotation(BindInt.class); if (bindInt == null) { return null; } validateMember(field); int id = bindInt.value(); Resources resources = source.getContext().getResources(); Class<?> fieldType = field.getType(); Object value; if (fieldType == int.class) { value = resources.getInteger(id); } else { throw new IllegalStateException(); // TODO } trySet(field, target, value); return Unbinder.EMPTY; }
public class MainActivity extends AppCompatActivity { @BindInt(android.R.integer.config_mediumAnimTime) int mToolbarHideDuration;
private void parseResourceInt(Element element, Map<TypeElement, BindingSet.Builder> builderMap, Set<TypeElement> erasedTargetNames) { boolean hasError = false; TypeElement enclosingElement = (TypeElement) element.getEnclosingElement(); // Verify that the target type is int. if (element.asType().getKind() != TypeKind.INT) { error(element, "@%s field type must be 'int'. (%s.%s)", BindInt.class.getSimpleName(), enclosingElement.getQualifiedName(), element.getSimpleName()); hasError = true; } // Verify common generated code restrictions. hasError |= isInaccessibleViaGeneratedCode(BindInt.class, "fields", element); hasError |= isBindingInWrongPackage(BindInt.class, element); if (hasError) { return; } // Assemble information on the field. String name = element.getSimpleName().toString(); int id = element.getAnnotation(BindInt.class).value(); Id resourceId = elementToId(element, BindInt.class, id); BindingSet.Builder builder = getOrCreateBindingBuilder(builderMap, enclosingElement); builder.addResource( new FieldResourceBinding(resourceId, name, FieldResourceBinding.Type.INT)); erasedTargetNames.add(enclosingElement); }
private void parseResourceInt(Element element, Map<TypeElement, BindingSet.Builder> builderMap, Set<TypeElement> erasedTargetNames) { boolean hasError = false; TypeElement enclosingElement = (TypeElement) element.getEnclosingElement(); // Verify that the target type is int. if (element.asType().getKind() != TypeKind.INT) { error(element, "@%s field type must be 'int'. (%s.%s)", BindInt.class.getSimpleName(), enclosingElement.getQualifiedName(), element.getSimpleName()); hasError = true; } // Verify common generated code restrictions. hasError |= isInaccessibleViaGeneratedCode(BindInt.class, "fields", element); hasError |= isBindingInWrongPackage(BindInt.class, element); if (hasError) { return; } // Assemble information on the field. String name = element.getSimpleName().toString(); int id = element.getAnnotation(BindInt.class).value(); Id resourceId = elementToId(element, BindInt.class, id); BindingSet.Builder builder = getOrCreateBindingBuilder(builderMap, enclosingElement); builder.addResource( new FieldResourceBinding(resourceId, name, FieldResourceBinding.Type.INT)); erasedTargetNames.add(enclosingElement); }
@Bind(R.id.favorite) FloatingActionButton mFavoriteBtn; @BindInt(R.integer.anim_short_duration) int mAnimShortDuration; @BindInt(R.integer.anim_stagger_delay) int mAnimStaggerDelay; @BindInt(R.integer.anim_activity_start_delay) int mAnimActivityStartDelay; @BindBool(R.bool.anim_backdrop_animate_alpha) boolean mAnimBackdropAnimateAlpha;
protected Drawable playIcon; @BindInt(R.integer.activity_channel_detail_play_stream_delay_millis) protected int playStreamDelayMillis;
@BindInt(R.integer.columns) int columns; @BindColor(R.color.amber) int amber; @BindColor(R.color.green) int green;