com.facebook.litho.annotations.ShouldUpdate Java Examples

The following examples show how to use com.facebook.litho.annotations.ShouldUpdate. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PureRenderValidation.java    From litho with Apache License 2.0 6 votes vote down vote up
static <S extends SpecModel & HasPureRender> List<SpecModelValidationError> validate(
    S specModel) {
  List<SpecModelValidationError> validationErrors = new ArrayList<>();
  final SpecMethodModel<DelegateMethod, Void> shouldUpdateMethod =
      SpecModelUtils.getMethodModelWithAnnotation(specModel, ShouldUpdate.class);

  if (shouldUpdateMethod != null) {
    if (!specModel.isPureRender()) {
      validationErrors.add(
          new SpecModelValidationError(
              shouldUpdateMethod.representedObject,
              "Specs defining a method annotated with @ShouldUpdate should also set "
                  + "isPureRender = true in the top-level spec annotation."));
    }
  }

  return validationErrors;
}
 
Example #2
Source File: MountSpecGenerator.java    From litho with Apache License 2.0 6 votes vote down vote up
public static TypeSpecDataHolder generateCallsShouldUpdateOnMount(MountSpecModel specModel) {
  final TypeSpecDataHolder.Builder dataHolder = TypeSpecDataHolder.newBuilder();

  final ShouldUpdate shouldUpdateAnnotation = getShouldUpdateAnnotation(specModel);

  if (shouldUpdateAnnotation != null && shouldUpdateAnnotation.onMount()) {
    dataHolder.addMethod(
        MethodSpec.methodBuilder("callsShouldUpdateOnMount")
            .addAnnotation(Override.class)
            .addModifiers(Modifier.PUBLIC)
            .returns(TypeName.BOOLEAN)
            .addStatement("return true")
            .build());
  }

  return dataHolder.build();
}
 
Example #3
Source File: MethodParamModelFactoryTest.java    From litho with Apache License 2.0 6 votes vote down vote up
@Test
public void testDontCreateDiffForShouldUpdate() {
  final List<Annotation> annotations = new ArrayList<>();
  Annotation annotation =
      new Annotation() {
        @Override
        public Class<? extends Annotation> annotationType() {
          return ShouldUpdate.class;
        }
      };
  annotations.add(annotation);

  MethodParamModel methodParamModel =
      MethodParamModelFactory.create(
          mDiffTypeSpecWrappingInt,
          "testParam",
          annotations,
          new ArrayList<AnnotationSpec>(),
          ImmutableList.<Class<? extends Annotation>>of(),
          false,
          null);

  assertThat(methodParamModel).isNotInstanceOf(RenderDataDiffModel.class);
}
 
Example #4
Source File: PureRenderValidationTest.java    From litho with Apache License 2.0 6 votes vote down vote up
@Before
public void setup() {
  SpecMethodModel<DelegateMethod, Void> delegateMethod =
      SpecMethodModel.<DelegateMethod, Void>builder()
          .annotations(
              ImmutableList.<Annotation>of(
                  new Annotation() {
                    @Override
                    public Class<? extends Annotation> annotationType() {
                      return ShouldUpdate.class;
                    }
                  }))
          .modifiers(ImmutableList.<Modifier>of())
          .name("method")
          .returnTypeSpec(new TypeSpec(TypeName.BOOLEAN))
          .typeVariables(ImmutableList.of())
          .methodParams(ImmutableList.<MethodParamModel>of())
          .representedObject(mDelegateMethodRepresentedObject1)
          .build();
  when(mSpecModel.getDelegateMethods()).thenReturn(ImmutableList.of(delegateMethod));
}
 
Example #5
Source File: GroupSectionSpecModelFactory.java    From litho with Apache License 2.0 5 votes vote down vote up
public GroupSectionSpecModel createModel(
    Elements elements,
    Types types,
    TypeElement element,
    Messager messager,
    @Nullable DependencyInjectionHelper dependencyInjectionHelper,
    EnumSet<RunMode> runMode) {
  return new GroupSectionSpecModel(
      element.getQualifiedName().toString(),
      element.getAnnotation(GroupSectionSpec.class).value(),
      DelegateMethodExtractor.getDelegateMethods(
          element,
          DELEGATE_METHOD_ANNOTATIONS,
          INTER_STAGE_INPUT_ANNOTATIONS,
          ImmutableList.<Class<? extends Annotation>>of(ShouldUpdate.class),
          messager),
      EventMethodExtractor.getOnEventMethods(
          elements, element, INTER_STAGE_INPUT_ANNOTATIONS, messager, runMode),
      TriggerMethodExtractor.getOnTriggerMethods(
          elements, element, INTER_STAGE_INPUT_ANNOTATIONS, messager, runMode),
      UpdateStateMethodExtractor.getOnUpdateStateMethods(
          element, INTER_STAGE_INPUT_ANNOTATIONS, messager),
      ImmutableList.copyOf(TypeVariablesExtractor.getTypeVariables(element)),
      ImmutableList.copyOf(PropDefaultsExtractor.getPropDefaults(element)),
      EventDeclarationsExtractor.getEventDeclarations(
          elements, element, GroupSectionSpec.class, runMode),
      AnnotationExtractor.extractValidAnnotations(element),
      ImmutableList.of(BuilderMethodModel.KEY_BUILDER_METHOD, LOADING_EVENT_BUILDER_METHOD),
      TagExtractor.extractTagsFromSpecClass(types, element, runMode),
      JavadocExtractor.getClassJavadoc(elements, element),
      JavadocExtractor.getPropJavadocs(elements, element),
      element.getAnnotation(GroupSectionSpec.class).isPublic(),
      SpecElementTypeDeterminator.determine(element),
      dependencyInjectionHelper,
      element,
      mSpecGenerator,
      FieldsExtractor.extractFields(element));
}
 
Example #6
Source File: FrescoVitoImage2Spec.java    From fresco with MIT License 5 votes vote down vote up
@ShouldUpdate(onMount = true)
static boolean shouldUpdate(
    @Prop(optional = true) Diff<Uri> uri,
    @Prop(optional = true) Diff<ImageSource> imageSource,
    @Prop(optional = true) Diff<ImageOptions> imageOptions,
    @Prop(optional = true, resType = ResType.FLOAT) Diff<Float> imageAspectRatio,
    @Prop(optional = true) Diff<ImageListener> imageListener) {
  return !ObjectsCompat.equals(uri.getPrevious(), uri.getNext())
      || !ObjectsCompat.equals(imageSource.getPrevious(), imageSource.getNext())
      || !ObjectsCompat.equals(imageOptions.getPrevious(), imageOptions.getNext())
      || !ObjectsCompat.equals(imageAspectRatio.getPrevious(), imageAspectRatio.getNext())
      || !ObjectsCompat.equals(imageListener.getPrevious(), imageListener.getNext());
}
 
Example #7
Source File: MountSpecGenerator.java    From litho with Apache License 2.0 5 votes vote down vote up
@Nullable
private static ShouldUpdate getShouldUpdateAnnotation(MountSpecModel specModel) {
  for (SpecMethodModel<DelegateMethod, Void> delegateMethodModel :
      specModel.getDelegateMethods()) {
    for (Annotation annotation : delegateMethodModel.annotations) {
      if (annotation.annotationType().equals(ShouldUpdate.class)) {
        return (ShouldUpdate) annotation;
      }
    }
  }

  return null;
}
 
Example #8
Source File: VerticalScrollSpec.java    From litho with Apache License 2.0 5 votes vote down vote up
@ShouldUpdate(onMount = true)
static boolean shouldUpdate(
    @Prop Diff<Component> childComponent,
    @Prop(optional = true) Diff<Boolean> scrollbarEnabled,
    @Prop(optional = true) Diff<Boolean> scrollbarFadingEnabled,
    @Prop(optional = true) Diff<Boolean> fillViewport,
    @Prop(optional = true) Diff<Boolean> nestedScrollingEnabled,
    @Prop(optional = true) Diff<Boolean> incrementalMountEnabled) {
  return !childComponent.getPrevious().isEquivalentTo(childComponent.getNext())
      || !scrollbarEnabled.getPrevious().equals(scrollbarEnabled.getNext())
      || !scrollbarFadingEnabled.getPrevious().equals(scrollbarFadingEnabled.getNext())
      || !fillViewport.getPrevious().equals(fillViewport.getNext())
      || !nestedScrollingEnabled.getPrevious().equals(nestedScrollingEnabled.getNext())
      || !incrementalMountEnabled.getPrevious().equals(incrementalMountEnabled.getNext());
}
 
Example #9
Source File: ImageSpec.java    From litho with Apache License 2.0 5 votes vote down vote up
@ShouldUpdate(onMount = true)
static boolean shouldUpdate(
    @Prop(optional = true) Diff<ScaleType> scaleType,
    @Prop(resType = ResType.DRAWABLE) Diff<Drawable> drawable) {
  return scaleType.getNext() != scaleType.getPrevious()
      || !DrawableUtils.isEquivalentTo(drawable.getNext(), drawable.getPrevious());
}
 
Example #10
Source File: DiffSectionSpecModelFactory.java    From litho with Apache License 2.0 5 votes vote down vote up
public DiffSectionSpecModel createModel(
    Elements elements,
    Types types,
    TypeElement element,
    Messager messager,
    @Nullable DependencyInjectionHelper dependencyInjectionHelper,
    EnumSet<RunMode> runMode) {
  return new DiffSectionSpecModel(
      element.getQualifiedName().toString(),
      element.getAnnotation(DiffSectionSpec.class).value(),
      DelegateMethodExtractor.getDelegateMethods(
          element,
          DELEGATE_METHOD_ANNOTATIONS,
          INTER_STAGE_INPUT_ANNOTATIONS,
          ImmutableList.<Class<? extends Annotation>>of(ShouldUpdate.class, OnDiff.class),
          messager),
      EventMethodExtractor.getOnEventMethods(
          elements, element, INTER_STAGE_INPUT_ANNOTATIONS, messager, runMode),
      AnnotationExtractor.extractValidAnnotations(element),
      TriggerMethodExtractor.getOnTriggerMethods(
          elements, element, INTER_STAGE_INPUT_ANNOTATIONS, messager, runMode),
      UpdateStateMethodExtractor.getOnUpdateStateMethods(
          element, INTER_STAGE_INPUT_ANNOTATIONS, messager),
      ImmutableList.copyOf(TypeVariablesExtractor.getTypeVariables(element)),
      ImmutableList.copyOf(PropDefaultsExtractor.getPropDefaults(element)),
      EventDeclarationsExtractor.getEventDeclarations(
          elements, element, DiffSectionSpec.class, runMode),
      ImmutableList.of(BuilderMethodModel.KEY_BUILDER_METHOD, LOADING_EVENT_BUILDER_METHOD),
      TagExtractor.extractTagsFromSpecClass(types, element, runMode),
      JavadocExtractor.getClassJavadoc(elements, element),
      JavadocExtractor.getPropJavadocs(elements, element),
      element.getAnnotation(DiffSectionSpec.class).isPublic(),
      SpecElementTypeDeterminator.determine(element),
      dependencyInjectionHelper,
      element,
      mSpecGenerator,
      FieldsExtractor.extractFields(element));
}
 
Example #11
Source File: RecordsShouldUpdateSpec.java    From litho with Apache License 2.0 4 votes vote down vote up
@ShouldUpdate(onMount = true)
static boolean shouldUpdate(
    @Prop Diff<Object> testProp, @Prop Diff<List<Diff<Object>>> shouldUpdateCalls) {
  shouldUpdateCalls.getNext().add(testProp);
  return true;
}
 
Example #12
Source File: MountSpecWithShouldUpdateSpec.java    From litho with Apache License 2.0 4 votes vote down vote up
@ShouldUpdate(onMount = true)
static boolean shouldUpdate(@Prop Diff<Object> objectForShouldUpdate) {
  return !objectForShouldUpdate.getPrevious().equals(objectForShouldUpdate.getNext());
}
 
Example #13
Source File: FullDiffSectionSpec.java    From litho with Apache License 2.0 4 votes vote down vote up
@ShouldUpdate
static boolean shouldUpdate(@Prop Diff<Integer> prop1) {
  return true;
}
 
Example #14
Source File: FullGroupSectionSpec.java    From litho with Apache License 2.0 4 votes vote down vote up
@ShouldUpdate
static boolean shouldUpdate(@Prop Diff<Integer> prop1) {
  return true;
}
 
Example #15
Source File: TestMountSpec.java    From litho with Apache License 2.0 4 votes vote down vote up
@ShouldUpdate(onMount = true)
static boolean shouldUpdate(@Prop Diff<Integer> prop1) {
  return true;
}
 
Example #16
Source File: RecyclerSpec.java    From litho with Apache License 2.0 4 votes vote down vote up
@ShouldUpdate(onMount = true)
protected static boolean shouldUpdate(
    @Prop Diff<Binder<RecyclerView>> binder,
    @Prop(optional = true) Diff<Boolean> hasFixedSize,
    @Prop(optional = true) Diff<Boolean> clipToPadding,
    @Prop(optional = true) Diff<Integer> leftPadding,
    @Prop(optional = true) Diff<Integer> rightPadding,
    @Prop(optional = true) Diff<Integer> topPadding,
    @Prop(optional = true) Diff<Integer> bottomPadding,
    @Prop(optional = true, resType = ResType.COLOR)
        Diff<Integer> refreshProgressBarBackgroundColor,
    @Prop(optional = true, resType = ResType.COLOR) Diff<Integer> refreshProgressBarColor,
    @Prop(optional = true) Diff<Boolean> clipChildren,
    @Prop(optional = true) Diff<Integer> scrollBarStyle,
    @Prop(optional = true) Diff<RecyclerView.ItemDecoration> itemDecoration,
    @Prop(optional = true) Diff<Boolean> horizontalFadingEdgeEnabled,
    @Prop(optional = true) Diff<Boolean> verticalFadingEdgeEnabled,
    @Prop(optional = true, resType = ResType.DIMEN_SIZE) Diff<Integer> fadingEdgeLength,
    @Prop(optional = true) Diff<ItemAnimator> itemAnimator,
    @State Diff<Integer> measureVersion) {

  if (measureVersion.getPrevious().intValue() != measureVersion.getNext().intValue()) {
    return true;
  }

  if (binder.getPrevious() != binder.getNext()) {
    return true;
  }

  if (!hasFixedSize.getPrevious().equals(hasFixedSize.getNext())) {
    return true;
  }

  if (!clipToPadding.getPrevious().equals(clipToPadding.getNext())) {
    return true;
  }

  if (!leftPadding.getPrevious().equals(leftPadding.getNext())) {
    return true;
  }

  if (!rightPadding.getPrevious().equals(rightPadding.getNext())) {
    return true;
  }

  if (!topPadding.getPrevious().equals(topPadding.getNext())) {
    return true;
  }

  if (!bottomPadding.getPrevious().equals(bottomPadding.getNext())) {
    return true;
  }

  if (!clipChildren.getPrevious().equals(clipChildren.getNext())) {
    return true;
  }

  if (!scrollBarStyle.getPrevious().equals(scrollBarStyle.getNext())) {
    return true;
  }

  if (!horizontalFadingEdgeEnabled.getPrevious().equals(horizontalFadingEdgeEnabled.getNext())) {
    return true;
  }

  if (!verticalFadingEdgeEnabled.getPrevious().equals(verticalFadingEdgeEnabled.getNext())) {
    return true;
  }

  if (!fadingEdgeLength.getPrevious().equals(fadingEdgeLength.getNext())) {
    return true;
  }

  Integer previousRefreshBgColor = refreshProgressBarBackgroundColor.getPrevious();
  Integer nextRefreshBgColor = refreshProgressBarBackgroundColor.getNext();
  if (previousRefreshBgColor == null
      ? nextRefreshBgColor != null
      : !previousRefreshBgColor.equals(nextRefreshBgColor)) {
    return true;
  }

  if (!refreshProgressBarColor.getPrevious().equals(refreshProgressBarColor.getNext())) {
    return true;
  }

  final ItemAnimator previousItemAnimator = itemAnimator.getPrevious();
  final ItemAnimator nextItemAnimator = itemAnimator.getNext();

  if (previousItemAnimator == null
      ? nextItemAnimator != null
      : !previousItemAnimator.getClass().equals(nextItemAnimator.getClass())) {
    return true;
  }

  final RecyclerView.ItemDecoration previous = itemDecoration.getPrevious();
  final RecyclerView.ItemDecoration next = itemDecoration.getNext();
  final boolean itemDecorationIsEqual =
      (previous == null) ? (next == null) : previous.equals(next);

  return !itemDecorationIsEqual;
}
 
Example #17
Source File: PsiLayoutSpecModelFactory.java    From litho with Apache License 2.0 4 votes vote down vote up
/**
 * @return a new {@link LayoutSpecModel} or null if provided class isn't a {@link LayoutSpec}
 *     class. Access is allowed from event dispatch thread or inside read-action only.
 */
@Nullable
public LayoutSpecModel createWithPsi(
    Project project,
    PsiClass psiClass,
    @Nullable DependencyInjectionHelper dependencyInjectionHelper) {
  LayoutSpec layoutSpecAnnotation =
      PsiAnnotationProxyUtils.findAnnotationInHierarchy(psiClass, LayoutSpec.class);
  if (layoutSpecAnnotation == null) {
    return null;
  }

  // #5 trigger methods
  ImmutableList<SpecMethodModel<EventMethod, EventDeclarationModel>> triggerMethods =
      PsiTriggerMethodExtractor.getOnTriggerMethods(psiClass, INTER_STAGE_INPUT_ANNOTATIONS);

  // #12 classJavadoc
  String classJavadoc = "classJavadoc";

  // #13 JavadocExtractor.getPropJavadocs()
  ImmutableList<PropJavadocModel> propJavadocs = ImmutableList.of();

  return new LayoutSpecModel(
      psiClass.getQualifiedName(),
      layoutSpecAnnotation.value(),
      PsiDelegateMethodExtractor.getDelegateMethods(
          psiClass,
          mLayoutSpecDelegateMethodAnnotations,
          INTER_STAGE_INPUT_ANNOTATIONS,
          ImmutableList.<Class<? extends Annotation>>of(ShouldUpdate.class)),
      PsiEventMethodExtractor.getOnEventMethods(psiClass, INTER_STAGE_INPUT_ANNOTATIONS),
      triggerMethods,
      PsiWorkingRangesMethodExtractor.getRegisterMethod(psiClass, INTER_STAGE_INPUT_ANNOTATIONS),
      PsiWorkingRangesMethodExtractor.getRangesMethods(psiClass, INTER_STAGE_INPUT_ANNOTATIONS),
      PsiUpdateStateMethodExtractor.getOnUpdateStateMethods(
          psiClass, INTER_STAGE_INPUT_ANNOTATIONS, false),
      PsiUpdateStateMethodExtractor.getOnUpdateStateMethods(
          psiClass, INTER_STAGE_INPUT_ANNOTATIONS, true),
      ImmutableList.<String>of(),
      PsiPropDefaultsExtractor.getPropDefaults(psiClass),
      PsiEventDeclarationsExtractor.getEventDeclarations(psiClass),
      PsiAnnotationExtractor.extractValidAnnotations(project, psiClass),
      null,
      classJavadoc,
      propJavadocs,
      layoutSpecAnnotation.isPublic(),
      dependencyInjectionHelper,
      layoutSpecAnnotation.isPureRender(),
      SpecElementType.JAVA_CLASS,
      psiClass,
      mLayoutSpecGenerator,
      PsiTypeVariablesExtractor.getTypeVariables(psiClass),
      PsiFieldsExtractor.extractFields(psiClass),
      null);
}
 
Example #18
Source File: MountSpecModelFactory.java    From litho with Apache License 2.0 4 votes vote down vote up
/**
 * Create a {@link MountSpecModel} from the given {@link TypeElement} and an optional {@link
 * DependencyInjectionHelper}.
 */
@Override
public MountSpecModel create(
    Elements elements,
    Types types,
    TypeElement element,
    Messager messager,
    EnumSet<RunMode> runMode,
    @Nullable DependencyInjectionHelper dependencyInjectionHelper,
    @Nullable InterStageStore interStageStore) {
  return new MountSpecModel(
      element.getQualifiedName().toString(),
      element.getAnnotation(MountSpec.class).value(),
      DelegateMethodExtractor.getDelegateMethods(
          element,
          DELEGATE_METHOD_ANNOTATIONS,
          INTER_STAGE_INPUT_ANNOTATIONS,
          ImmutableList.<Class<? extends Annotation>>of(ShouldUpdate.class),
          messager),
      EventMethodExtractor.getOnEventMethods(
          elements, element, INTER_STAGE_INPUT_ANNOTATIONS, messager, runMode),
      TriggerMethodExtractor.getOnTriggerMethods(
          elements, element, INTER_STAGE_INPUT_ANNOTATIONS, messager, runMode),
      WorkingRangesMethodExtractor.getRegisterMethod(
          element, INTER_STAGE_INPUT_ANNOTATIONS, messager),
      WorkingRangesMethodExtractor.getRangesMethods(
          elements, element, INTER_STAGE_INPUT_ANNOTATIONS, messager),
      UpdateStateMethodExtractor.getOnUpdateStateMethods(
          element, INTER_STAGE_INPUT_ANNOTATIONS, messager),
      interStageStore == null
          ? ImmutableList.of()
          : CachedPropNameExtractor.getCachedPropNames(
              interStageStore, element.getQualifiedName()),
      ImmutableList.copyOf(TypeVariablesExtractor.getTypeVariables(element)),
      ImmutableList.copyOf(PropDefaultsExtractor.getPropDefaults(element)),
      EventDeclarationsExtractor.getEventDeclarations(
          elements, element, MountSpec.class, runMode),
      JavadocExtractor.getClassJavadoc(elements, element),
      AnnotationExtractor.extractValidAnnotations(element),
      TagExtractor.extractTagsFromSpecClass(types, element, runMode),
      JavadocExtractor.getPropJavadocs(elements, element),
      element.getAnnotation(MountSpec.class).isPublic(),
      dependencyInjectionHelper,
      element.getAnnotation(MountSpec.class).isPureRender(),
      element.getAnnotation(MountSpec.class).hasChildLithoViews(),
      element.getAnnotation(MountSpec.class).poolSize(),
      element.getAnnotation(MountSpec.class).canPreallocate(),
      getMountType(elements, element, runMode),
      SpecElementTypeDeterminator.determine(element),
      element,
      mMountSpecGenerator,
      FieldsExtractor.extractFields(element),
      BindDynamicValuesMethodExtractor.getOnBindDynamicValuesMethods(element, messager));
}
 
Example #19
Source File: LayoutSpecModelFactory.java    From litho with Apache License 2.0 4 votes vote down vote up
/**
 * Create a {@link LayoutSpecModel} from the given {@link TypeElement} and an optional {@link
 * DependencyInjectionHelper}.
 */
@Override
public LayoutSpecModel create(
    Elements elements,
    Types types,
    TypeElement element,
    Messager messager,
    EnumSet<RunMode> runMode,
    @Nullable DependencyInjectionHelper dependencyInjectionHelper,
    @Nullable InterStageStore interStageStore) {

  return new LayoutSpecModel(
      element.getQualifiedName().toString(),
      element.getAnnotation(LayoutSpec.class).value(),
      DelegateMethodExtractor.getDelegateMethods(
          element,
          mLayoutSpecDelegateMethodAnnotations,
          INTER_STAGE_INPUT_ANNOTATIONS,
          ImmutableList.<Class<? extends Annotation>>of(ShouldUpdate.class),
          messager),
      EventMethodExtractor.getOnEventMethods(
          elements, element, INTER_STAGE_INPUT_ANNOTATIONS, messager, runMode),
      TriggerMethodExtractor.getOnTriggerMethods(
          elements, element, INTER_STAGE_INPUT_ANNOTATIONS, messager, runMode),
      WorkingRangesMethodExtractor.getRegisterMethod(
          element, INTER_STAGE_INPUT_ANNOTATIONS, messager),
      WorkingRangesMethodExtractor.getRangesMethods(
          elements, element, INTER_STAGE_INPUT_ANNOTATIONS, messager),
      UpdateStateMethodExtractor.getOnUpdateStateMethods(
          element, INTER_STAGE_INPUT_ANNOTATIONS, messager),
      UpdateStateMethodExtractor.getOnUpdateStateWithTransitionMethods(
          element, INTER_STAGE_INPUT_ANNOTATIONS, messager),
      interStageStore == null
          ? ImmutableList.of()
          : CachedPropNameExtractor.getCachedPropNames(
              interStageStore, element.getQualifiedName()),
      ImmutableList.copyOf(PropDefaultsExtractor.getPropDefaults(element)),
      EventDeclarationsExtractor.getEventDeclarations(
          elements, element, LayoutSpec.class, runMode),
      AnnotationExtractor.extractValidAnnotations(element),
      TagExtractor.extractTagsFromSpecClass(types, element, runMode),
      JavadocExtractor.getClassJavadoc(elements, element),
      JavadocExtractor.getPropJavadocs(elements, element),
      element.getAnnotation(LayoutSpec.class).isPublic(),
      dependencyInjectionHelper,
      element.getAnnotation(LayoutSpec.class).isPureRender(),
      SpecElementTypeDeterminator.determine(element),
      element,
      mLayoutSpecGenerator,
      ImmutableList.copyOf(TypeVariablesExtractor.getTypeVariables(element)),
      FieldsExtractor.extractFields(element),
      element.getAnnotation(LayoutSpec.class).simpleNameDelegate());
}
 
Example #20
Source File: PicassoImageSpec.java    From litho-picasso with MIT License 4 votes vote down vote up
@ShouldUpdate(onMount = true)
static boolean shouldUpdate(
        @Prop(optional = true) Diff<String> imageUrl,
        @Prop(optional = true) Diff<File> file,
        @Prop(optional = true) Diff<Uri> uri,
        @Prop(optional = true) Diff<Integer> resourceId,
        @Prop(optional = true, resType = DRAWABLE) Diff<Drawable> errorDrawable,
        @Prop(optional = true, resType = DRAWABLE) Diff<Drawable> placeholderImage,
        @Prop(optional = true) Diff<Boolean> noPlaceholder,
        @Prop(optional = true) Diff<Bitmap.Config> config,
        @Prop(optional = true) Diff<Boolean> fit,
        @Prop(optional = true) Diff<Boolean> centerCrop,
        @Prop(optional = true) Diff<Boolean> centerInside,
        @Prop(optional = true) Diff<Boolean> noFade,
        @Prop(optional = true) Diff<Boolean> onlyScaleDown,
        @Prop(optional = true) Diff<Picasso.Priority> priority,
        @Prop(optional = true) Diff<Integer> resizeTargetWidth,
        @Prop(optional = true) Diff<Integer> resizeTargetHeight,
        @Prop(optional = true, resType = INT) Diff<Integer> resizeTargetWidthResId,
        @Prop(optional = true, resType = INT) Diff<Integer> resizeTargetHeightResId,
        @Prop(optional = true) Diff<Float> rotateDegrees,
        @Prop(optional = true) Diff<Integer> pivotX,
        @Prop(optional = true) Diff<Integer> pivotY,
        @Prop(optional = true) Diff<String> stableKey,
        @Prop(optional = true) Diff<Object> tag,
        @Prop(optional = true) Diff<Transformation> transformation,
        @Prop(optional = true) Diff<List<? extends Transformation>> transformations
) {
  return imageUrl.getNext() != imageUrl.getPrevious() ||
          file.getNext() != file.getPrevious() ||
          uri.getNext() != uri.getPrevious() ||
          resourceId.getNext() != resourceId.getPrevious() ||
          errorDrawable.getNext() != errorDrawable.getPrevious() ||
          placeholderImage.getNext() != placeholderImage.getPrevious() ||
          noPlaceholder.getNext() != noPlaceholder.getPrevious() ||
          config.getNext() != config.getPrevious() ||
          fit.getNext() != fit.getPrevious() ||
          centerCrop.getNext() != centerCrop.getPrevious() ||
          centerInside.getNext() != centerInside.getPrevious() ||
          noFade.getNext() != noFade.getPrevious() ||
          onlyScaleDown.getNext() != onlyScaleDown.getPrevious() ||
          priority.getNext() != priority.getPrevious() ||
          resizeTargetWidth.getNext() != resizeTargetWidth.getPrevious() ||
          resizeTargetHeight.getNext() != resizeTargetHeight.getPrevious() ||
          resizeTargetWidthResId.getNext() != resizeTargetWidthResId.getPrevious() ||
          resizeTargetHeightResId.getNext() != resizeTargetHeightResId.getPrevious() ||
          rotateDegrees.getNext() != rotateDegrees.getPrevious() ||
          pivotX.getNext() != pivotX.getPrevious() ||
          pivotY.getNext() != pivotY.getPrevious() ||
          stableKey.getNext() != stableKey.getPrevious() ||
          tag.getNext() != tag.getPrevious() ||
          transformation.getNext() != transformation.getPrevious() ||
          transformations.getNext() != transformations.getPrevious();
}