static class Target { @BindDrawable(R.drawable.circle) Drawable actual; }
private void parseResourceDrawable(Element element, Map<TypeElement, BindingSet.Builder> builderMap, Set<TypeElement> erasedTargetNames) { boolean hasError = false; TypeElement enclosingElement = (TypeElement) element.getEnclosingElement(); // Verify that the target type is Drawable. if (!DRAWABLE_TYPE.equals(element.asType().toString())) { error(element, "@%s field type must be 'Drawable'. (%s.%s)", BindDrawable.class.getSimpleName(), enclosingElement.getQualifiedName(), element.getSimpleName()); hasError = true; } // Verify common generated code restrictions. hasError |= isInaccessibleViaGeneratedCode(BindDrawable.class, "fields", element); hasError |= isBindingInWrongPackage(BindDrawable.class, element); if (hasError) { return; } // Assemble information on the field. String name = element.getSimpleName().toString(); int id = element.getAnnotation(BindDrawable.class).value(); int tint = element.getAnnotation(BindDrawable.class).tint(); Map<Integer, Id> resourceIds = elementToIds(element, BindDrawable.class, new int[] {id, tint}); BindingSet.Builder builder = getOrCreateBindingBuilder(builderMap, enclosingElement); builder.addResource(new FieldDrawableBinding(resourceIds.get(id), name, resourceIds.get(tint))); erasedTargetNames.add(enclosingElement); }
private int mState = STATE_HIDDEN; @BindDrawable(R.drawable.fastscroll_thumb_pressed) Drawable mThumbDrawableDragging; @BindDrawable(R.drawable.fastscroll_thumb_default) Drawable mThumbDrawableNormal;
private static @Nullable Unbinder parseBindDrawable(Object target, Field field, View source) { BindDrawable bindDrawable = field.getAnnotation(BindDrawable.class); if (bindDrawable == null) { return null; } validateMember(field); int id = bindDrawable.value(); int tint = bindDrawable.tint(); Context context = source.getContext(); Class<?> fieldType = field.getType(); Object value; if (fieldType == Drawable.class) { value = tint != Constants.NO_RES_ID ? Utils.getTintedDrawable(context, id, tint) : ContextCompat.getDrawable(context, id); } else { throw new IllegalStateException(); // TODO } trySet(field, target, value); return Unbinder.EMPTY; }
@BindDrawable(android.R.drawable.ic_media_pause) protected Drawable pauseIcon; @BindDrawable(android.R.drawable.ic_media_play) protected Drawable playIcon;
private void parseResourceDrawable(Element element, Map<TypeElement, BindingSet.Builder> builderMap, Set<TypeElement> erasedTargetNames) { boolean hasError = false; TypeElement enclosingElement = (TypeElement) element.getEnclosingElement(); // Verify that the target type is Drawable. if (!DRAWABLE_TYPE.equals(element.asType().toString())) { error(element, "@%s field type must be 'Drawable'. (%s.%s)", BindDrawable.class.getSimpleName(), enclosingElement.getQualifiedName(), element.getSimpleName()); hasError = true; } // Verify common generated code restrictions. hasError |= isInaccessibleViaGeneratedCode(BindDrawable.class, "fields", element); hasError |= isBindingInWrongPackage(BindDrawable.class, element); if (hasError) { return; } // Assemble information on the field. String name = element.getSimpleName().toString(); int id = element.getAnnotation(BindDrawable.class).value(); int tint = element.getAnnotation(BindDrawable.class).tint(); Map<Integer, Id> resourceIds = elementToIds(element, BindDrawable.class, new int[] {id, tint}); BindingSet.Builder builder = getOrCreateBindingBuilder(builderMap, enclosingElement); builder.addResource(new FieldDrawableBinding(resourceIds.get(id), name, resourceIds.get(tint))); erasedTargetNames.add(enclosingElement); }
@Bind(R.id.flowlayout_tags) FlowLayout mFlowLayout; @BindDrawable(R.drawable.ic_warning_grey_500_24dp) Drawable mIcWarning;
@BindBool(R.bool.anim_backdrop_animate_alpha) boolean mAnimBackdropAnimateAlpha; @BindDrawable(R.drawable.star_outline) Drawable mStarOutline; @BindDrawable(R.drawable.star) Drawable mStarFilled;
@BindString(R.string.perm_not_granted) String permNotGranted; @BindDrawable(R.drawable.ic_3d_quality) Drawable quality3Drawable; @BindDrawable(R.drawable.ic_720p_quality) Drawable quality720pDrawable; @BindDrawable(R.drawable.ic_1080p_quality) Drawable quality1080pDrawable;
@BindString(R.string.generic_error) String mStringGenericError; @BindDrawable(R.drawable.ic_error_grey_500_24dp) Drawable mIcError;
@BindString(R.string.showcase_got_it) String mStringShowCaseGotIt; @BindDrawable(R.drawable.ic_person_white_24dp) Drawable mIcPersonWhite; @BindDrawable(R.drawable.ic_person_teal_900_24dp) Drawable mIcPersonDark; @BindDrawable(R.drawable.ic_public_white_24dp) Drawable mIcPublicWhite; @BindDrawable(R.drawable.ic_public_teal_900_24dp) Drawable mIcPublicDark;