From ef42810d10432042a2333cb4a8cd50bb9a899c57 Mon Sep 17 00:00:00 2001 From: Emmanuel Boudrant Date: Thu, 27 Sep 2018 14:55:42 -0700 Subject: [PATCH 01/38] Implements visibility events for EpoxyRecyclerView/EpoxyViewHolder. --- .../java/com/airbnb/epoxy/EpoxyModel.java | 19 ++ .../airbnb/epoxy/EpoxyModelWithHolder.java | 32 ++++ .../com/airbnb/epoxy/EpoxyRecyclerView.java | 39 ++++ .../com/airbnb/epoxy/EpoxyViewHolder.java | 36 ++++ .../com/airbnb/epoxy/EpoxyVisibilityItem.java | 169 ++++++++++++++++++ .../airbnb/epoxy/EpoxyVisibilityTracker.java | 164 +++++++++++++++++ .../com/airbnb/epoxy/OnVisibilityEvent.java | 63 +++++++ .../com/airbnb/epoxy/GeneratedModelWriter.kt | 97 ++++++++++ .../java/com/airbnb/epoxy/ModelViewInfo.kt | 16 +- .../com/airbnb/epoxy/ModelViewProcessor.kt | 66 ++++++- .../java/com/airbnb/epoxy/ModelViewWriter.kt | 39 +++- .../kotlinsample/models/ItemCustomView.kt | 31 ++++ 12 files changed, 763 insertions(+), 8 deletions(-) create mode 100644 epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java create mode 100644 epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityTracker.java create mode 100644 epoxy-annotations/src/main/java/com/airbnb/epoxy/OnVisibilityEvent.java diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModel.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModel.java index 22dd96c833..7a1c7bc64d 100755 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModel.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModel.java @@ -155,6 +155,25 @@ public void bind(@NonNull T view, @NonNull EpoxyModel previouslyBoundModel) { public void unbind(@NonNull T view) { } + public void visibilityVisible(@NonNull T view) { + } + + public void visibilityFocusedVisible(@NonNull T view) { + } + + public void visibilityInvisible(@NonNull T view) { + } + + public void visibilityUnfocusedVisible(@NonNull T view) { + } + + public void visibilityFullImpressionVisible(@NonNull T view) { + } + + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, @NonNull T view) { + } + public long id() { return id; } diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModelWithHolder.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModelWithHolder.java index 2dd219b727..0a612f400b 100644 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModelWithHolder.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModelWithHolder.java @@ -40,6 +40,38 @@ public void unbind(@NonNull T holder) { super.unbind(holder); } + @Override + public void visibilityFocusedVisible(@NonNull T view) { + super.visibilityFocusedVisible(view); + } + + @Override + public void visibilityFullImpressionVisible(@NonNull T view) { + super.visibilityFullImpressionVisible(view); + } + + @Override + public void visibilityInvisible(@NonNull T view) { + super.visibilityInvisible(view); + } + + @Override + public void visibilityUnfocusedVisible(@NonNull T view) { + super.visibilityUnfocusedVisible(view); + } + + @Override + public void visibilityVisible(@NonNull T view) { + super.visibilityVisible(view); + } + + @Override + public void visibilityChanged(float visibleHeight, float visibleWidth, int percentVisibleHeight, + int percentVisibleWidth, @NonNull T view) { + super.visibilityChanged(visibleHeight, visibleWidth, percentVisibleHeight, percentVisibleWidth, + view); + } + @Override public boolean onFailedToRecycleView(T holder) { return super.onFailedToRecycleView(holder); diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyRecyclerView.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyRecyclerView.java index 215946354e..721d836748 100644 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyRecyclerView.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyRecyclerView.java @@ -78,6 +78,11 @@ public class EpoxyRecyclerView extends RecyclerView { private EpoxyController epoxyController; + private boolean visibilityTrackingEnabled = false; + + @NonNull + private EpoxyVisibilityTracker epoxyVisibilityTracker = new EpoxyVisibilityTracker(); + /** * The adapter that was removed because the RecyclerView was detached from the window. We save it * so we can reattach it if the RecyclerView is reattached to window. This allows us to @@ -230,6 +235,40 @@ protected RecycledViewPool createViewPool() { return new UnboundedViewPool(); } + /** + * Enable visibility event tracking : + *

+ * - Visible Event: this event is triggered when at least one pixel of the Component is visible. + *

+ * - Invisible Event: this event is triggered when the Component no longer has any pixels on the + * screen. + *

+ * - Focused Visible Event: this event is triggered when either the Component occupies at least + * half of the viewport, or, if the Component is smaller than half the viewport, when it is fully + * visible. + *

+ * - Unfocused Visible Event: this event is triggered when the Component is no longer focused, i.e. + * it is not fully visible and does not occupy at least half the viewport. + *

+ * - Full Impression Visible Event: this event is triggered when the entire Component has passed + * through the viewport at some point. + *

+ * - VisibilityChangedEvent: this event is triggered when the visibility of the Component on the + * screen changes. + * + * By default visibility event tracking is not enabled. + */ + public void setVisibilityTrackingEnabled(boolean enabled) { + if (visibilityTrackingEnabled != enabled) { + visibilityTrackingEnabled = enabled; + if (visibilityTrackingEnabled) { + epoxyVisibilityTracker.attach(this); + } else { + epoxyVisibilityTracker.detach(this); + } + } + } + /** * To maximize view recycling by default we share the same view pool across all {@link * EpoxyRecyclerView} instances in the same Activity. This behavior can be disabled by returning diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyViewHolder.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyViewHolder.java index 6c0a7c8226..ac38a77d1d 100755 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyViewHolder.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyViewHolder.java @@ -82,6 +82,42 @@ public void unbind() { payloads = null; } + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth) { + assertBound(); + // noinspection unchecked + epoxyModel.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, objectToBind()); + } + + public void visibilityVisible() { + assertBound(); + // noinspection unchecked + epoxyModel.visibilityVisible(objectToBind()); + } + + public void visibilityFocusedVisible() { + assertBound(); + // noinspection unchecked + epoxyModel.visibilityFocusedVisible(objectToBind()); + } + + public void visibilityInvisible() { + assertBound(); + // noinspection unchecked + epoxyModel.visibilityInvisible(objectToBind()); + } + + public void visibilityUnfocusedVisible() { + assertBound(); + // noinspection unchecked + epoxyModel.visibilityUnfocusedVisible(objectToBind()); + } + + public void visibilityFullImpressionVisible() { + assertBound(); + // noinspection unchecked + epoxyModel.visibilityFullImpressionVisible(objectToBind()); + } + public List getPayloads() { assertBound(); return payloads; diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java new file mode 100644 index 0000000000..179cca1e24 --- /dev/null +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java @@ -0,0 +1,169 @@ +package com.airbnb.epoxy; + +import android.graphics.Rect; +import android.support.annotation.NonNull; +import android.support.annotation.Px; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.view.View; + +class EpoxyVisibilityItem { + + private final Rect localVisibleRect = new Rect(); + + private int adapterPosition = RecyclerView.NO_POSITION; + + @Px + int size; + + private int otherSize; + + private boolean vertical; + + private float percentVisibleSize = 0.f; + + private int visibleSize; + + private int viewportSize; + + private boolean fullyVisible = false; + private boolean visible = false; + private boolean focusedVisible = false; + + /** + * Update the visibility item according the current layout. + * + * @param view the current {@link com.airbnb.epoxy.EpoxyViewHolder}'s itemView + * @param parent the {@link android.support.v7.widget.RecyclerView} + * @param orientation the {@link android.support.v7.widget.LinearLayoutManager}'s orientation + * + * @return true if the view has been measured + */ + boolean update(@NonNull View view, @NonNull RecyclerView parent, int orientation) { + view.getLocalVisibleRect(localVisibleRect); + vertical = orientation == LinearLayoutManager.VERTICAL; + if (vertical) { + size = view.getMeasuredHeight(); + otherSize = view.getMeasuredWidth(); + viewportSize = parent.getMeasuredHeight(); + visibleSize = localVisibleRect.height(); + } else { + otherSize = view.getMeasuredHeight(); + size = view.getMeasuredWidth(); + viewportSize = parent.getMeasuredWidth(); + visibleSize = localVisibleRect.width(); + } + percentVisibleSize = 100.f / size * visibleSize; + if (visibleSize != size) { + fullyVisible = false; + } + return size > 0; + } + + void reset(int newAdapterPosition) { + fullyVisible = false; + visible = false; + focusedVisible = false; + adapterPosition = newAdapterPosition; + } + + void handleVisible(@NonNull EpoxyViewHolder epoxyHolder) { + if (!wasVisible() && isVisible()) { + epoxyHolder.visibilityVisible(); + } + } + + void handleInvisible(EpoxyViewHolder epoxyHolder, boolean detachEvent) { + if (!wasInvisible() && isInvisible(detachEvent)) { + epoxyHolder.visibilityInvisible(); + } + } + + void handleFocusedVisible(EpoxyViewHolder epoxyHolder) { + if (!wasFocusedVisible() && isFocusedVisible()) { + epoxyHolder.visibilityFocusedVisible(); + } + } + + void handleUnfocusedVisible(EpoxyViewHolder epoxyHolder) { + if (!wasUnfocusedVisible() && isUnfocusedVisible()) { + epoxyHolder.visibilityUnfocusedVisible(); + } + } + + void handleFullImpressionVisible(EpoxyViewHolder epoxyHolder) { + if (!wasFullImpressionVisible() && isFullImpressionVisible()) { + epoxyHolder.visibilityFullImpressionVisible(); + } + } + + void handleChanged(EpoxyViewHolder epoxyHolder) { + if (vertical) { + epoxyHolder.visibilityChanged(percentVisibleSize, 100.f, size, otherSize); + } else { + epoxyHolder.visibilityChanged(100.f, percentVisibleSize, otherSize, size); + } + } + + int getAdapterPosition() { + return adapterPosition; + } + + private boolean isVisible() { + // true when at least one pixel of the Component is visible + return visible = visibleSize > 0; + } + + private boolean wasVisible() { + return visible; + } + + private boolean isInvisible(boolean detachEvent) { + // true when when the Component no longer has any pixels on the screen + boolean invisible = visibleSize <= 0 || detachEvent; + if (invisible) { + visible = false; + } + return !visible; + } + + private boolean wasInvisible() { + return !visible; + } + + private boolean isFocusedVisible() { + // true when either the Component occupies at least half of the viewport, or, if the Component + // is smaller than half the viewport, when it is fully visible. + return focusedVisible = + size >= viewportSize / 2 || (visibleSize == size && size < viewportSize / 2); + } + + private boolean wasFocusedVisible() { + return focusedVisible; + } + + private boolean isUnfocusedVisible() { + // true when the Component is no longer focused, i.e. it is not fully visible and does not + // occupy at least half the viewport. + boolean unfocusedVisible = + !(size >= viewportSize / 2 || (visibleSize == size && size < viewportSize / 2)); + if (unfocusedVisible) { + focusedVisible = false; + } + return !focusedVisible; + } + + private boolean wasUnfocusedVisible() { + return !focusedVisible; + } + + private boolean wasFullImpressionVisible() { + return fullyVisible; + } + + private boolean isFullImpressionVisible() { + // true when the entire Component has passed through the viewport at some point. + return fullyVisible = visibleSize == size; + } +} + diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityTracker.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityTracker.java new file mode 100644 index 0000000000..43694321bd --- /dev/null +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityTracker.java @@ -0,0 +1,164 @@ +package com.airbnb.epoxy; + +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.support.v7.widget.RecyclerView.LayoutManager; +import android.support.v7.widget.RecyclerView.OnChildAttachStateChangeListener; +import android.support.v7.widget.RecyclerView.OnScrollListener; +import android.support.v7.widget.RecyclerView.ViewHolder; +import android.util.SparseArray; +import android.view.View; +import android.view.View.OnLayoutChangeListener; + +/** + * Helper class to handle visibility event from an {@link com.airbnb.epoxy.EpoxyRecyclerView}. + */ +class EpoxyVisibilityTracker { + + /** Maintain visibility item indexed by view id (identity hashcode) */ + private final SparseArray visibilityIdToItemMap = new SparseArray<>(); + + /** listener used to process scroll, layout and attach events */ + private final Listener listener = new Listener(); + + @Nullable + private RecyclerView attachedRecyclerView = null; + + @Nullable + private LinearLayoutManager attachedLinearLayoutManager = null; + + /** + * Attach the tracker. + * + * @param recyclerView The EpoxyRecyclerView. + */ + void attach(@NonNull EpoxyRecyclerView recyclerView) { + attachedRecyclerView = recyclerView; + recyclerView.addOnScrollListener(this.listener); + recyclerView.addOnLayoutChangeListener(this.listener); + recyclerView.addOnChildAttachStateChangeListener(this.listener); + } + + /** + * Detach the tracker + * + * @param recyclerView The EpoxyRecyclerView. + */ + void detach(@NonNull EpoxyRecyclerView recyclerView) { + recyclerView.removeOnScrollListener(this.listener); + recyclerView.removeOnLayoutChangeListener(this.listener); + recyclerView.removeOnChildAttachStateChangeListener(this.listener); + attachedRecyclerView = null; + attachedLinearLayoutManager = null; + } + + @Nullable + private LinearLayoutManager getLinearLayoutManager() { + if (attachedLinearLayoutManager == null && attachedRecyclerView != null) { + final LayoutManager lm = attachedRecyclerView.getLayoutManager(); + if (lm instanceof LinearLayoutManager) { + attachedLinearLayoutManager = (LinearLayoutManager) lm; + } else { + throw new IllegalStateException("setVisibilityTrackingEnabled(true) require to have a " + + "LinearLayoutManager, found " + lm.getClass().getName() + "."); + } + } + return attachedLinearLayoutManager; + } + + private void processChildren() { + final LinearLayoutManager llm = getLinearLayoutManager(); + if (llm != null) { + for (int i = 0; i < llm.getChildCount(); i++) { + final View child = llm.getChildAt(i); + if (child != null) { + processChild(child); + } + } + } + } + + private void processChild(@NonNull View child) { + processChild(child, false); + } + + private void processChild(@NonNull View child, boolean detachEvent) { + final LinearLayoutManager llm = getLinearLayoutManager(); + if (attachedRecyclerView != null && llm != null) { + attachedRecyclerView.getChildViewHolder(child); + final ViewHolder holder = attachedRecyclerView.getChildViewHolder(child); + if (holder instanceof EpoxyViewHolder) { + processVisibilityEvents(attachedRecyclerView, (EpoxyViewHolder) holder, + llm.getOrientation(), detachEvent); + } + } + } + + private void processVisibilityEvents( + @NonNull RecyclerView recyclerView, + @NonNull EpoxyViewHolder epoxyHolder, + int orientation, boolean detachEvent + ) { + if (epoxyHolder.getAdapterPosition() == RecyclerView.NO_POSITION) { + return; + } + + final View itemView = epoxyHolder.itemView; + final int id = System.identityHashCode(itemView); + + EpoxyVisibilityItem vi = visibilityIdToItemMap.get(id); + if (vi == null) { + vi = new EpoxyVisibilityItem(); + visibilityIdToItemMap.put(id, vi); + } + + if (vi.getAdapterPosition() != epoxyHolder.getAdapterPosition()) { + // EpoxyVisibilityItem being re-used for a different position + vi.reset(epoxyHolder.getAdapterPosition()); + } + + if (vi.update(itemView, recyclerView, orientation)) { + // View is measured, process events + vi.handleVisible(epoxyHolder); + vi.handleInvisible(epoxyHolder, detachEvent); + vi.handleFocusedVisible(epoxyHolder); + vi.handleUnfocusedVisible(epoxyHolder); + vi.handleFullImpressionVisible(epoxyHolder); + vi.handleChanged(epoxyHolder); + } + } + + /** + * Helper class that host the {@link android.support.v7.widget.RecyclerView} listener + * implementations + */ + private class Listener extends OnScrollListener + implements OnLayoutChangeListener, OnChildAttachStateChangeListener { + + @Override + public void onLayoutChange( + @NonNull View recyclerView, + int left, int top, int right, int bottom, + int oldLeft, int oldTop, int oldRight, int oldBottom + ) { + processChildren(); + } + + @Override + public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { + processChildren(); + } + + @Override + public void onChildViewAttachedToWindow(View child) { + processChild(child); + } + + @Override + public void onChildViewDetachedFromWindow(View child) { + processChild(child, true); + } + } +} diff --git a/epoxy-annotations/src/main/java/com/airbnb/epoxy/OnVisibilityEvent.java b/epoxy-annotations/src/main/java/com/airbnb/epoxy/OnVisibilityEvent.java new file mode 100644 index 0000000000..a27da19eb3 --- /dev/null +++ b/epoxy-annotations/src/main/java/com/airbnb/epoxy/OnVisibilityEvent.java @@ -0,0 +1,63 @@ +package com.airbnb.epoxy; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * This can be used to annotate methods inside classes with a {@link ModelView} + * annotation. Methods with this annotation will be called when the viewport is + * changed. + * + * Inspired from Litho : https://fblitho.com/docs/visibility-handling + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.CLASS) +public @interface OnVisibilityEvent { + enum Event { + /** + * Event triggered when a Component enters the Visible Range. This happens + * when at least a pixel of the Component is visible. + */ + Visible, + /** + * Event triggered when a Component becomes invisible. This is the same with + * exiting the Visible Range, the Focused Range and the Full Impression + * Range. All the code that needs to be executed when a component leaves + * any of these ranges should be written in the handler for this event. + */ + Invisible, + /** + * Event triggered when a Component enters the Focused Range. This happens + * when either the Component occupies at least half of the viewport or, + * if the Component is smaller than half of the viewport, when the it is + * fully visible. + */ + FocusedVisible, + /** + * Event triggered when a Component exits the Focused Range. The Focused + * Range is defined as at least half of the viewport or, if the Component is + * smaller than half of the viewport, when the it is fully visible. + */ + UnfocusedVisible, + /** + * Event triggered when a Component enters the Full Impression Range. This + * happens, for instance in the case of a vertical RecyclerView, when both + * the top and bottom edges of the component become visible. + */ + FullImpressionVisible, + /** + * Event triggered when the visible rect of a Component changes. + * + * VisibilityChangedEvents should be used with particular care since they + * will be dispatched on every frame while scrolling. No heavy work should + * be done inside the VisibilityChangedEvents handlers. Visible, Invisible, + * Focused, Unfocused and Full Impression events are the recommended over + * VisibilityChanged events whenever possible. + */ + Changed, + } + + Event value() default Event.Changed; +} diff --git a/epoxy-processor/src/main/java/com/airbnb/epoxy/GeneratedModelWriter.kt b/epoxy-processor/src/main/java/com/airbnb/epoxy/GeneratedModelWriter.kt index 4e826449cb..a89f985bf7 100644 --- a/epoxy-processor/src/main/java/com/airbnb/epoxy/GeneratedModelWriter.kt +++ b/epoxy-processor/src/main/java/com/airbnb/epoxy/GeneratedModelWriter.kt @@ -78,6 +78,14 @@ internal class GeneratedModelWriter( } + open fun addToVisibilityMethod( + visibilityBuilder: Builder, + visibilityParamName: String, + event: OnVisibilityEvent.Event + ) { + + } + /** * True true to have the bind method build, false to not add the method to the generated class. */ @@ -137,6 +145,7 @@ internal class GeneratedModelWriter( addMethods(generateProgrammaticViewMethods(info)) addMethods(generateBindMethods(info)) + addMethods(generateVisibilityMethods(info)) addMethods(generateStyleableViewMethods(info)) addMethods(generateSettersAndGetters(info)) addMethods(generateMethodsReturningClassType(info)) @@ -435,6 +444,18 @@ internal class GeneratedModelWriter( } } + private fun generateVisibilityMethods(modelInfo: GeneratedModelInfo): Iterable { + val methods = ArrayList() + val boundObjectParam = ParameterSpec.builder(modelInfo.modelType, "object", FINAL).build() + methods.add(buildVisibilityVisibleMethod(boundObjectParam)) + methods.add(buildVisibilityFocusedVisibleMethod(boundObjectParam)) + methods.add(buildVisibilityUnfocusedVisibleMethod(boundObjectParam)) + methods.add(buildVisibilityInvisibleMethod(boundObjectParam)) + methods.add(buildVisibilityFullImpressionVisibleMethod(boundObjectParam)) + methods.add(buildVisibilityChangedMethod(boundObjectParam)) + return methods + } + private fun generateBindMethods(modelInfo: GeneratedModelInfo): Iterable { val methods = ArrayList() @@ -581,6 +602,82 @@ internal class GeneratedModelWriter( builderHooks?.addToBindMethod(this, boundObjectParam) } + private fun buildVisibilityVisibleMethod( + boundObjectParam: ParameterSpec + ) = buildMethod("visibilityVisible") { + addAnnotation(Override::class.java) + addModifiers(PUBLIC) + addParameter(boundObjectParam) + + builderHooks?.addToVisibilityMethod(this, boundObjectParam.name, OnVisibilityEvent.Event.Visible) + + addStatement("super.visibilityVisible(\$L)", boundObjectParam.name) + } + + private fun buildVisibilityUnfocusedVisibleMethod( + boundObjectParam: ParameterSpec + ) = buildMethod("visibilityUnfocusedVisible") { + addAnnotation(Override::class.java) + addModifiers(PUBLIC) + addParameter(boundObjectParam) + + builderHooks?.addToVisibilityMethod(this, boundObjectParam.name, OnVisibilityEvent.Event.UnfocusedVisible) + + addStatement("super.visibilityUnfocusedVisible(\$L)", boundObjectParam.name) + } + + private fun buildVisibilityFocusedVisibleMethod( + boundObjectParam: ParameterSpec + ) = buildMethod("visibilityFocusedVisible") { + addAnnotation(Override::class.java) + addModifiers(PUBLIC) + addParameter(boundObjectParam) + + builderHooks?.addToVisibilityMethod(this, boundObjectParam.name, OnVisibilityEvent.Event.FocusedVisible) + + addStatement("super.visibilityFocusedVisible(\$L)", boundObjectParam.name) + } + + private fun buildVisibilityInvisibleMethod( + boundObjectParam: ParameterSpec + ) = buildMethod("visibilityInvisible") { + addAnnotation(Override::class.java) + addModifiers(PUBLIC) + addParameter(boundObjectParam) + + builderHooks?.addToVisibilityMethod(this, boundObjectParam.name, OnVisibilityEvent.Event.Invisible) + + addStatement("super.visibilityInvisible(\$L)", boundObjectParam.name) + } + + private fun buildVisibilityFullImpressionVisibleMethod( + boundObjectParam: ParameterSpec + ) = buildMethod("visibilityFullImpressionVisible") { + addAnnotation(Override::class.java) + addModifiers(PUBLIC) + addParameter(boundObjectParam) + + builderHooks?.addToVisibilityMethod(this, boundObjectParam.name, OnVisibilityEvent.Event.FullImpressionVisible) + + addStatement("super.visibilityFullImpressionVisible(\$L)", boundObjectParam.name) + } + + private fun buildVisibilityChangedMethod( + boundObjectParam: ParameterSpec + ) = buildMethod("visibilityChanged") { + addAnnotation(Override::class.java) + addModifiers(PUBLIC) + addParameter(TypeName.FLOAT, "percentVisibleHeight") + addParameter(TypeName.FLOAT, "percentVisibleWidth") + addParameter(TypeName.INT, "visibleHeight") + addParameter(TypeName.INT, "visibleWidth") + addParameter(boundObjectParam) + + builderHooks?.addToVisibilityMethod(this, boundObjectParam.name, OnVisibilityEvent.Event.Changed) + + addStatement("super.visibilityChanged(\$L, \$L, \$L, \$L, \$L)", "percentVisibleHeight", "percentVisibleWidth", "visibleHeight", "visibleWidth", boundObjectParam.name) + } + private fun buildBindWithDiffMethod( classInfo: GeneratedModelInfo, boundObjectParam: ParameterSpec diff --git a/epoxy-processor/src/main/java/com/airbnb/epoxy/ModelViewInfo.kt b/epoxy-processor/src/main/java/com/airbnb/epoxy/ModelViewInfo.kt index 0855ca9b85..4fd127caf0 100644 --- a/epoxy-processor/src/main/java/com/airbnb/epoxy/ModelViewInfo.kt +++ b/epoxy-processor/src/main/java/com/airbnb/epoxy/ModelViewInfo.kt @@ -13,7 +13,6 @@ import javax.lang.model.type.MirroredTypeException import javax.lang.model.type.TypeMirror import javax.lang.model.util.Elements import javax.lang.model.util.Types -import javax.tools.Diagnostic internal class ModelViewInfo( val viewElement: TypeElement, @@ -24,6 +23,7 @@ internal class ModelViewInfo( private val resourceProcessor: ResourceProcessor ) : GeneratedModelInfo() { val resetMethodNames = mutableListOf() + val visibilityMethodNamesMap = mutableMapOf>() val afterPropsSetMethodNames = mutableListOf() val saveViewState: Boolean private val viewAnnotation: ModelView = viewElement.getAnnotation(ModelView::class.java) @@ -200,6 +200,20 @@ internal class ModelViewInfo( } } + fun addOnVisibilityChangedMethodIfNotExists( + visibilityMethod: Element, + event: OnVisibilityEvent.Event + ) { + val methodName = visibilityMethod.simpleName.toString() + val list = + visibilityMethodNamesMap[event] ?: mutableListOf().apply { + visibilityMethodNamesMap[event] = this + } + if (!list.contains(methodName)) { + list.add(methodName) + } + } + fun addAfterPropsSetMethodIfNotExists(afterPropsSetMethod: Element) { val methodName = afterPropsSetMethod.simpleName.toString() if (!afterPropsSetMethodNames.contains(methodName)) { diff --git a/epoxy-processor/src/main/java/com/airbnb/epoxy/ModelViewProcessor.kt b/epoxy-processor/src/main/java/com/airbnb/epoxy/ModelViewProcessor.kt index 38198791ab..79bf18ecc2 100644 --- a/epoxy-processor/src/main/java/com/airbnb/epoxy/ModelViewProcessor.kt +++ b/epoxy-processor/src/main/java/com/airbnb/epoxy/ModelViewProcessor.kt @@ -1,11 +1,20 @@ package com.airbnb.epoxy -import com.airbnb.epoxy.Utils.* +import com.airbnb.epoxy.Utils.belongToTheSamePackage +import com.airbnb.epoxy.Utils.isFieldPackagePrivate +import com.airbnb.epoxy.Utils.isSubtype +import com.airbnb.epoxy.Utils.isSubtypeOfType import java.util.* -import javax.annotation.processing.* -import javax.lang.model.element.* -import javax.lang.model.element.Modifier.* -import javax.lang.model.util.* +import javax.annotation.processing.RoundEnvironment +import javax.lang.model.element.Element +import javax.lang.model.element.ElementKind +import javax.lang.model.element.ExecutableElement +import javax.lang.model.element.Modifier.PRIVATE +import javax.lang.model.element.Modifier.STATIC +import javax.lang.model.element.TypeElement +import javax.lang.model.element.VariableElement +import javax.lang.model.util.Elements +import javax.lang.model.util.Types // TODO: (eli_hart 5/30/17) allow param counts > 0 in setters // TODO: (eli_hart 5/23/17) Allow default values to be methods @@ -35,6 +44,7 @@ internal class ModelViewProcessor( processSetterAnnotations(roundEnv) processResetAnnotations(roundEnv) + processVisibilityAnnotations(roundEnv) processAfterBindAnnotations(roundEnv) updateViewsForInheritedViewAnnotations() @@ -250,6 +260,29 @@ internal class ModelViewProcessor( } } + private fun processVisibilityAnnotations(roundEnv: RoundEnvironment) { + for (visibilityMethod in roundEnv.getElementsAnnotatedWith(OnVisibilityEvent::class.java)) { + val value = visibilityMethod.getAnnotation(OnVisibilityEvent::class.java).value + if (!validateVisibilityElement(visibilityMethod, value)) { + continue + } + + val info = getModelInfoForPropElement(visibilityMethod) + if (info == null) { + errorLogger.logError( + "%s annotation can only be used in classes annotated with %s", + OnVisibilityEvent::class.java, ModelView::class.java + ) + continue + } + + info.addOnVisibilityChangedMethodIfNotExists( + visibilityMethod as ExecutableElement, + value + ) + } + } + private fun processAfterBindAnnotations(roundEnv: RoundEnvironment) { for (afterPropsMethod in roundEnv.getElementsAnnotatedWith(AfterPropsSet::class.java)) { if (!validateAfterPropsMethod(afterPropsMethod)) { @@ -315,6 +348,11 @@ internal class ModelViewProcessor( view.addOnRecycleMethodIfNotExists(it) } + forEachElementWithAnnotation(listOf(OnVisibilityEvent::class.java)) { + view.addOnVisibilityChangedMethodIfNotExists(it, it.getAnnotation( + OnVisibilityEvent::class.java).value) + } + forEachElementWithAnnotation(listOf(AfterPropsSet::class.java)) { view.addAfterPropsSetMethodIfNotExists(it) } @@ -354,7 +392,23 @@ internal class ModelViewProcessor( } private fun validateResetElement(resetMethod: Element): Boolean = - validateExecutableElement(resetMethod, OnViewRecycled::class.java, 0) + validateExecutableElement(resetMethod, OnViewRecycled::class.java, 0) + + private fun validateVisibilityElement( + visibilityMethod: Element, + event: OnVisibilityEvent.Event + ): Boolean = when (event) { + OnVisibilityEvent.Event.Changed -> validateExecutableElement( + visibilityMethod, + OnVisibilityEvent::class.java, + 4 + ) + else -> validateExecutableElement( + visibilityMethod, + OnVisibilityEvent::class.java, + 0 + ) + } private fun writeJava() { val modelsToWrite = mutableListOf() diff --git a/epoxy-processor/src/main/java/com/airbnb/epoxy/ModelViewWriter.kt b/epoxy-processor/src/main/java/com/airbnb/epoxy/ModelViewWriter.kt index cd2b89bb8f..69dc83ae6a 100644 --- a/epoxy-processor/src/main/java/com/airbnb/epoxy/ModelViewWriter.kt +++ b/epoxy-processor/src/main/java/com/airbnb/epoxy/ModelViewWriter.kt @@ -204,6 +204,18 @@ internal class ModelViewWriter( unbindParamName) } + override fun addToVisibilityMethod( + visibilityBuilder: MethodSpec.Builder, + visibilityParamName: String, + event: OnVisibilityEvent.Event + ) { + addVisibilityMethodsToBuilder(visibilityBuilder, + modelInfo, + visibilityParamName, + event + ) + } + override fun beforeFinalBuild(builder: TypeSpec.Builder) { if (modelInfo.saveViewState) { builder.addMethod( @@ -280,6 +292,32 @@ internal class ModelViewWriter( } } + private fun addVisibilityMethodsToBuilder( + builder: MethodSpec.Builder, + modelViewInfo: ModelViewInfo, + unbindParamName: String, + event: OnVisibilityEvent.Event + ) { + modelViewInfo.visibilityMethodNamesMap[event]?.let { visibilityMethodNames -> + for (methodName in visibilityMethodNames) { + when (event) { + OnVisibilityEvent.Event.Visible -> + builder.addStatement("$unbindParamName.$methodName()") + OnVisibilityEvent.Event.Invisible -> + builder.addStatement("$unbindParamName.$methodName()") + OnVisibilityEvent.Event.UnfocusedVisible -> + builder.addStatement("$unbindParamName.$methodName()") + OnVisibilityEvent.Event.FocusedVisible -> + builder.addStatement("$unbindParamName.$methodName()") + OnVisibilityEvent.Event.FullImpressionVisible -> + builder.addStatement("$unbindParamName.$methodName()") + OnVisibilityEvent.Event.Changed -> + builder.addStatement("$unbindParamName.$methodName(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth)") + } + } + } + } + private fun addAfterPropsAddedMethodsToBuilder( methodBuilder: MethodSpec.Builder, modelInfo: ModelViewInfo, @@ -289,5 +327,4 @@ internal class ModelViewWriter( methodBuilder.addStatement(boundObjectParam.name + "." + methodName + "()") } } - } diff --git a/kotlinsample/src/main/java/com/airbnb/epoxy/kotlinsample/models/ItemCustomView.kt b/kotlinsample/src/main/java/com/airbnb/epoxy/kotlinsample/models/ItemCustomView.kt index 7ae91011a9..a5ca118853 100644 --- a/kotlinsample/src/main/java/com/airbnb/epoxy/kotlinsample/models/ItemCustomView.kt +++ b/kotlinsample/src/main/java/com/airbnb/epoxy/kotlinsample/models/ItemCustomView.kt @@ -10,6 +10,7 @@ import com.airbnb.epoxy.AfterPropsSet import com.airbnb.epoxy.CallbackProp import com.airbnb.epoxy.ModelProp import com.airbnb.epoxy.ModelView +import com.airbnb.epoxy.OnVisibilityEvent import com.airbnb.epoxy.TextProp import com.airbnb.epoxy.kotlinsample.R @@ -52,4 +53,34 @@ class ItemCustomView @JvmOverloads constructor( textView.text = title textView.setOnClickListener(listener) } + + @OnVisibilityEvent(OnVisibilityEvent.Event.Changed) + fun onChanged( + visibleHeight: Float, + visibleWidth: Float, + percentVisibleHeight: Int, + percentVisibleWidth: Int + ) { + textView.text = "onVisibilityChanged $visibleHeight $visibleWidth $percentVisibleHeight $percentVisibleWidth" + } + + @OnVisibilityEvent(OnVisibilityEvent.Event.Visible) + fun onVisible() { + } + + @OnVisibilityEvent(OnVisibilityEvent.Event.FocusedVisible) + fun onFocusedVisible() { + } + + @OnVisibilityEvent(OnVisibilityEvent.Event.FullImpressionVisible) + fun onFullImpressionVisible() { + } + + @OnVisibilityEvent(OnVisibilityEvent.Event.Invisible) + fun onInvisible() { + } + + @OnVisibilityEvent(OnVisibilityEvent.Event.UnfocusedVisible) + fun onUnfocusedVisible() { + } } \ No newline at end of file From a0fe6a4700ded264e06a57208bfac1f11ea5cd07 Mon Sep 17 00:00:00 2001 From: Emmanuel Boudrant Date: Tue, 2 Oct 2018 13:35:24 -0700 Subject: [PATCH 02/38] checkstyle failures --- .../src/main/java/com/airbnb/epoxy/EpoxyRecyclerView.java | 4 ++-- .../src/main/java/com/airbnb/epoxy/EpoxyViewHolder.java | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyRecyclerView.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyRecyclerView.java index 721d836748..0ebd3e05ba 100644 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyRecyclerView.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyRecyclerView.java @@ -247,8 +247,8 @@ protected RecycledViewPool createViewPool() { * half of the viewport, or, if the Component is smaller than half the viewport, when it is fully * visible. *

- * - Unfocused Visible Event: this event is triggered when the Component is no longer focused, i.e. - * it is not fully visible and does not occupy at least half the viewport. + * - Unfocused Visible Event: this event is triggered when the Component is no longer focused, + * i.e. it is not fully visible and does not occupy at least half the viewport. *

* - Full Impression Visible Event: this event is triggered when the entire Component has passed * through the viewport at some point. diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyViewHolder.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyViewHolder.java index ac38a77d1d..3d0b847a89 100755 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyViewHolder.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyViewHolder.java @@ -82,10 +82,12 @@ public void unbind() { payloads = null; } - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth) { + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth) { assertBound(); // noinspection unchecked - epoxyModel.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, objectToBind()); + epoxyModel.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, + visibleWidth, objectToBind()); } public void visibilityVisible() { From 03fc79951ce2e4695d41cc2d5ec8910bbd9b253a Mon Sep 17 00:00:00 2001 From: Emmanuel Boudrant Date: Tue, 2 Oct 2018 16:13:54 -0700 Subject: [PATCH 03/38] Fix existing tests --- .../com/airbnb/epoxy/GeneratedModelWriter.kt | 57 ++++++++++++++----- .../java/com/airbnb/epoxy/ModelViewWriter.kt | 4 +- 2 files changed, 47 insertions(+), 14 deletions(-) diff --git a/epoxy-processor/src/main/java/com/airbnb/epoxy/GeneratedModelWriter.kt b/epoxy-processor/src/main/java/com/airbnb/epoxy/GeneratedModelWriter.kt index a89f985bf7..a5a45365b5 100644 --- a/epoxy-processor/src/main/java/com/airbnb/epoxy/GeneratedModelWriter.kt +++ b/epoxy-processor/src/main/java/com/airbnb/epoxy/GeneratedModelWriter.kt @@ -447,12 +447,28 @@ internal class GeneratedModelWriter( private fun generateVisibilityMethods(modelInfo: GeneratedModelInfo): Iterable { val methods = ArrayList() val boundObjectParam = ParameterSpec.builder(modelInfo.modelType, "object", FINAL).build() - methods.add(buildVisibilityVisibleMethod(boundObjectParam)) - methods.add(buildVisibilityFocusedVisibleMethod(boundObjectParam)) - methods.add(buildVisibilityUnfocusedVisibleMethod(boundObjectParam)) - methods.add(buildVisibilityInvisibleMethod(boundObjectParam)) - methods.add(buildVisibilityFullImpressionVisibleMethod(boundObjectParam)) - methods.add(buildVisibilityChangedMethod(boundObjectParam)) + if (modelInfo is ModelViewInfo) { + with(modelInfo.visibilityMethodNamesMap) { + if (containsKey(OnVisibilityEvent.Event.Visible)) { + methods.add(buildVisibilityVisibleMethod(boundObjectParam)) + } + if (containsKey(OnVisibilityEvent.Event.Invisible)) { + methods.add(buildVisibilityInvisibleMethod(boundObjectParam)) + } + if (containsKey(OnVisibilityEvent.Event.FocusedVisible)) { + methods.add(buildVisibilityFocusedVisibleMethod(boundObjectParam)) + } + if (containsKey(OnVisibilityEvent.Event.UnfocusedVisible)) { + methods.add(buildVisibilityUnfocusedVisibleMethod(boundObjectParam)) + } + if (containsKey(OnVisibilityEvent.Event.FullImpressionVisible)) { + methods.add(buildVisibilityFullImpressionVisibleMethod(boundObjectParam)) + } + if (containsKey(OnVisibilityEvent.Event.Changed)) { + methods.add(buildVisibilityChangedMethod(boundObjectParam)) + } + } + } return methods } @@ -609,7 +625,9 @@ internal class GeneratedModelWriter( addModifiers(PUBLIC) addParameter(boundObjectParam) - builderHooks?.addToVisibilityMethod(this, boundObjectParam.name, OnVisibilityEvent.Event.Visible) + builderHooks?.addToVisibilityMethod( + this, boundObjectParam.name, OnVisibilityEvent.Event.Visible + ) addStatement("super.visibilityVisible(\$L)", boundObjectParam.name) } @@ -621,7 +639,9 @@ internal class GeneratedModelWriter( addModifiers(PUBLIC) addParameter(boundObjectParam) - builderHooks?.addToVisibilityMethod(this, boundObjectParam.name, OnVisibilityEvent.Event.UnfocusedVisible) + builderHooks?.addToVisibilityMethod( + this, boundObjectParam.name, OnVisibilityEvent.Event.UnfocusedVisible + ) addStatement("super.visibilityUnfocusedVisible(\$L)", boundObjectParam.name) } @@ -633,7 +653,9 @@ internal class GeneratedModelWriter( addModifiers(PUBLIC) addParameter(boundObjectParam) - builderHooks?.addToVisibilityMethod(this, boundObjectParam.name, OnVisibilityEvent.Event.FocusedVisible) + builderHooks?.addToVisibilityMethod( + this, boundObjectParam.name, OnVisibilityEvent.Event.FocusedVisible + ) addStatement("super.visibilityFocusedVisible(\$L)", boundObjectParam.name) } @@ -645,7 +667,9 @@ internal class GeneratedModelWriter( addModifiers(PUBLIC) addParameter(boundObjectParam) - builderHooks?.addToVisibilityMethod(this, boundObjectParam.name, OnVisibilityEvent.Event.Invisible) + builderHooks?.addToVisibilityMethod( + this, boundObjectParam.name, OnVisibilityEvent.Event.Invisible + ) addStatement("super.visibilityInvisible(\$L)", boundObjectParam.name) } @@ -657,7 +681,9 @@ internal class GeneratedModelWriter( addModifiers(PUBLIC) addParameter(boundObjectParam) - builderHooks?.addToVisibilityMethod(this, boundObjectParam.name, OnVisibilityEvent.Event.FullImpressionVisible) + builderHooks?.addToVisibilityMethod( + this, boundObjectParam.name, OnVisibilityEvent.Event.FullImpressionVisible + ) addStatement("super.visibilityFullImpressionVisible(\$L)", boundObjectParam.name) } @@ -673,9 +699,14 @@ internal class GeneratedModelWriter( addParameter(TypeName.INT, "visibleWidth") addParameter(boundObjectParam) - builderHooks?.addToVisibilityMethod(this, boundObjectParam.name, OnVisibilityEvent.Event.Changed) + builderHooks?.addToVisibilityMethod( + this, boundObjectParam.name, OnVisibilityEvent.Event.Changed + ) - addStatement("super.visibilityChanged(\$L, \$L, \$L, \$L, \$L)", "percentVisibleHeight", "percentVisibleWidth", "visibleHeight", "visibleWidth", boundObjectParam.name) + addStatement( + "super.visibilityChanged(\$L, \$L, \$L, \$L, \$L)", "percentVisibleHeight", + "percentVisibleWidth", "visibleHeight", "visibleWidth", boundObjectParam.name + ) } private fun buildBindWithDiffMethod( diff --git a/epoxy-processor/src/main/java/com/airbnb/epoxy/ModelViewWriter.kt b/epoxy-processor/src/main/java/com/airbnb/epoxy/ModelViewWriter.kt index 69dc83ae6a..c2a90958c4 100644 --- a/epoxy-processor/src/main/java/com/airbnb/epoxy/ModelViewWriter.kt +++ b/epoxy-processor/src/main/java/com/airbnb/epoxy/ModelViewWriter.kt @@ -312,7 +312,9 @@ internal class ModelViewWriter( OnVisibilityEvent.Event.FullImpressionVisible -> builder.addStatement("$unbindParamName.$methodName()") OnVisibilityEvent.Event.Changed -> - builder.addStatement("$unbindParamName.$methodName(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth)") + builder.addStatement( + "$unbindParamName.$methodName(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth)" + ) } } } From 5b175d29866f7b8b53b47629e43386c183261aa9 Mon Sep 17 00:00:00 2001 From: Emmanuel Boudrant Date: Wed, 3 Oct 2018 09:49:34 -0700 Subject: [PATCH 04/38] Send visibleSize instead of size, prevent sending duplicate events. --- .../java/com/airbnb/epoxy/EpoxyRecyclerView.java | 2 +- .../com/airbnb/epoxy/EpoxyVisibilityItem.java | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyRecyclerView.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyRecyclerView.java index 0ebd3e05ba..29224e22c0 100644 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyRecyclerView.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyRecyclerView.java @@ -81,7 +81,7 @@ public class EpoxyRecyclerView extends RecyclerView { private boolean visibilityTrackingEnabled = false; @NonNull - private EpoxyVisibilityTracker epoxyVisibilityTracker = new EpoxyVisibilityTracker(); + private final EpoxyVisibilityTracker epoxyVisibilityTracker = new EpoxyVisibilityTracker(); /** * The adapter that was removed because the RecyclerView was detached from the window. We save it diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java index 179cca1e24..5960b8760f 100644 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java @@ -30,6 +30,9 @@ class EpoxyVisibilityItem { private boolean visible = false; private boolean focusedVisible = false; + /** Store last value for deduping */ + private int lastVisibleSizeNotified = -1; + /** * Update the visibility item according the current layout. * @@ -65,6 +68,7 @@ void reset(int newAdapterPosition) { visible = false; focusedVisible = false; adapterPosition = newAdapterPosition; + lastVisibleSizeNotified = -1; } void handleVisible(@NonNull EpoxyViewHolder epoxyHolder) { @@ -98,10 +102,13 @@ void handleFullImpressionVisible(EpoxyViewHolder epoxyHolder) { } void handleChanged(EpoxyViewHolder epoxyHolder) { - if (vertical) { - epoxyHolder.visibilityChanged(percentVisibleSize, 100.f, size, otherSize); - } else { - epoxyHolder.visibilityChanged(100.f, percentVisibleSize, otherSize, size); + if (visibleSize != lastVisibleSizeNotified) { + if (vertical) { + epoxyHolder.visibilityChanged(percentVisibleSize, 100.f, visibleSize, otherSize); + } else { + epoxyHolder.visibilityChanged(100.f, percentVisibleSize, otherSize, visibleSize); + } + lastVisibleSizeNotified = visibleSize; } } From 3b29fe83d10ad1818fad3f76e418a24ea9621329 Mon Sep 17 00:00:00 2001 From: Emmanuel Boudrant Date: Wed, 3 Oct 2018 09:50:01 -0700 Subject: [PATCH 05/38] Remove useless private methods --- .../com/airbnb/epoxy/EpoxyVisibilityItem.java | 38 +++++-------------- 1 file changed, 9 insertions(+), 29 deletions(-) diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java index 5960b8760f..7b82f8d16f 100644 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java @@ -63,6 +63,10 @@ boolean update(@NonNull View view, @NonNull RecyclerView parent, int orientation return size > 0; } + int getAdapterPosition() { + return adapterPosition; + } + void reset(int newAdapterPosition) { fullyVisible = false; visible = false; @@ -72,31 +76,31 @@ void reset(int newAdapterPosition) { } void handleVisible(@NonNull EpoxyViewHolder epoxyHolder) { - if (!wasVisible() && isVisible()) { + if (!visible && isVisible()) { epoxyHolder.visibilityVisible(); } } void handleInvisible(EpoxyViewHolder epoxyHolder, boolean detachEvent) { - if (!wasInvisible() && isInvisible(detachEvent)) { + if (visible && isInvisible(detachEvent)) { epoxyHolder.visibilityInvisible(); } } void handleFocusedVisible(EpoxyViewHolder epoxyHolder) { - if (!wasFocusedVisible() && isFocusedVisible()) { + if (!focusedVisible && isFocusedVisible()) { epoxyHolder.visibilityFocusedVisible(); } } void handleUnfocusedVisible(EpoxyViewHolder epoxyHolder) { - if (!wasUnfocusedVisible() && isUnfocusedVisible()) { + if (focusedVisible && isUnfocusedVisible()) { epoxyHolder.visibilityUnfocusedVisible(); } } void handleFullImpressionVisible(EpoxyViewHolder epoxyHolder) { - if (!wasFullImpressionVisible() && isFullImpressionVisible()) { + if (!fullyVisible && isFullImpressionVisible()) { epoxyHolder.visibilityFullImpressionVisible(); } } @@ -112,19 +116,11 @@ void handleChanged(EpoxyViewHolder epoxyHolder) { } } - int getAdapterPosition() { - return adapterPosition; - } - private boolean isVisible() { // true when at least one pixel of the Component is visible return visible = visibleSize > 0; } - private boolean wasVisible() { - return visible; - } - private boolean isInvisible(boolean detachEvent) { // true when when the Component no longer has any pixels on the screen boolean invisible = visibleSize <= 0 || detachEvent; @@ -134,10 +130,6 @@ private boolean isInvisible(boolean detachEvent) { return !visible; } - private boolean wasInvisible() { - return !visible; - } - private boolean isFocusedVisible() { // true when either the Component occupies at least half of the viewport, or, if the Component // is smaller than half the viewport, when it is fully visible. @@ -145,10 +137,6 @@ private boolean isFocusedVisible() { size >= viewportSize / 2 || (visibleSize == size && size < viewportSize / 2); } - private boolean wasFocusedVisible() { - return focusedVisible; - } - private boolean isUnfocusedVisible() { // true when the Component is no longer focused, i.e. it is not fully visible and does not // occupy at least half the viewport. @@ -160,14 +148,6 @@ private boolean isUnfocusedVisible() { return !focusedVisible; } - private boolean wasUnfocusedVisible() { - return !focusedVisible; - } - - private boolean wasFullImpressionVisible() { - return fullyVisible; - } - private boolean isFullImpressionVisible() { // true when the entire Component has passed through the viewport at some point. return fullyVisible = visibleSize == size; From 33757a99bd64f0401ba2bd1b1a2187b517c6fbdd Mon Sep 17 00:00:00 2001 From: Emmanuel Boudrant Date: Wed, 3 Oct 2018 09:51:03 -0700 Subject: [PATCH 06/38] Add visibility events in sample app. --- .../airbnb/epoxy/kotlinsample/MainActivity.kt | 1 + .../kotlinsample/models/ItemCustomView.kt | 68 +++++++++---- .../models/OnVisibilityEventDrawable.kt | 96 +++++++++++++++++++ 3 files changed, 148 insertions(+), 17 deletions(-) create mode 100644 kotlinsample/src/main/java/com/airbnb/epoxy/kotlinsample/models/OnVisibilityEventDrawable.kt diff --git a/kotlinsample/src/main/java/com/airbnb/epoxy/kotlinsample/MainActivity.kt b/kotlinsample/src/main/java/com/airbnb/epoxy/kotlinsample/MainActivity.kt index 6ace282022..0820f1143b 100644 --- a/kotlinsample/src/main/java/com/airbnb/epoxy/kotlinsample/MainActivity.kt +++ b/kotlinsample/src/main/java/com/airbnb/epoxy/kotlinsample/MainActivity.kt @@ -18,6 +18,7 @@ class MainActivity : AppCompatActivity() { setContentView(R.layout.activity) recyclerView = findViewById(R.id.recycler_view) + recyclerView.setVisibilityTrackingEnabled(true) recyclerView.withModels { diff --git a/kotlinsample/src/main/java/com/airbnb/epoxy/kotlinsample/models/ItemCustomView.kt b/kotlinsample/src/main/java/com/airbnb/epoxy/kotlinsample/models/ItemCustomView.kt index a5ca118853..e0ab60db2e 100644 --- a/kotlinsample/src/main/java/com/airbnb/epoxy/kotlinsample/models/ItemCustomView.kt +++ b/kotlinsample/src/main/java/com/airbnb/epoxy/kotlinsample/models/ItemCustomView.kt @@ -3,6 +3,7 @@ package com.airbnb.epoxy.kotlinsample.models import android.content.Context import android.support.annotation.ColorInt import android.util.AttributeSet +import android.util.Log import android.view.View import android.widget.LinearLayout import android.widget.TextView @@ -10,6 +11,7 @@ import com.airbnb.epoxy.AfterPropsSet import com.airbnb.epoxy.CallbackProp import com.airbnb.epoxy.ModelProp import com.airbnb.epoxy.ModelView +import com.airbnb.epoxy.OnViewRecycled import com.airbnb.epoxy.OnVisibilityEvent import com.airbnb.epoxy.TextProp import com.airbnb.epoxy.kotlinsample.R @@ -23,11 +25,16 @@ class ItemCustomView @JvmOverloads constructor( defStyleAttr: Int = 0 ) : LinearLayout(context, attrs, defStyleAttr) { - val textView: TextView + private val onVisibilityEventDrawable = OnVisibilityEventDrawable(context) + + private val textView: TextView + init { inflate(context, R.layout.custom_view_item, this) orientation = VERTICAL - textView = (findViewById(R.id.title)) + textView = (findViewById(R.id.title)) + textView.setCompoundDrawables(null, null, onVisibilityEventDrawable, null) + textView.compoundDrawablePadding = (4 * resources.displayMetrics.density).toInt() } // You can annotate your methods with @ModelProp @@ -45,7 +52,6 @@ class ItemCustomView @JvmOverloads constructor( // 2. Or you can use lateinit @TextProp lateinit var title: CharSequence - @AfterPropsSet fun useProps() { // This is optional, and is called after the annotated properties above are set. @@ -54,33 +60,61 @@ class ItemCustomView @JvmOverloads constructor( textView.setOnClickListener(listener) } - @OnVisibilityEvent(OnVisibilityEvent.Event.Changed) - fun onChanged( - visibleHeight: Float, - visibleWidth: Float, - percentVisibleHeight: Int, - percentVisibleWidth: Int - ) { - textView.text = "onVisibilityChanged $visibleHeight $visibleWidth $percentVisibleHeight $percentVisibleWidth" - } - @OnVisibilityEvent(OnVisibilityEvent.Event.Visible) fun onVisible() { + Log.d(TAG, "$title Visible") + onVisibilityEventDrawable.visible = true + } + + @OnVisibilityEvent(OnVisibilityEvent.Event.Invisible) + fun onInvisible() { + Log.d(TAG, "$title Invisible") + onVisibilityEventDrawable.visible = false } @OnVisibilityEvent(OnVisibilityEvent.Event.FocusedVisible) fun onFocusedVisible() { + Log.d(TAG, "$title FocusedVisible") + onVisibilityEventDrawable.focusedVisible = true + } + + @OnVisibilityEvent(OnVisibilityEvent.Event.UnfocusedVisible) + fun onUnfocusedVisible() { + Log.d(TAG, "$title UnfocusedVisible") + onVisibilityEventDrawable.focusedVisible = false } @OnVisibilityEvent(OnVisibilityEvent.Event.FullImpressionVisible) fun onFullImpressionVisible() { + Log.d(TAG, "$title FullImpressionVisible") + onVisibilityEventDrawable.fullImpression = true } - @OnVisibilityEvent(OnVisibilityEvent.Event.Invisible) - fun onInvisible() { + @OnVisibilityEvent(OnVisibilityEvent.Event.Changed) + fun onChanged( + percentVisibleHeight: Float, + percentVisibleWidth: Float, + visibleHeight: Int, + visibleWidth: Int + ) { + Log.d( + TAG, + "$title onChanged ${percentVisibleHeight.toInt()} ${percentVisibleWidth.toInt()} $visibleHeight $visibleWidth ${System.identityHashCode(this)}" + ) + with(onVisibilityEventDrawable) { + if (percentVisibleHeight < 100 && fullImpression) { + fullImpression = false + } + percent = percentVisibleHeight + } } - @OnVisibilityEvent(OnVisibilityEvent.Event.UnfocusedVisible) - fun onUnfocusedVisible() { + @OnViewRecycled + fun clear() { + onVisibilityEventDrawable.reset() + } + + companion object { + private const val TAG = "ItemCustomView" } } \ No newline at end of file diff --git a/kotlinsample/src/main/java/com/airbnb/epoxy/kotlinsample/models/OnVisibilityEventDrawable.kt b/kotlinsample/src/main/java/com/airbnb/epoxy/kotlinsample/models/OnVisibilityEventDrawable.kt new file mode 100644 index 0000000000..bbbe4833a1 --- /dev/null +++ b/kotlinsample/src/main/java/com/airbnb/epoxy/kotlinsample/models/OnVisibilityEventDrawable.kt @@ -0,0 +1,96 @@ +package com.airbnb.epoxy.kotlinsample.models + +import android.content.Context +import android.graphics.Canvas +import android.graphics.Color +import android.graphics.ColorFilter +import android.graphics.Paint +import android.graphics.PixelFormat +import android.graphics.drawable.Drawable + +/** + * Drawable for sample app that draw the current visibility state : + * - circle #1 : visible + * - circle #2 : focused + * - circle #3 : full impression + * - rectangle : visibility percentage + */ +class OnVisibilityEventDrawable(context: Context) : Drawable() { + + private val density = context.resources.displayMetrics.density + private val diameter = density * 12 + private val padding = density * 2 + private val paint = Paint().apply { + color = Color.LTGRAY + isAntiAlias = true + strokeWidth = density + } + + init { + setBounds(0, 0, padding.toInt() * 4 + diameter.toInt() * 3, diameter.toInt()) + } + + var visible = false + set(value) { + field = value + invalidateSelf() + } + + var focusedVisible = false + set(value) { + field = value + invalidateSelf() + } + + var fullImpression = false + set(value) { + field = value + invalidateSelf() + } + + var percent = 0.0f + set(value) { + field = value + invalidateSelf() + } + + fun reset() { + visible = false + focusedVisible = false + fullImpression = false + percent = 0.0f + invalidateSelf() + } + + override fun draw(canvas: Canvas) { + + val y = diameter / 2 + var x = diameter / 2 + padding + + paint.style = if (visible) Paint.Style.FILL_AND_STROKE else Paint.Style.STROKE + canvas.drawCircle(x, y, diameter / 2, paint) + + x += diameter + padding + paint.style = if (focusedVisible) Paint.Style.FILL_AND_STROKE else Paint.Style.STROKE + canvas.drawCircle(x, y, diameter / 2, paint) + + x += diameter + padding + paint.style = if (fullImpression) Paint.Style.FILL_AND_STROKE else Paint.Style.STROKE + canvas.drawCircle(x, y, diameter / 2, paint) + + paint.style = Paint.Style.STROKE + canvas.drawRect( + 0.0f, + 0.0f, + bounds.width() * percent / 100, + bounds.height().toFloat(), + paint + ) + } + + override fun setAlpha(alpha: Int) = Unit + + override fun getOpacity() = PixelFormat.TRANSLUCENT + + override fun setColorFilter(colorFilter: ColorFilter?) = Unit +} \ No newline at end of file From 7727d1fa3b718cfb5449cc6ab79b949b840d8c5d Mon Sep 17 00:00:00 2001 From: Emmanuel Boudrant Date: Thu, 4 Oct 2018 12:23:07 -0700 Subject: [PATCH 07/38] Replace `@OnVisibilityEvent(event = ...)` by `@OnVisibilityChanged` and `@OnVisibilityStateChanged` Add `OnModelVisibilityStateChangedListener` and `OnModelVisibilityChangedListener` interfaces --- .../java/com/airbnb/epoxy/EpoxyModel.java | 15 +-- .../airbnb/epoxy/EpoxyModelWithHolder.java | 24 +--- .../com/airbnb/epoxy/EpoxyViewHolder.java | 36 ++---- .../com/airbnb/epoxy/EpoxyVisibilityItem.java | 16 +-- .../OnModelVisibilityChangedListener.java | 25 ++++ ...OnModelVisibilityStateChangedListener.java | 58 +++++++++ .../com/airbnb/epoxy/OnVisibilityChanged.java | 18 +++ .../com/airbnb/epoxy/OnVisibilityEvent.java | 63 ---------- .../epoxy/OnVisibilityStateChanged.java | 20 ++++ .../com/airbnb/epoxy/GeneratedModelWriter.kt | 111 ++++-------------- .../java/com/airbnb/epoxy/ModelViewInfo.kt | 23 ++-- .../com/airbnb/epoxy/ModelViewProcessor.kt | 68 ++++++----- .../java/com/airbnb/epoxy/ModelViewWriter.kt | 64 +++++----- .../kotlinsample/models/ItemCustomView.kt | 62 +++++----- 14 files changed, 277 insertions(+), 326 deletions(-) create mode 100644 epoxy-adapter/src/main/java/com/airbnb/epoxy/OnModelVisibilityChangedListener.java create mode 100644 epoxy-adapter/src/main/java/com/airbnb/epoxy/OnModelVisibilityStateChangedListener.java create mode 100644 epoxy-annotations/src/main/java/com/airbnb/epoxy/OnVisibilityChanged.java delete mode 100644 epoxy-annotations/src/main/java/com/airbnb/epoxy/OnVisibilityEvent.java create mode 100644 epoxy-annotations/src/main/java/com/airbnb/epoxy/OnVisibilityStateChanged.java diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModel.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModel.java index 7a1c7bc64d..ae8cb10485 100755 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModel.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModel.java @@ -8,6 +8,7 @@ import android.view.ViewGroup; import com.airbnb.epoxy.EpoxyController.ModelInterceptorCallback; +import com.airbnb.epoxy.OnModelVisibilityStateChangedListener.VisibilityState; import java.util.List; @@ -155,19 +156,7 @@ public void bind(@NonNull T view, @NonNull EpoxyModel previouslyBoundModel) { public void unbind(@NonNull T view) { } - public void visibilityVisible(@NonNull T view) { - } - - public void visibilityFocusedVisible(@NonNull T view) { - } - - public void visibilityInvisible(@NonNull T view) { - } - - public void visibilityUnfocusedVisible(@NonNull T view) { - } - - public void visibilityFullImpressionVisible(@NonNull T view) { + public void visibilityStateChanged(@VisibilityState int visibilityState, @NonNull T view) { } public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModelWithHolder.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModelWithHolder.java index 0a612f400b..5de19bec3b 100644 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModelWithHolder.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModelWithHolder.java @@ -2,6 +2,8 @@ import android.support.annotation.NonNull; +import com.airbnb.epoxy.OnModelVisibilityStateChangedListener.VisibilityState; + import java.util.List; /** @@ -40,30 +42,12 @@ public void unbind(@NonNull T holder) { super.unbind(holder); } - @Override - public void visibilityFocusedVisible(@NonNull T view) { - super.visibilityFocusedVisible(view); - } - - @Override - public void visibilityFullImpressionVisible(@NonNull T view) { - super.visibilityFullImpressionVisible(view); - } @Override - public void visibilityInvisible(@NonNull T view) { - super.visibilityInvisible(view); + public void visibilityStateChanged(@VisibilityState int visibilityState, @NonNull T view) { + super.visibilityStateChanged(visibilityState, view); } - @Override - public void visibilityUnfocusedVisible(@NonNull T view) { - super.visibilityUnfocusedVisible(view); - } - - @Override - public void visibilityVisible(@NonNull T view) { - super.visibilityVisible(view); - } @Override public void visibilityChanged(float visibleHeight, float visibleWidth, int percentVisibleHeight, diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyViewHolder.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyViewHolder.java index 3d0b847a89..7f53e5c8a8 100755 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyViewHolder.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyViewHolder.java @@ -5,6 +5,7 @@ import android.support.v7.widget.RecyclerView; import android.view.View; +import com.airbnb.epoxy.OnModelVisibilityStateChangedListener.VisibilityState; import com.airbnb.epoxy.ViewHolderState.ViewState; import java.util.List; @@ -82,43 +83,20 @@ public void unbind() { payloads = null; } - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, - int visibleHeight, int visibleWidth) { - assertBound(); - // noinspection unchecked - epoxyModel.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, - visibleWidth, objectToBind()); - } - - public void visibilityVisible() { - assertBound(); - // noinspection unchecked - epoxyModel.visibilityVisible(objectToBind()); - } - - public void visibilityFocusedVisible() { + public void visibilityStateChanged(@VisibilityState int visibilityState) { assertBound(); // noinspection unchecked - epoxyModel.visibilityFocusedVisible(objectToBind()); + epoxyModel.visibilityStateChanged(visibilityState, objectToBind()); } - public void visibilityInvisible() { - assertBound(); - // noinspection unchecked - epoxyModel.visibilityInvisible(objectToBind()); - } - - public void visibilityUnfocusedVisible() { + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth) { assertBound(); // noinspection unchecked - epoxyModel.visibilityUnfocusedVisible(objectToBind()); + epoxyModel.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, + visibleWidth, objectToBind()); } - public void visibilityFullImpressionVisible() { - assertBound(); - // noinspection unchecked - epoxyModel.visibilityFullImpressionVisible(objectToBind()); - } public List getPayloads() { assertBound(); diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java index 7b82f8d16f..ca96befa36 100644 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java @@ -36,10 +36,9 @@ class EpoxyVisibilityItem { /** * Update the visibility item according the current layout. * - * @param view the current {@link com.airbnb.epoxy.EpoxyViewHolder}'s itemView - * @param parent the {@link android.support.v7.widget.RecyclerView} + * @param view the current {@link com.airbnb.epoxy.EpoxyViewHolder}'s itemView + * @param parent the {@link android.support.v7.widget.RecyclerView} * @param orientation the {@link android.support.v7.widget.LinearLayoutManager}'s orientation - * * @return true if the view has been measured */ boolean update(@NonNull View view, @NonNull RecyclerView parent, int orientation) { @@ -77,31 +76,32 @@ void reset(int newAdapterPosition) { void handleVisible(@NonNull EpoxyViewHolder epoxyHolder) { if (!visible && isVisible()) { - epoxyHolder.visibilityVisible(); + epoxyHolder.visibilityStateChanged(OnModelVisibilityStateChangedListener.VISIBLE); } } void handleInvisible(EpoxyViewHolder epoxyHolder, boolean detachEvent) { if (visible && isInvisible(detachEvent)) { - epoxyHolder.visibilityInvisible(); + epoxyHolder.visibilityStateChanged(OnModelVisibilityStateChangedListener.INVISIBLE); } } void handleFocusedVisible(EpoxyViewHolder epoxyHolder) { if (!focusedVisible && isFocusedVisible()) { - epoxyHolder.visibilityFocusedVisible(); + epoxyHolder.visibilityStateChanged(OnModelVisibilityStateChangedListener.FOCUSED_VISIBLE); } } void handleUnfocusedVisible(EpoxyViewHolder epoxyHolder) { if (focusedVisible && isUnfocusedVisible()) { - epoxyHolder.visibilityUnfocusedVisible(); + epoxyHolder.visibilityStateChanged(OnModelVisibilityStateChangedListener.UNFOCUSED_VISIBLE); } } void handleFullImpressionVisible(EpoxyViewHolder epoxyHolder) { if (!fullyVisible && isFullImpressionVisible()) { - epoxyHolder.visibilityFullImpressionVisible(); + epoxyHolder + .visibilityStateChanged(OnModelVisibilityStateChangedListener.FULL_IMPRESSION_VISIBLE); } } diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/OnModelVisibilityChangedListener.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/OnModelVisibilityChangedListener.java new file mode 100644 index 0000000000..88d870325e --- /dev/null +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/OnModelVisibilityChangedListener.java @@ -0,0 +1,25 @@ +package com.airbnb.epoxy; + +import android.support.annotation.Px; + +/** Used to register an onVisibilityChanged callback with a generated model. */ +public interface OnModelVisibilityChangedListener, V> { + + /** + * This will be called once the view port changed. + * + * OnModelVisibilityChangedListener should be used with particular care since they will be + * dispatched on every frame while scrolling. No heavy work should be done inside the + * implementation. Using {@link OnModelVisibilityStateChangedListener} is recommended whenever + * possible. + * + * @param model The model being bound + * @param view The view that is being bound to the model + * @param percentHeightVisible The percentage of height visible + * @param percentWidthVisible The percentage of width visible + * @param heightVisible The visible height in pixel + * @param widthVisible The visible width in pixel + */ + void onVisibilityChanged(T model, V view, float percentHeightVisible, float percentWidthVisible, + @Px int heightVisible, @Px int widthVisible); +} diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/OnModelVisibilityStateChangedListener.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/OnModelVisibilityStateChangedListener.java new file mode 100644 index 0000000000..91cfa54516 --- /dev/null +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/OnModelVisibilityStateChangedListener.java @@ -0,0 +1,58 @@ +package com.airbnb.epoxy; + +import android.support.annotation.IntDef; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** Used to register an onVisibilityChanged callback with a generated model. */ +public interface OnModelVisibilityStateChangedListener, V> { + + @Retention(RetentionPolicy.SOURCE) + @IntDef({VISIBLE, INVISIBLE, FOCUSED_VISIBLE, UNFOCUSED_VISIBLE, FULL_IMPRESSION_VISIBLE}) + @interface VisibilityState { + } + + /** + * Event triggered when a Component enters the Visible Range. This happens when at least a pixel + * of the Component is visible. + */ + int VISIBLE = 0; + + /** + * Event triggered when a Component becomes invisible. This is the same with exiting the Visible + * Range, the Focused Range and the Full Impression Range. All the code that needs to be executed + * when a component leaves any of these ranges should be written in the handler for this event. + */ + int INVISIBLE = 1; + + /** + * Event triggered when a Component enters the Focused Range. This happens when either the + * Component occupies at least half of the viewport or, if the Component is smaller than half of + * the viewport, when the it is fully visible. + */ + int FOCUSED_VISIBLE = 2; + + /** + * Event triggered when a Component exits the Focused Range. The Focused Range is defined as at + * least half of the viewport or, if the Component is smaller than half of the viewport, when the + * it is fully visible. + */ + int UNFOCUSED_VISIBLE = 3; + + /** + * Event triggered when a Component enters the Full Impression Range. This happens, for instance + * in the case of a vertical RecyclerView, when both the top and bottom edges of the component + * become visible. + */ + int FULL_IMPRESSION_VISIBLE = 4; + + /** + * This will be called once the visibility changed. + * + * @param model The model being bound + * @param view The view that is being bound to the model + * @param visibilityState The new visibility + */ + void onVisibilityStateChanged(T model, V view, @VisibilityState int visibilityState); +} diff --git a/epoxy-annotations/src/main/java/com/airbnb/epoxy/OnVisibilityChanged.java b/epoxy-annotations/src/main/java/com/airbnb/epoxy/OnVisibilityChanged.java new file mode 100644 index 0000000000..2789982ad1 --- /dev/null +++ b/epoxy-annotations/src/main/java/com/airbnb/epoxy/OnVisibilityChanged.java @@ -0,0 +1,18 @@ +package com.airbnb.epoxy; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * This can be used to annotate methods inside classes with a {@link ModelView} annotation. Methods + * with this annotation will be called when the viewport is + * changed. + * + * Inspired from Litho : https://fblitho.com/docs/visibility-handling + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.CLASS) +public @interface OnVisibilityChanged { +} diff --git a/epoxy-annotations/src/main/java/com/airbnb/epoxy/OnVisibilityEvent.java b/epoxy-annotations/src/main/java/com/airbnb/epoxy/OnVisibilityEvent.java deleted file mode 100644 index a27da19eb3..0000000000 --- a/epoxy-annotations/src/main/java/com/airbnb/epoxy/OnVisibilityEvent.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.airbnb.epoxy; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * This can be used to annotate methods inside classes with a {@link ModelView} - * annotation. Methods with this annotation will be called when the viewport is - * changed. - * - * Inspired from Litho : https://fblitho.com/docs/visibility-handling - */ -@Target(ElementType.METHOD) -@Retention(RetentionPolicy.CLASS) -public @interface OnVisibilityEvent { - enum Event { - /** - * Event triggered when a Component enters the Visible Range. This happens - * when at least a pixel of the Component is visible. - */ - Visible, - /** - * Event triggered when a Component becomes invisible. This is the same with - * exiting the Visible Range, the Focused Range and the Full Impression - * Range. All the code that needs to be executed when a component leaves - * any of these ranges should be written in the handler for this event. - */ - Invisible, - /** - * Event triggered when a Component enters the Focused Range. This happens - * when either the Component occupies at least half of the viewport or, - * if the Component is smaller than half of the viewport, when the it is - * fully visible. - */ - FocusedVisible, - /** - * Event triggered when a Component exits the Focused Range. The Focused - * Range is defined as at least half of the viewport or, if the Component is - * smaller than half of the viewport, when the it is fully visible. - */ - UnfocusedVisible, - /** - * Event triggered when a Component enters the Full Impression Range. This - * happens, for instance in the case of a vertical RecyclerView, when both - * the top and bottom edges of the component become visible. - */ - FullImpressionVisible, - /** - * Event triggered when the visible rect of a Component changes. - * - * VisibilityChangedEvents should be used with particular care since they - * will be dispatched on every frame while scrolling. No heavy work should - * be done inside the VisibilityChangedEvents handlers. Visible, Invisible, - * Focused, Unfocused and Full Impression events are the recommended over - * VisibilityChanged events whenever possible. - */ - Changed, - } - - Event value() default Event.Changed; -} diff --git a/epoxy-annotations/src/main/java/com/airbnb/epoxy/OnVisibilityStateChanged.java b/epoxy-annotations/src/main/java/com/airbnb/epoxy/OnVisibilityStateChanged.java new file mode 100644 index 0000000000..47ba058bce --- /dev/null +++ b/epoxy-annotations/src/main/java/com/airbnb/epoxy/OnVisibilityStateChanged.java @@ -0,0 +1,20 @@ +package com.airbnb.epoxy; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * This can be used to annotate methods inside classes with a {@link ModelView} annotation. Methods + * with this annotation will be called when the visibility state is changed. + * + * Possible States are declared in {@link com.airbnb.epoxy.OnModelVisibilityStateChangedListener}. + * + * Inspired from Litho: https://fblitho.com/docs/visibility-handling + */ +@SuppressWarnings("JavadocReference") +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.CLASS) +public @interface OnVisibilityStateChanged { +} diff --git a/epoxy-processor/src/main/java/com/airbnb/epoxy/GeneratedModelWriter.kt b/epoxy-processor/src/main/java/com/airbnb/epoxy/GeneratedModelWriter.kt index a5a45365b5..efd91609a8 100644 --- a/epoxy-processor/src/main/java/com/airbnb/epoxy/GeneratedModelWriter.kt +++ b/epoxy-processor/src/main/java/com/airbnb/epoxy/GeneratedModelWriter.kt @@ -78,10 +78,18 @@ internal class GeneratedModelWriter( } - open fun addToVisibilityMethod( + /** Opportunity to add additional code to the visibilityStateChanged method. */ + open fun addToVisibilityStateChangedMethod( visibilityBuilder: Builder, - visibilityParamName: String, - event: OnVisibilityEvent.Event + visibilityParamName: String + ) { + + } + + /** Opportunity to add additional code to the visibilityChanged method. */ + open fun addToVisibilityChangedMethod( + visibilityBuilder: MethodSpec.Builder, + visibilityParamName: String ) { } @@ -446,29 +454,12 @@ internal class GeneratedModelWriter( private fun generateVisibilityMethods(modelInfo: GeneratedModelInfo): Iterable { val methods = ArrayList() + val boundObjectParam = ParameterSpec.builder(modelInfo.modelType, "object", FINAL).build() - if (modelInfo is ModelViewInfo) { - with(modelInfo.visibilityMethodNamesMap) { - if (containsKey(OnVisibilityEvent.Event.Visible)) { - methods.add(buildVisibilityVisibleMethod(boundObjectParam)) - } - if (containsKey(OnVisibilityEvent.Event.Invisible)) { - methods.add(buildVisibilityInvisibleMethod(boundObjectParam)) - } - if (containsKey(OnVisibilityEvent.Event.FocusedVisible)) { - methods.add(buildVisibilityFocusedVisibleMethod(boundObjectParam)) - } - if (containsKey(OnVisibilityEvent.Event.UnfocusedVisible)) { - methods.add(buildVisibilityUnfocusedVisibleMethod(boundObjectParam)) - } - if (containsKey(OnVisibilityEvent.Event.FullImpressionVisible)) { - methods.add(buildVisibilityFullImpressionVisibleMethod(boundObjectParam)) - } - if (containsKey(OnVisibilityEvent.Event.Changed)) { - methods.add(buildVisibilityChangedMethod(boundObjectParam)) - } - } - } + + methods.add(buildVisibilityStateChangedMethod(boundObjectParam)) + methods.add(buildVisibilityChangedMethod(boundObjectParam)) + return methods } @@ -618,74 +609,20 @@ internal class GeneratedModelWriter( builderHooks?.addToBindMethod(this, boundObjectParam) } - private fun buildVisibilityVisibleMethod( - boundObjectParam: ParameterSpec - ) = buildMethod("visibilityVisible") { - addAnnotation(Override::class.java) - addModifiers(PUBLIC) - addParameter(boundObjectParam) - builderHooks?.addToVisibilityMethod( - this, boundObjectParam.name, OnVisibilityEvent.Event.Visible - ) - - addStatement("super.visibilityVisible(\$L)", boundObjectParam.name) - } - - private fun buildVisibilityUnfocusedVisibleMethod( + private fun buildVisibilityStateChangedMethod( boundObjectParam: ParameterSpec - ) = buildMethod("visibilityUnfocusedVisible") { + ) = buildMethod("visibilityStateChanged") { addAnnotation(Override::class.java) addModifiers(PUBLIC) + addParameter(TypeName.INT, "visibilityState") addParameter(boundObjectParam) - builderHooks?.addToVisibilityMethod( - this, boundObjectParam.name, OnVisibilityEvent.Event.UnfocusedVisible - ) - - addStatement("super.visibilityUnfocusedVisible(\$L)", boundObjectParam.name) - } + builderHooks?.addToVisibilityStateChangedMethod(this, boundObjectParam.name) - private fun buildVisibilityFocusedVisibleMethod( - boundObjectParam: ParameterSpec - ) = buildMethod("visibilityFocusedVisible") { - addAnnotation(Override::class.java) - addModifiers(PUBLIC) - addParameter(boundObjectParam) - - builderHooks?.addToVisibilityMethod( - this, boundObjectParam.name, OnVisibilityEvent.Event.FocusedVisible - ) - - addStatement("super.visibilityFocusedVisible(\$L)", boundObjectParam.name) - } - - private fun buildVisibilityInvisibleMethod( - boundObjectParam: ParameterSpec - ) = buildMethod("visibilityInvisible") { - addAnnotation(Override::class.java) - addModifiers(PUBLIC) - addParameter(boundObjectParam) - - builderHooks?.addToVisibilityMethod( - this, boundObjectParam.name, OnVisibilityEvent.Event.Invisible - ) - - addStatement("super.visibilityInvisible(\$L)", boundObjectParam.name) - } - - private fun buildVisibilityFullImpressionVisibleMethod( - boundObjectParam: ParameterSpec - ) = buildMethod("visibilityFullImpressionVisible") { - addAnnotation(Override::class.java) - addModifiers(PUBLIC) - addParameter(boundObjectParam) - - builderHooks?.addToVisibilityMethod( - this, boundObjectParam.name, OnVisibilityEvent.Event.FullImpressionVisible + addStatement( + "super.visibilityStateChanged(\$L, \$L)", "visibilityState", boundObjectParam.name ) - - addStatement("super.visibilityFullImpressionVisible(\$L)", boundObjectParam.name) } private fun buildVisibilityChangedMethod( @@ -699,9 +636,7 @@ internal class GeneratedModelWriter( addParameter(TypeName.INT, "visibleWidth") addParameter(boundObjectParam) - builderHooks?.addToVisibilityMethod( - this, boundObjectParam.name, OnVisibilityEvent.Event.Changed - ) + builderHooks?.addToVisibilityChangedMethod(this, boundObjectParam.name) addStatement( "super.visibilityChanged(\$L, \$L, \$L, \$L, \$L)", "percentVisibleHeight", diff --git a/epoxy-processor/src/main/java/com/airbnb/epoxy/ModelViewInfo.kt b/epoxy-processor/src/main/java/com/airbnb/epoxy/ModelViewInfo.kt index 4fd127caf0..355b512840 100644 --- a/epoxy-processor/src/main/java/com/airbnb/epoxy/ModelViewInfo.kt +++ b/epoxy-processor/src/main/java/com/airbnb/epoxy/ModelViewInfo.kt @@ -23,7 +23,8 @@ internal class ModelViewInfo( private val resourceProcessor: ResourceProcessor ) : GeneratedModelInfo() { val resetMethodNames = mutableListOf() - val visibilityMethodNamesMap = mutableMapOf>() + val visibilityStateChangedMethodNames = mutableListOf() + val visibilityChangedMethodNames = mutableListOf() val afterPropsSetMethodNames = mutableListOf() val saveViewState: Boolean private val viewAnnotation: ModelView = viewElement.getAnnotation(ModelView::class.java) @@ -200,17 +201,17 @@ internal class ModelViewInfo( } } - fun addOnVisibilityChangedMethodIfNotExists( - visibilityMethod: Element, - event: OnVisibilityEvent.Event - ) { + fun addOnVisibilityStateChangedMethodIfNotExists(visibilityMethod: Element) { val methodName = visibilityMethod.simpleName.toString() - val list = - visibilityMethodNamesMap[event] ?: mutableListOf().apply { - visibilityMethodNamesMap[event] = this - } - if (!list.contains(methodName)) { - list.add(methodName) + if (!visibilityStateChangedMethodNames.contains(methodName)) { + visibilityStateChangedMethodNames.add(methodName) + } + } + + fun addOnVisibilityChangedMethodIfNotExists(visibilityMethod: Element) { + val methodName = visibilityMethod.simpleName.toString() + if (!visibilityChangedMethodNames.contains(methodName)) { + visibilityChangedMethodNames.add(methodName) } } diff --git a/epoxy-processor/src/main/java/com/airbnb/epoxy/ModelViewProcessor.kt b/epoxy-processor/src/main/java/com/airbnb/epoxy/ModelViewProcessor.kt index 79bf18ecc2..3dec1ce797 100644 --- a/epoxy-processor/src/main/java/com/airbnb/epoxy/ModelViewProcessor.kt +++ b/epoxy-processor/src/main/java/com/airbnb/epoxy/ModelViewProcessor.kt @@ -44,7 +44,8 @@ internal class ModelViewProcessor( processSetterAnnotations(roundEnv) processResetAnnotations(roundEnv) - processVisibilityAnnotations(roundEnv) + processVisibilityStateChangedAnnotations(roundEnv) + processVisibilityChangedAnnotations(roundEnv) processAfterBindAnnotations(roundEnv) updateViewsForInheritedViewAnnotations() @@ -260,26 +261,38 @@ internal class ModelViewProcessor( } } - private fun processVisibilityAnnotations(roundEnv: RoundEnvironment) { - for (visibilityMethod in roundEnv.getElementsAnnotatedWith(OnVisibilityEvent::class.java)) { - val value = visibilityMethod.getAnnotation(OnVisibilityEvent::class.java).value - if (!validateVisibilityElement(visibilityMethod, value)) { + private fun processVisibilityStateChangedAnnotations(roundEnv: RoundEnvironment) { + for (visibilityMethod in roundEnv.getElementsAnnotatedWith(OnVisibilityStateChanged::class.java)) { + if (!validateVisibilityStateChangedElement(visibilityMethod)) { continue } val info = getModelInfoForPropElement(visibilityMethod) if (info == null) { - errorLogger.logError( - "%s annotation can only be used in classes annotated with %s", - OnVisibilityEvent::class.java, ModelView::class.java - ) + errorLogger.logError("%s annotation can only be used in classes annotated with %s", + OnVisibilityStateChanged::class.java, ModelView::class.java) continue } - info.addOnVisibilityChangedMethodIfNotExists( - visibilityMethod as ExecutableElement, - value - ) + info.addOnVisibilityStateChangedMethodIfNotExists(visibilityMethod as ExecutableElement) + } + } + + + private fun processVisibilityChangedAnnotations(roundEnv: RoundEnvironment) { + for (visibilityMethod in roundEnv.getElementsAnnotatedWith(OnVisibilityChanged::class.java)) { + if (!validateVisibilityChangedElement(visibilityMethod)) { + continue + } + + val info = getModelInfoForPropElement(visibilityMethod) + if (info == null) { + errorLogger.logError("%s annotation can only be used in classes annotated with %s", + OnVisibilityChanged::class.java, ModelView::class.java) + continue + } + + info.addOnVisibilityChangedMethodIfNotExists(visibilityMethod as ExecutableElement) } } @@ -348,9 +361,12 @@ internal class ModelViewProcessor( view.addOnRecycleMethodIfNotExists(it) } - forEachElementWithAnnotation(listOf(OnVisibilityEvent::class.java)) { - view.addOnVisibilityChangedMethodIfNotExists(it, it.getAnnotation( - OnVisibilityEvent::class.java).value) + forEachElementWithAnnotation(listOf(OnVisibilityStateChanged::class.java)) { + view.addOnVisibilityStateChangedMethodIfNotExists(it) + } + + forEachElementWithAnnotation(listOf(OnVisibilityChanged::class.java)) { + view.addOnVisibilityChangedMethodIfNotExists(it) } forEachElementWithAnnotation(listOf(AfterPropsSet::class.java)) { @@ -394,21 +410,11 @@ internal class ModelViewProcessor( private fun validateResetElement(resetMethod: Element): Boolean = validateExecutableElement(resetMethod, OnViewRecycled::class.java, 0) - private fun validateVisibilityElement( - visibilityMethod: Element, - event: OnVisibilityEvent.Event - ): Boolean = when (event) { - OnVisibilityEvent.Event.Changed -> validateExecutableElement( - visibilityMethod, - OnVisibilityEvent::class.java, - 4 - ) - else -> validateExecutableElement( - visibilityMethod, - OnVisibilityEvent::class.java, - 0 - ) - } + private fun validateVisibilityStateChangedElement(visibilityMethod: Element): Boolean = + validateExecutableElement(visibilityMethod, OnVisibilityStateChanged::class.java, 1) + + private fun validateVisibilityChangedElement(visibilityMethod: Element): Boolean = + validateExecutableElement(visibilityMethod, OnVisibilityChanged::class.java, 4) private fun writeJava() { val modelsToWrite = mutableListOf() diff --git a/epoxy-processor/src/main/java/com/airbnb/epoxy/ModelViewWriter.kt b/epoxy-processor/src/main/java/com/airbnb/epoxy/ModelViewWriter.kt index c2a90958c4..bef6222f40 100644 --- a/epoxy-processor/src/main/java/com/airbnb/epoxy/ModelViewWriter.kt +++ b/epoxy-processor/src/main/java/com/airbnb/epoxy/ModelViewWriter.kt @@ -204,15 +204,23 @@ internal class ModelViewWriter( unbindParamName) } - override fun addToVisibilityMethod( + override fun addToVisibilityStateChangedMethod( visibilityBuilder: MethodSpec.Builder, - visibilityParamName: String, - event: OnVisibilityEvent.Event + visibilityParamName: String ) { - addVisibilityMethodsToBuilder(visibilityBuilder, - modelInfo, - visibilityParamName, - event + addVisibilityStateChangedMethodsToBuilder(visibilityBuilder, + modelInfo, + visibilityParamName + ) + } + + override fun addToVisibilityChangedMethod( + visibilityBuilder: MethodSpec.Builder, + visibilityParamName: String + ) { + addVisibilityChangedMethodsToBuilder(visibilityBuilder, + modelInfo, + visibilityParamName ) } @@ -283,40 +291,32 @@ internal class ModelViewWriter( } private fun addResetMethodsToBuilder( - builder: MethodSpec.Builder, - modelViewInfo: ModelViewInfo, - unbindParamName: String + builder: MethodSpec.Builder, + modelViewInfo: ModelViewInfo, + unbindParamName: String ) { for (methodName in modelViewInfo.resetMethodNames) { builder.addStatement("$unbindParamName.$methodName()") } } - private fun addVisibilityMethodsToBuilder( + private fun addVisibilityStateChangedMethodsToBuilder( builder: MethodSpec.Builder, modelViewInfo: ModelViewInfo, - unbindParamName: String, - event: OnVisibilityEvent.Event + visibilityParamName: String ) { - modelViewInfo.visibilityMethodNamesMap[event]?.let { visibilityMethodNames -> - for (methodName in visibilityMethodNames) { - when (event) { - OnVisibilityEvent.Event.Visible -> - builder.addStatement("$unbindParamName.$methodName()") - OnVisibilityEvent.Event.Invisible -> - builder.addStatement("$unbindParamName.$methodName()") - OnVisibilityEvent.Event.UnfocusedVisible -> - builder.addStatement("$unbindParamName.$methodName()") - OnVisibilityEvent.Event.FocusedVisible -> - builder.addStatement("$unbindParamName.$methodName()") - OnVisibilityEvent.Event.FullImpressionVisible -> - builder.addStatement("$unbindParamName.$methodName()") - OnVisibilityEvent.Event.Changed -> - builder.addStatement( - "$unbindParamName.$methodName(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth)" - ) - } - } + for (methodName in modelViewInfo.visibilityStateChangedMethodNames) { + builder.addStatement("$visibilityParamName.$methodName(visibilityState)") + } + } + + private fun addVisibilityChangedMethodsToBuilder( + builder: MethodSpec.Builder, + modelViewInfo: ModelViewInfo, + visibilityParamName: String + ) { + for (methodName in modelViewInfo.visibilityChangedMethodNames) { + builder.addStatement("$visibilityParamName.$methodName(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth)") } } diff --git a/kotlinsample/src/main/java/com/airbnb/epoxy/kotlinsample/models/ItemCustomView.kt b/kotlinsample/src/main/java/com/airbnb/epoxy/kotlinsample/models/ItemCustomView.kt index e0ab60db2e..69addb9280 100644 --- a/kotlinsample/src/main/java/com/airbnb/epoxy/kotlinsample/models/ItemCustomView.kt +++ b/kotlinsample/src/main/java/com/airbnb/epoxy/kotlinsample/models/ItemCustomView.kt @@ -11,8 +11,10 @@ import com.airbnb.epoxy.AfterPropsSet import com.airbnb.epoxy.CallbackProp import com.airbnb.epoxy.ModelProp import com.airbnb.epoxy.ModelView +import com.airbnb.epoxy.OnModelVisibilityStateChangedListener import com.airbnb.epoxy.OnViewRecycled -import com.airbnb.epoxy.OnVisibilityEvent +import com.airbnb.epoxy.OnVisibilityChanged +import com.airbnb.epoxy.OnVisibilityStateChanged import com.airbnb.epoxy.TextProp import com.airbnb.epoxy.kotlinsample.R @@ -60,38 +62,36 @@ class ItemCustomView @JvmOverloads constructor( textView.setOnClickListener(listener) } - @OnVisibilityEvent(OnVisibilityEvent.Event.Visible) - fun onVisible() { - Log.d(TAG, "$title Visible") - onVisibilityEventDrawable.visible = true - } - - @OnVisibilityEvent(OnVisibilityEvent.Event.Invisible) - fun onInvisible() { - Log.d(TAG, "$title Invisible") - onVisibilityEventDrawable.visible = false - } - - @OnVisibilityEvent(OnVisibilityEvent.Event.FocusedVisible) - fun onFocusedVisible() { - Log.d(TAG, "$title FocusedVisible") - onVisibilityEventDrawable.focusedVisible = true - } - - @OnVisibilityEvent(OnVisibilityEvent.Event.UnfocusedVisible) - fun onUnfocusedVisible() { - Log.d(TAG, "$title UnfocusedVisible") - onVisibilityEventDrawable.focusedVisible = false - } - - @OnVisibilityEvent(OnVisibilityEvent.Event.FullImpressionVisible) - fun onFullImpressionVisible() { - Log.d(TAG, "$title FullImpressionVisible") - onVisibilityEventDrawable.fullImpression = true + @OnVisibilityStateChanged + fun onVisibilityStateChanged( + @OnModelVisibilityStateChangedListener.VisibilityState visibilityState: Int + ) { + when (visibilityState) { + OnModelVisibilityStateChangedListener.VISIBLE -> { + Log.d(TAG, "$title Visible") + onVisibilityEventDrawable.visible = true + } + OnModelVisibilityStateChangedListener.INVISIBLE -> { + Log.d(TAG, "$title Invisible") + onVisibilityEventDrawable.visible = false + } + OnModelVisibilityStateChangedListener.FOCUSED_VISIBLE -> { + Log.d(TAG, "$title FocusedVisible") + onVisibilityEventDrawable.focusedVisible = true + } + OnModelVisibilityStateChangedListener.UNFOCUSED_VISIBLE -> { + Log.d(TAG, "$title UnfocusedVisible") + onVisibilityEventDrawable.focusedVisible = false + } + OnModelVisibilityStateChangedListener.FULL_IMPRESSION_VISIBLE -> { + Log.d(TAG, "$title FullImpressionVisible") + onVisibilityEventDrawable.fullImpression = true + } + } } - @OnVisibilityEvent(OnVisibilityEvent.Event.Changed) - fun onChanged( + @OnVisibilityChanged + fun onVisibilityChanged( percentVisibleHeight: Float, percentVisibleWidth: Float, visibleHeight: Int, From 625b76d45926a41d322d5669fcce1a6255013d1c Mon Sep 17 00:00:00 2001 From: Emmanuel Boudrant Date: Thu, 4 Oct 2018 13:11:05 -0700 Subject: [PATCH 08/38] Add the visibility listener to the model code generation --- .../com/airbnb/epoxy/GeneratedModelWriter.kt | 160 ++++++++++++++++-- .../src/main/java/com/airbnb/epoxy/Utils.java | 2 + .../airbnb/epoxy/kotlinsample/MainActivity.kt | 9 + 3 files changed, 160 insertions(+), 11 deletions(-) diff --git a/epoxy-processor/src/main/java/com/airbnb/epoxy/GeneratedModelWriter.kt b/epoxy-processor/src/main/java/com/airbnb/epoxy/GeneratedModelWriter.kt index efd91609a8..5d8abf3031 100644 --- a/epoxy-processor/src/main/java/com/airbnb/epoxy/GeneratedModelWriter.kt +++ b/epoxy-processor/src/main/java/com/airbnb/epoxy/GeneratedModelWriter.kt @@ -11,6 +11,8 @@ import com.airbnb.epoxy.Utils.MODEL_CLICK_LISTENER_TYPE import com.airbnb.epoxy.Utils.MODEL_LONG_CLICK_LISTENER_TYPE import com.airbnb.epoxy.Utils.ON_BIND_MODEL_LISTENER_TYPE import com.airbnb.epoxy.Utils.ON_UNBIND_MODEL_LISTENER_TYPE +import com.airbnb.epoxy.Utils.ON_VISIBILITY_MODEL_LISTENER_TYPE +import com.airbnb.epoxy.Utils.ON_VISIBILITY_STATE_MODEL_LISTENER_TYPE import com.airbnb.epoxy.Utils.UNTYPED_EPOXY_MODEL_TYPE import com.airbnb.epoxy.Utils.WRAPPED_LISTENER_TYPE import com.airbnb.epoxy.Utils.getClassName @@ -299,6 +301,30 @@ internal class GeneratedModelWriter( ).build() ) + val onVisibilityStateChangedListenerType = ParameterizedTypeName.get( + getClassName(ON_VISIBILITY_STATE_MODEL_LISTENER_TYPE), + classInfo.parameterizedGeneratedName, + classInfo.modelType + ) + fields.add( + FieldSpec.builder( + onVisibilityStateChangedListenerType, modelVisibilityStateChangedListenerFieldName(), + PRIVATE + ).build() + ) + + val onVisibilityChangedListenerType = ParameterizedTypeName.get( + getClassName(ON_VISIBILITY_MODEL_LISTENER_TYPE), + classInfo.parameterizedGeneratedName, + classInfo.modelType + ) + fields.add( + FieldSpec.builder( + onVisibilityChangedListenerType, modelVisibilityChangedListenerFieldName(), + PRIVATE + ).build() + ) + classInfo.getAttributeInfo() .filter { it.isGenerated } .mapTo(fields) { @@ -325,6 +351,12 @@ internal class GeneratedModelWriter( private fun modelBindListenerFieldName(): String = "onModelBoundListener$GENERATED_FIELD_SUFFIX" + private fun modelVisibilityStateChangedListenerFieldName(): String = + "onModelVisibilityStateChangedListener$GENERATED_FIELD_SUFFIX" + + private fun modelVisibilityChangedListenerFieldName(): String = + "onModelVisibilityChangedListener$GENERATED_FIELD_SUFFIX" + private fun getModelClickListenerType(classInfo: GeneratedModelInfo): ParameterizedTypeName { return ParameterizedTypeName.get( getClassName(MODEL_CLICK_LISTENER_TYPE), @@ -455,10 +487,67 @@ internal class GeneratedModelWriter( private fun generateVisibilityMethods(modelInfo: GeneratedModelInfo): Iterable { val methods = ArrayList() - val boundObjectParam = ParameterSpec.builder(modelInfo.modelType, "object", FINAL).build() + val visibilityObjectParam = ParameterSpec.builder(modelInfo.modelType, "object", FINAL).build() + + methods.add(buildVisibilityStateChangedMethod(visibilityObjectParam)) + + val onVisibilityStateChangedListenerType = ParameterizedTypeName.get( + getClassName(ON_VISIBILITY_STATE_MODEL_LISTENER_TYPE), + modelInfo.parameterizedGeneratedName, + modelInfo.modelType + ) + val visibilityStateChangedListenerParam = ParameterSpec.builder(onVisibilityStateChangedListenerType, "listener").build() + + val onVisibilityStateChanged = MethodSpec.methodBuilder("onVisibilityStateChanged") + .addJavadoc( + "Register a listener that will be called when this model visibility state " + + "has changed.\n" + + "

\n" + + "The listener will contribute to this model's hashCode state per the {@link\n" + + "com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.\n" + + "

\n" + + "You may clear the listener by setting a null value, or by calling " + + "{@link #reset()}" + ) + .addModifiers(PUBLIC) + .returns(modelInfo.parameterizedGeneratedName) + + addOnMutationCall(onVisibilityStateChanged) + .addParameter(visibilityStateChangedListenerParam) + .addStatement("this.\$L = listener", modelVisibilityStateChangedListenerFieldName()) + .addStatement("return this") + + methods.add(onVisibilityStateChanged.build()) + + methods.add(buildVisibilityChangedMethod(visibilityObjectParam)) + + val onVisibilityChangedListenerType = ParameterizedTypeName.get( + getClassName(ON_VISIBILITY_MODEL_LISTENER_TYPE), + modelInfo.parameterizedGeneratedName, + modelInfo.modelType + ) + val visibilityChangedListenerParam = ParameterSpec.builder(onVisibilityChangedListenerType, "listener").build() + + val onVisibilityChanged = MethodSpec.methodBuilder("onVisibilityChanged") + .addJavadoc( + "Register a listener that will be called when this model visibility has " + + "changed.\n" + + "

\n" + + "The listener will contribute to this model's hashCode state per the {@link\n" + + "com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.\n" + + "

\n" + + "You may clear the listener by setting a null value, or by calling " + + "{@link #reset()}" + ) + .addModifiers(PUBLIC) + .returns(modelInfo.parameterizedGeneratedName) - methods.add(buildVisibilityStateChangedMethod(boundObjectParam)) - methods.add(buildVisibilityChangedMethod(boundObjectParam)) + addOnMutationCall(onVisibilityChanged) + .addParameter(visibilityChangedListenerParam) + .addStatement("this.\$L = listener", modelVisibilityChangedListenerFieldName()) + .addStatement("return this") + + methods.add(onVisibilityChanged.build()) return methods } @@ -611,22 +700,29 @@ internal class GeneratedModelWriter( private fun buildVisibilityStateChangedMethod( - boundObjectParam: ParameterSpec + visibilityStateParam: ParameterSpec ) = buildMethod("visibilityStateChanged") { addAnnotation(Override::class.java) addModifiers(PUBLIC) addParameter(TypeName.INT, "visibilityState") - addParameter(boundObjectParam) + addParameter(visibilityStateParam) + + beginControlFlow("if (\$L != null)", modelVisibilityStateChangedListenerFieldName()) + addStatement( + "\$L.onVisibilityStateChanged(this, object, visibilityState)", + modelVisibilityStateChangedListenerFieldName() + ) + endControlFlow() - builderHooks?.addToVisibilityStateChangedMethod(this, boundObjectParam.name) + builderHooks?.addToVisibilityStateChangedMethod(this, visibilityStateParam.name) addStatement( - "super.visibilityStateChanged(\$L, \$L)", "visibilityState", boundObjectParam.name + "super.visibilityStateChanged(\$L, \$L)", "visibilityState", visibilityStateParam.name ) } private fun buildVisibilityChangedMethod( - boundObjectParam: ParameterSpec + visibilityStateParam: ParameterSpec ) = buildMethod("visibilityChanged") { addAnnotation(Override::class.java) addModifiers(PUBLIC) @@ -634,13 +730,21 @@ internal class GeneratedModelWriter( addParameter(TypeName.FLOAT, "percentVisibleWidth") addParameter(TypeName.INT, "visibleHeight") addParameter(TypeName.INT, "visibleWidth") - addParameter(boundObjectParam) + addParameter(visibilityStateParam) + + beginControlFlow("if (\$L != null)", modelVisibilityChangedListenerFieldName()) + addStatement( + "\$L.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, " + + "visibleHeight, visibleWidth)", + modelVisibilityChangedListenerFieldName() + ) + endControlFlow() - builderHooks?.addToVisibilityChangedMethod(this, boundObjectParam.name) + builderHooks?.addToVisibilityChangedMethod(this, visibilityStateParam.name) addStatement( "super.visibilityChanged(\$L, \$L, \$L, \$L, \$L)", "percentVisibleHeight", - "percentVisibleWidth", "visibleHeight", "visibleWidth", boundObjectParam.name + "percentVisibleWidth", "visibleHeight", "visibleWidth", visibilityStateParam.name ) } @@ -1263,6 +1367,24 @@ internal class GeneratedModelWriter( addStatement("return false") endControlFlow() + startNotEqualsControlFlow( + this, + false, + getClassName(ON_VISIBILITY_STATE_MODEL_LISTENER_TYPE), + modelVisibilityStateChangedListenerFieldName() + ) + addStatement("return false") + endControlFlow() + + startNotEqualsControlFlow( + this, + false, + getClassName(ON_VISIBILITY_MODEL_LISTENER_TYPE), + modelVisibilityChangedListenerFieldName() + ) + addStatement("return false") + endControlFlow() + for (attributeInfo in helperClass.getAttributeInfo()) { val type = attributeInfo.typeName @@ -1298,6 +1420,20 @@ internal class GeneratedModelWriter( modelUnbindListenerFieldName() ) + addHashCodeLineForType( + this, + false, + getClassName(ON_VISIBILITY_STATE_MODEL_LISTENER_TYPE), + modelVisibilityStateChangedListenerFieldName() + ) + + addHashCodeLineForType( + this, + false, + getClassName(ON_VISIBILITY_MODEL_LISTENER_TYPE), + modelVisibilityChangedListenerFieldName() + ) + for (attributeInfo in helperClass.getAttributeInfo()) { if (!attributeInfo.useInHash) { continue @@ -1457,6 +1593,8 @@ internal class GeneratedModelWriter( returns(helperClass.parameterizedGeneratedName) addStatement("\$L = null", modelBindListenerFieldName()) addStatement("\$L = null", modelUnbindListenerFieldName()) + addStatement("\$L = null", modelVisibilityStateChangedListenerFieldName()) + addStatement("\$L = null", modelVisibilityChangedListenerFieldName()) if (shouldUseBitSet(helperClass)) { addStatement("\$L.clear()", ATTRIBUTES_BITSET_FIELD_NAME) diff --git a/epoxy-processor/src/main/java/com/airbnb/epoxy/Utils.java b/epoxy-processor/src/main/java/com/airbnb/epoxy/Utils.java index fc8556e2c5..6c072c2a9f 100644 --- a/epoxy-processor/src/main/java/com/airbnb/epoxy/Utils.java +++ b/epoxy-processor/src/main/java/com/airbnb/epoxy/Utils.java @@ -64,6 +64,8 @@ class Utils { static final String ON_UNBIND_MODEL_LISTENER_TYPE = "com.airbnb.epoxy.OnModelUnboundListener"; static final String WRAPPED_LISTENER_TYPE = "com.airbnb.epoxy.WrappedEpoxyModelClickListener"; static final String DATA_BINDING_MODEL_TYPE = "com.airbnb.epoxy.DataBindingEpoxyModel"; + static final String ON_VISIBILITY_STATE_MODEL_LISTENER_TYPE = "com.airbnb.epoxy.OnModelVisibilityStateChangedListener"; + static final String ON_VISIBILITY_MODEL_LISTENER_TYPE = "com.airbnb.epoxy.OnModelVisibilityChangedListener"; static void throwError(String msg, Object... args) throws EpoxyProcessorException { diff --git a/kotlinsample/src/main/java/com/airbnb/epoxy/kotlinsample/MainActivity.kt b/kotlinsample/src/main/java/com/airbnb/epoxy/kotlinsample/MainActivity.kt index 0820f1143b..862af53e66 100644 --- a/kotlinsample/src/main/java/com/airbnb/epoxy/kotlinsample/MainActivity.kt +++ b/kotlinsample/src/main/java/com/airbnb/epoxy/kotlinsample/MainActivity.kt @@ -3,9 +3,11 @@ package com.airbnb.epoxy.kotlinsample import android.graphics.Color import android.os.Bundle import android.support.v7.app.AppCompatActivity +import android.util.Log import android.widget.Toast import com.airbnb.epoxy.EpoxyController import com.airbnb.epoxy.EpoxyRecyclerView +import com.airbnb.epoxy.OnModelVisibilityStateChangedListener import com.airbnb.epoxy.kotlinsample.models.ItemDataClass import com.airbnb.epoxy.kotlinsample.models.itemCustomView import com.airbnb.epoxy.kotlinsample.models.itemEpoxyHolder @@ -29,6 +31,9 @@ class MainActivity : AppCompatActivity() { onClick { _ -> Toast.makeText(this@MainActivity, "clicked", Toast.LENGTH_LONG).show() } + onVisibilityStateChanged { model, view, visibilityState -> + Log.d(TAG, "$model -> $visibilityState") + } } itemCustomView { @@ -56,6 +61,10 @@ class MainActivity : AppCompatActivity() { } } } + + companion object { + private const val TAG = "MainActivity" + } } fun EpoxyRecyclerView.withModels(buildModelsCallback: EpoxyController.() -> Unit) { From a080b5163256cc9af17d47edf73eca2231370dcf Mon Sep 17 00:00:00 2001 From: Emmanuel Boudrant Date: Thu, 4 Oct 2018 13:14:23 -0700 Subject: [PATCH 09/38] Update test resources (not sure why but the ruby script reformatted some non-related lines) --- .../resources/AllTypesModelViewModel_.java | 74 +++++++++++- .../test/resources/BaseModelViewModel_.java | 65 ++++++++++- .../resources/BasicModelWithAttribute_.java | 68 ++++++++++- .../BasicModelWithFinalAttribute_.java | 68 ++++++++++- .../CallbackPropModelViewModel_.java | 74 +++++++++++- ...AttributeDifferentNameModelViewModel_.java | 93 +++++++++++++-- ...ortedAttributeSameNameModelViewModel_.java | 79 ++++++++++++- ...ngleSupportedAttributeModelViewModel_.java | 70 +++++++++++- .../resources/ListSubtypeModelViewModel_.java | 68 ++++++++++- .../resources/StyleableModelViewModel_.java | 71 +++++++++++- .../resources/TextPropModelViewModel_.java | 68 ++++++++++- .../src/main/java/com/airbnb/epoxy/Utils.java | 6 +- .../resources/AbstractModelWithHolder_.java | 69 ++++++++++- .../AutoLayoutModelViewMatchParentModel_.java | 69 ++++++++++- .../resources/AutoLayoutModelViewModel_.java | 68 ++++++++++- .../BaseModelFromPackageConfigViewModel_.java | 65 ++++++++++- ...ModelOverridesPackageConfigViewModel_.java | 65 ++++++++++- .../test/resources/BaseModelViewModel_.java | 65 ++++++++++- .../BaseModelViewWithSuperDiffBindModel_.java | 65 ++++++++++- .../BaseModelWithAttributeViewModel_.java | 65 ++++++++++- .../resources/BasicModelWithAttribute_.java | 68 ++++++++++- .../CustomPackageLayoutPatternViewModel_.java | 69 ++++++++++- ...ngModelWithAllFieldTypesNoValidation_.java | 78 ++++++++++++- .../DataBindingModelWithAllFieldTypes_.java | 69 ++++++++++- ...DefaultPackageLayoutPatternViewModel_.java | 69 ++++++++++- .../test/resources/DoNotHashViewModel_.java | 68 ++++++++++- .../EpoxyModelGroupWithAnnotations_.java | 68 ++++++++++- ...ayoutMethodNextParentLayout$NoLayout_.java | 68 ++++++++++- ...MethodNextParentLayout$StillNoLayout_.java | 71 +++++++++++- ...outMethodNextParentLayout$WithLayout_.java | 68 ++++++++++- ...ultLayoutMethodParentLayout$NoLayout_.java | 68 ++++++++++- ...tLayoutMethodParentLayout$WithLayout_.java | 68 ++++++++++- .../GenerateDefaultLayoutMethod_.java | 68 ++++++++++- .../GeneratedModelSuffixViewSuffix_.java | 68 ++++++++++- .../resources/GridSpanCountViewModel_.java | 68 ++++++++++- .../IgnoreRequireHashCodeViewModel_.java | 74 +++++++++++- .../resources/LayoutOverloadsViewModel_.java | 68 ++++++++++- .../src/test/resources/ModelDoNotHash_.java | 59 ++++++++++ .../resources/ModelDoNotUseInToString_.java | 68 ++++++++++- .../resources/ModelForRProcessingTest_.java | 68 ++++++++++- .../ModelForTestingDuplicateRValues_.java | 68 ++++++++++- .../test/resources/ModelNoValidation_.java | 59 ++++++++++ .../ModelReturningClassTypeWithVarargs_.java | 68 ++++++++++- .../resources/ModelReturningClassType_.java | 68 ++++++++++- .../ModelViewExtendingSuperClassModel_.java | 69 ++++++++++- .../resources/ModelViewSuperClassModel_.java | 68 ++++++++++- .../resources/ModelViewWithParisModel_.java | 71 +++++++++++- .../ModelWithAbstractClassAndAnnotation_.java | 68 ++++++++++- .../ModelWithAllFieldTypesBuilder.java | 15 ++- .../resources/ModelWithAllFieldTypes_.java | 68 ++++++++++- .../ModelWithAllPrivateFieldTypes_.java | 68 ++++++++++- ...WithAnnotatedClassAndSuperAttributes_.java | 107 +++++++++++++++--- ...WithAnnotatedClassAndSuperAttributes_.java | 68 ++++++++++- .../resources/ModelWithAnnotatedClass_.java | 68 ++++++++++- .../test/resources/ModelWithAnnotation_.java | 62 +++++++++- .../resources/ModelWithConstructors_.java | 68 ++++++++++- .../ModelWithDataBindingBindingModel_.java | 69 ++++++++++- ...aBindingWithoutDonothashBindingModel_.java | 60 ++++++++++ .../resources/ModelWithFieldAnnotation_.java | 68 ++++++++++- .../test/resources/ModelWithFinalField_.java | 62 +++++++++- .../src/test/resources/ModelWithIntDef_.java | 61 ++++++++++ ...ldWithSameAsFieldGetterAndSetterName_.java | 68 ++++++++++- .../ModelWithPrivateViewClickListener_.java | 71 +++++++++++- ...tributes$SubModelWithSuperAttributes_.java | 68 ++++++++++- .../resources/ModelWithSuperAttributes_.java | 68 ++++++++++- .../src/test/resources/ModelWithSuper_.java | 59 ++++++++++ .../src/test/resources/ModelWithType_.java | 59 ++++++++++ .../ModelWithVarargsConstructors_.java | 68 ++++++++++- .../ModelWithViewClickListener_.java | 71 +++++++++++- .../ModelWithViewLongClickListener_.java | 71 +++++++++++- .../src/test/resources/ModelWithoutHash_.java | 59 ++++++++++ .../test/resources/ModelWithoutSetter_.java | 62 +++++++++- .../resources/NullOnRecycleViewModel_.java | 68 ++++++++++- .../resources/OnViewRecycledViewModel_.java | 68 ++++++++++- .../resources/PropDefaultsViewModel_.java | 77 ++++++++++++- .../test/resources/PropGroupsViewModel_.java | 71 +++++++++++- ...tInViewModelAnnotationWorksViewModel_.java | 69 ++++++++++- .../test/resources/SavedStateViewModel_.java | 65 ++++++++++- .../TestAfterBindPropsViewModel_.java | 68 ++++++++++- .../resources/TestCallbackPropViewModel_.java | 71 +++++++++++- .../TestFieldPropCallbackPropViewModel_.java | 72 +++++++++++- .../TestFieldPropChildViewModel_.java | 71 +++++++++++- ...estFieldPropDoNotHashOptionViewModel_.java | 72 +++++++++++- ...nerateStringOverloadsOptionViewModel_.java | 74 +++++++++++- ...IgnoreRequireHashCodeOptionViewModel_.java | 76 ++++++++++++- .../TestFieldPropModelPropViewModel_.java | 68 ++++++++++- ...ieldPropNullOnRecycleOptionViewModel_.java | 85 ++++++++++++-- .../TestFieldPropTextPropViewModel_.java | 68 ++++++++++- .../TestManyTypesViewModelBuilder.java | 27 +++-- .../resources/TestManyTypesViewModel_.java | 80 +++++++++++-- .../TestNullStringOverloadsViewModel_.java | 69 ++++++++++- .../TestStringOverloadsViewModel_.java | 71 +++++++++++- .../resources/TestTextPropViewModel_.java | 68 ++++++++++- .../resources/TextPropDefaultViewModel_.java | 71 +++++++++++- 94 files changed, 6027 insertions(+), 317 deletions(-) diff --git a/epoxy-modelfactory/src/test/resources/AllTypesModelViewModel_.java b/epoxy-modelfactory/src/test/resources/AllTypesModelViewModel_.java index a5236664c1..17c092318a 100644 --- a/epoxy-modelfactory/src/test/resources/AllTypesModelViewModel_.java +++ b/epoxy-modelfactory/src/test/resources/AllTypesModelViewModel_.java @@ -29,6 +29,10 @@ public class AllTypesModelViewModel_ extends EpoxyModel imple private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + /** * Bitset index: 0 */ private boolean booleanValue_Boolean = false; @@ -244,7 +248,8 @@ public void handlePostBind(final AllTypesModelView object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public AllTypesModelViewModel_ onBind(OnModelBoundListener listener) { + public AllTypesModelViewModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -265,12 +270,58 @@ public void unbind(AllTypesModelView object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public AllTypesModelViewModel_ onUnbind(OnModelUnboundListener listener) { + public AllTypesModelViewModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final AllTypesModelView object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public AllTypesModelViewModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final AllTypesModelView object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public AllTypesModelViewModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + /** * Optional: Default value is false * @@ -385,7 +436,8 @@ public int drawableRes() { * * @see AllTypesModelView#setEpoxyModelList(List>) */ - public AllTypesModelViewModel_ epoxyModelList(@NonNull List> epoxyModelList) { + public AllTypesModelViewModel_ epoxyModelList( + @NonNull List> epoxyModelList) { if (epoxyModelList == null) { throw new IllegalArgumentException("epoxyModelList cannot be null"); } @@ -474,7 +526,8 @@ public Long boxedLongValue() { /** * Set a click listener that will provide the parent view, model, and adapter position of the clicked view. This will clear the normal View.OnClickListener if one has been set */ - public AllTypesModelViewModel_ onClickListener(@NonNull final OnModelClickListener onClickListener) { + public AllTypesModelViewModel_ onClickListener( + @NonNull final OnModelClickListener onClickListener) { assignedAttributes_epoxyGeneratedModel.set(11); onMutation(); if (onClickListener == null) { @@ -606,7 +659,8 @@ public AllTypesModelViewModel_ layout(@LayoutRes int arg0) { } @Override - public AllTypesModelViewModel_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public AllTypesModelViewModel_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -639,6 +693,8 @@ protected int getDefaultLayout() { public AllTypesModelViewModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); this.booleanValue_Boolean = false; this.boxedBooleanValue_Boolean = null; @@ -677,6 +733,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((booleanValue_Boolean != that.booleanValue_Boolean)) { return false; } @@ -730,6 +792,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); long temp; result = 31 * result + (booleanValue_Boolean ? 1 : 0); result = 31 * result + (boxedBooleanValue_Boolean != null ? boxedBooleanValue_Boolean.hashCode() : 0); diff --git a/epoxy-modelfactory/src/test/resources/BaseModelViewModel_.java b/epoxy-modelfactory/src/test/resources/BaseModelViewModel_.java index bd0623d305..756c34b8e8 100644 --- a/epoxy-modelfactory/src/test/resources/BaseModelViewModel_.java +++ b/epoxy-modelfactory/src/test/resources/BaseModelViewModel_.java @@ -21,6 +21,10 @@ public class BaseModelViewModel_ extends EpoxyModel implements Ge private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + /** * Bitset index: 0 */ @NonNull @@ -76,7 +80,8 @@ public void handlePostBind(final BaseModelView object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public BaseModelViewModel_ onBind(OnModelBoundListener listener) { + public BaseModelViewModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -97,12 +102,58 @@ public void unbind(BaseModelView object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public BaseModelViewModel_ onUnbind(OnModelUnboundListener listener) { + public BaseModelViewModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final BaseModelView object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public BaseModelViewModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final BaseModelView object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public BaseModelViewModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + /** * Required. * @@ -199,6 +250,8 @@ protected int getDefaultLayout() { public BaseModelViewModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); this.title_String = null; super.reset(); @@ -223,6 +276,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((title_String != null ? !title_String.equals(that.title_String) : that.title_String != null)) { return false; } @@ -234,6 +293,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (title_String != null ? title_String.hashCode() : 0); return result; } diff --git a/epoxy-modelfactory/src/test/resources/BasicModelWithAttribute_.java b/epoxy-modelfactory/src/test/resources/BasicModelWithAttribute_.java index 6d71d0c069..b56749ba50 100755 --- a/epoxy-modelfactory/src/test/resources/BasicModelWithAttribute_.java +++ b/epoxy-modelfactory/src/test/resources/BasicModelWithAttribute_.java @@ -15,6 +15,10 @@ public class BasicModelWithAttribute_ extends BasicModelWithAttribute implements private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + public BasicModelWithAttribute_() { super(); } @@ -45,7 +49,8 @@ public void handlePostBind(final Object object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public BasicModelWithAttribute_ onBind(OnModelBoundListener listener) { + public BasicModelWithAttribute_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -66,12 +71,58 @@ public void unbind(Object object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public BasicModelWithAttribute_ onUnbind(OnModelUnboundListener listener) { + public BasicModelWithAttribute_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final Object object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public BasicModelWithAttribute_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final Object object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public BasicModelWithAttribute_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + public BasicModelWithAttribute_ value(int value) { onMutation(); super.value = value; @@ -125,7 +176,8 @@ public BasicModelWithAttribute_ layout(@LayoutRes int arg0) { } @Override - public BasicModelWithAttribute_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public BasicModelWithAttribute_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -152,6 +204,8 @@ public BasicModelWithAttribute_ hide() { public BasicModelWithAttribute_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; super.value = 0; super.reset(); return this; @@ -175,6 +229,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((value != that.value)) { return false; } @@ -186,6 +246,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + value; return result; } diff --git a/epoxy-modelfactory/src/test/resources/BasicModelWithFinalAttribute_.java b/epoxy-modelfactory/src/test/resources/BasicModelWithFinalAttribute_.java index b80a474007..cf1d1fbfb9 100755 --- a/epoxy-modelfactory/src/test/resources/BasicModelWithFinalAttribute_.java +++ b/epoxy-modelfactory/src/test/resources/BasicModelWithFinalAttribute_.java @@ -15,6 +15,10 @@ public class BasicModelWithFinalAttribute_ extends BasicModelWithFinalAttribute private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + public BasicModelWithFinalAttribute_() { super(); } @@ -45,7 +49,8 @@ public void handlePostBind(final Object object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public BasicModelWithFinalAttribute_ onBind(OnModelBoundListener listener) { + public BasicModelWithFinalAttribute_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -66,12 +71,58 @@ public void unbind(Object object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public BasicModelWithFinalAttribute_ onUnbind(OnModelUnboundListener listener) { + public BasicModelWithFinalAttribute_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final Object object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public BasicModelWithFinalAttribute_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final Object object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public BasicModelWithFinalAttribute_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + public int value() { return value; } @@ -120,7 +171,8 @@ public BasicModelWithFinalAttribute_ layout(@LayoutRes int arg0) { } @Override - public BasicModelWithFinalAttribute_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public BasicModelWithFinalAttribute_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -147,6 +199,8 @@ public BasicModelWithFinalAttribute_ hide() { public BasicModelWithFinalAttribute_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; super.reset(); return this; } @@ -169,6 +223,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((value != that.value)) { return false; } @@ -180,6 +240,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + value; return result; } diff --git a/epoxy-modelfactory/src/test/resources/CallbackPropModelViewModel_.java b/epoxy-modelfactory/src/test/resources/CallbackPropModelViewModel_.java index a285730a6c..5755c06911 100644 --- a/epoxy-modelfactory/src/test/resources/CallbackPropModelViewModel_.java +++ b/epoxy-modelfactory/src/test/resources/CallbackPropModelViewModel_.java @@ -19,6 +19,10 @@ public class CallbackPropModelViewModel_ extends EpoxyModel onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + /** * Bitset index: 0 */ @Nullable @@ -71,7 +75,8 @@ public void handlePostBind(final CallbackPropModelView object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public CallbackPropModelViewModel_ onBind(OnModelBoundListener listener) { + public CallbackPropModelViewModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -93,15 +98,62 @@ public void unbind(CallbackPropModelView object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public CallbackPropModelViewModel_ onUnbind(OnModelUnboundListener listener) { + public CallbackPropModelViewModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final CallbackPropModelView object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public CallbackPropModelViewModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final CallbackPropModelView object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public CallbackPropModelViewModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + /** * Set a click listener that will provide the parent view, model, and adapter position of the clicked view. This will clear the normal View.OnClickListener if one has been set */ - public CallbackPropModelViewModel_ onClickListener(@Nullable final OnModelClickListener onClickListener) { + public CallbackPropModelViewModel_ onClickListener( + @Nullable final OnModelClickListener onClickListener) { assignedAttributes_epoxyGeneratedModel.set(0); onMutation(); if (onClickListener == null) { @@ -118,7 +170,8 @@ public CallbackPropModelViewModel_ onClickListener(@Nullable final OnModelClickL * * @see CallbackPropModelView#setOnClickListener(View.OnClickListener) */ - public CallbackPropModelViewModel_ onClickListener(@Nullable View.OnClickListener onClickListener) { + public CallbackPropModelViewModel_ onClickListener( + @Nullable View.OnClickListener onClickListener) { assignedAttributes_epoxyGeneratedModel.set(0); onMutation(); this.onClickListener_OnClickListener = onClickListener; @@ -174,7 +227,8 @@ public CallbackPropModelViewModel_ layout(@LayoutRes int arg0) { } @Override - public CallbackPropModelViewModel_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public CallbackPropModelViewModel_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -207,6 +261,8 @@ protected int getDefaultLayout() { public CallbackPropModelViewModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); this.onClickListener_OnClickListener = (View.OnClickListener) null; super.reset(); @@ -231,6 +287,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if (((onClickListener_OnClickListener == null) != (that.onClickListener_OnClickListener == null))) { return false; } @@ -242,6 +304,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onClickListener_OnClickListener != null ? 1 : 0); return result; } diff --git a/epoxy-modelfactory/src/test/resources/GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_.java b/epoxy-modelfactory/src/test/resources/GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_.java index 47134c27c0..fb373ddbb6 100644 --- a/epoxy-modelfactory/src/test/resources/GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_.java +++ b/epoxy-modelfactory/src/test/resources/GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_.java @@ -20,6 +20,10 @@ public class GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ ext private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + /** * Bitset index: 0 */ @NonNull @@ -97,7 +101,8 @@ public void handlePostBind(final GroupPropMultipleSupportedAttributeDifferentNam * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ onBind(OnModelBoundListener listener) { + public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -118,18 +123,67 @@ public void unbind(GroupPropMultipleSupportedAttributeDifferentNameModelView obj * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ onUnbind(OnModelUnboundListener listener) { + public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, + final GroupPropMultipleSupportedAttributeDifferentNameModelView object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, + final GroupPropMultipleSupportedAttributeDifferentNameModelView object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + /** * Required. * * @see GroupPropMultipleSupportedAttributeDifferentNameModelView#setTitleString(String) */ - public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ titleString(@NonNull String titleString) { + public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ titleString( + @NonNull String titleString) { if (titleString == null) { throw new IllegalArgumentException("titleString cannot be null"); } @@ -171,7 +225,8 @@ public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ id(long i } @Override - public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ id(@Nullable Number... arg0) { + public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ id( + @Nullable Number... arg0) { super.id(arg0); return this; } @@ -183,33 +238,36 @@ public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ id(long i } @Override - public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ id(@Nullable CharSequence arg0) { + public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ id( + @Nullable CharSequence arg0) { super.id(arg0); return this; } @Override - public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ id(@Nullable CharSequence arg0, - @Nullable CharSequence... arg1) { + public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ id( + @Nullable CharSequence arg0, @Nullable CharSequence... arg1) { super.id(arg0, arg1); return this; } @Override - public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ id(@Nullable CharSequence arg0, - long arg1) { + public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ id( + @Nullable CharSequence arg0, long arg1) { super.id(arg0, arg1); return this; } @Override - public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ layout(@LayoutRes int arg0) { + public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ layout( + @LayoutRes int arg0) { super.layout(arg0); return this; } @Override - public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -242,6 +300,8 @@ protected int getDefaultLayout() { public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); this.titleString_String = null; this.titleInt_Int = 0; @@ -267,6 +327,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((titleString_String != null ? !titleString_String.equals(that.titleString_String) : that.titleString_String != null)) { return false; } @@ -281,6 +347,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (titleString_String != null ? titleString_String.hashCode() : 0); result = 31 * result + titleInt_Int; return result; @@ -294,7 +362,8 @@ public String toString() { "}" + super.toString(); } - public static GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ from(ModelProperties properties) { + public static GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ from( + ModelProperties properties) { GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ model = new GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_(); model.id(properties.getId()); if (properties.has("titleString")) { diff --git a/epoxy-modelfactory/src/test/resources/GroupPropMultipleSupportedAttributeSameNameModelViewModel_.java b/epoxy-modelfactory/src/test/resources/GroupPropMultipleSupportedAttributeSameNameModelViewModel_.java index a86f10f44a..252ea186cd 100644 --- a/epoxy-modelfactory/src/test/resources/GroupPropMultipleSupportedAttributeSameNameModelViewModel_.java +++ b/epoxy-modelfactory/src/test/resources/GroupPropMultipleSupportedAttributeSameNameModelViewModel_.java @@ -20,6 +20,10 @@ public class GroupPropMultipleSupportedAttributeSameNameModelViewModel_ extends private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + /** * Bitset index: 0 */ @NonNull @@ -97,7 +101,8 @@ public void handlePostBind(final GroupPropMultipleSupportedAttributeSameNameMode * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ onBind(OnModelBoundListener listener) { + public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -118,18 +123,67 @@ public void unbind(GroupPropMultipleSupportedAttributeSameNameModelView object) * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ onUnbind(OnModelUnboundListener listener) { + public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, + final GroupPropMultipleSupportedAttributeSameNameModelView object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, + final GroupPropMultipleSupportedAttributeSameNameModelView object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + /** * Required. * * @see GroupPropMultipleSupportedAttributeSameNameModelView#setTitleString(String) */ - public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ titleString(@NonNull String titleString) { + public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ titleString( + @NonNull String titleString) { if (titleString == null) { throw new IllegalArgumentException("titleString cannot be null"); } @@ -183,7 +237,8 @@ public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ id(long id1, l } @Override - public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ id(@Nullable CharSequence arg0) { + public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ id( + @Nullable CharSequence arg0) { super.id(arg0); return this; } @@ -209,7 +264,8 @@ public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ layout(@Layout } @Override - public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -242,6 +298,8 @@ protected int getDefaultLayout() { public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); this.titleString_String = null; this.titleInt_Int = 0; @@ -267,6 +325,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((titleString_String != null ? !titleString_String.equals(that.titleString_String) : that.titleString_String != null)) { return false; } @@ -281,6 +345,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (titleString_String != null ? titleString_String.hashCode() : 0); result = 31 * result + titleInt_Int; return result; @@ -294,7 +360,8 @@ public String toString() { "}" + super.toString(); } - public static GroupPropMultipleSupportedAttributeSameNameModelViewModel_ from(ModelProperties properties) { + public static GroupPropMultipleSupportedAttributeSameNameModelViewModel_ from( + ModelProperties properties) { GroupPropMultipleSupportedAttributeSameNameModelViewModel_ model = new GroupPropMultipleSupportedAttributeSameNameModelViewModel_(); model.id(properties.getId()); if (properties.has("titleString")) { diff --git a/epoxy-modelfactory/src/test/resources/GroupPropSingleSupportedAttributeModelViewModel_.java b/epoxy-modelfactory/src/test/resources/GroupPropSingleSupportedAttributeModelViewModel_.java index 7434bb0697..5db9d8da43 100644 --- a/epoxy-modelfactory/src/test/resources/GroupPropSingleSupportedAttributeModelViewModel_.java +++ b/epoxy-modelfactory/src/test/resources/GroupPropSingleSupportedAttributeModelViewModel_.java @@ -21,6 +21,10 @@ public class GroupPropSingleSupportedAttributeModelViewModel_ extends EpoxyModel private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + /** * Bitset index: 0 */ @NonNull @@ -95,7 +99,8 @@ public void handlePostBind(final GroupPropSingleSupportedAttributeModelView obje * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public GroupPropSingleSupportedAttributeModelViewModel_ onBind(OnModelBoundListener listener) { + public GroupPropSingleSupportedAttributeModelViewModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -116,12 +121,60 @@ public void unbind(GroupPropSingleSupportedAttributeModelView object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public GroupPropSingleSupportedAttributeModelViewModel_ onUnbind(OnModelUnboundListener listener) { + public GroupPropSingleSupportedAttributeModelViewModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, + final GroupPropSingleSupportedAttributeModelView object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public GroupPropSingleSupportedAttributeModelViewModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, + final GroupPropSingleSupportedAttributeModelView object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public GroupPropSingleSupportedAttributeModelViewModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + /** * Required. * @@ -211,7 +264,8 @@ public GroupPropSingleSupportedAttributeModelViewModel_ layout(@LayoutRes int ar } @Override - public GroupPropSingleSupportedAttributeModelViewModel_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public GroupPropSingleSupportedAttributeModelViewModel_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -244,6 +298,8 @@ protected int getDefaultLayout() { public GroupPropSingleSupportedAttributeModelViewModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); this.title_String = null; this.title_Object = null; @@ -269,6 +325,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((title_String != null ? !title_String.equals(that.title_String) : that.title_String != null)) { return false; } @@ -283,6 +345,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (title_String != null ? title_String.hashCode() : 0); result = 31 * result + (title_Object != null ? title_Object.hashCode() : 0); return result; diff --git a/epoxy-modelfactory/src/test/resources/ListSubtypeModelViewModel_.java b/epoxy-modelfactory/src/test/resources/ListSubtypeModelViewModel_.java index 5103af9c5d..a4ab17ba74 100644 --- a/epoxy-modelfactory/src/test/resources/ListSubtypeModelViewModel_.java +++ b/epoxy-modelfactory/src/test/resources/ListSubtypeModelViewModel_.java @@ -22,6 +22,10 @@ public class ListSubtypeModelViewModel_ extends EpoxyModel private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + /** * Bitset index: 0 */ @NonNull @@ -77,7 +81,8 @@ public void handlePostBind(final ListSubtypeModelView object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ListSubtypeModelViewModel_ onBind(OnModelBoundListener listener) { + public ListSubtypeModelViewModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -98,12 +103,58 @@ public void unbind(ListSubtypeModelView object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ListSubtypeModelViewModel_ onUnbind(OnModelUnboundListener listener) { + public ListSubtypeModelViewModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final ListSubtypeModelView object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ListSubtypeModelViewModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final ListSubtypeModelView object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ListSubtypeModelViewModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + /** * Required. * @@ -168,7 +219,8 @@ public ListSubtypeModelViewModel_ layout(@LayoutRes int arg0) { } @Override - public ListSubtypeModelViewModel_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public ListSubtypeModelViewModel_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -201,6 +253,8 @@ protected int getDefaultLayout() { public ListSubtypeModelViewModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); this.stringArrayList_ArrayList = null; super.reset(); @@ -225,6 +279,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((stringArrayList_ArrayList != null ? !stringArrayList_ArrayList.equals(that.stringArrayList_ArrayList) : that.stringArrayList_ArrayList != null)) { return false; } @@ -236,6 +296,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (stringArrayList_ArrayList != null ? stringArrayList_ArrayList.hashCode() : 0); return result; } diff --git a/epoxy-modelfactory/src/test/resources/StyleableModelViewModel_.java b/epoxy-modelfactory/src/test/resources/StyleableModelViewModel_.java index bd7ccfdf04..e67b27660c 100644 --- a/epoxy-modelfactory/src/test/resources/StyleableModelViewModel_.java +++ b/epoxy-modelfactory/src/test/resources/StyleableModelViewModel_.java @@ -35,6 +35,10 @@ public class StyleableModelViewModel_ extends EpoxyModel imp private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + /** * Bitset index: 0 */ @NonNull @@ -130,7 +134,8 @@ public void handlePostBind(final StyleableModelView object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public StyleableModelViewModel_ onBind(OnModelBoundListener listener) { + public StyleableModelViewModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -151,12 +156,58 @@ public void unbind(StyleableModelView object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public StyleableModelViewModel_ onUnbind(OnModelUnboundListener listener) { + public StyleableModelViewModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final StyleableModelView object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public StyleableModelViewModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final StyleableModelView object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public StyleableModelViewModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + public StyleableModelViewModel_ style(Style style) { assignedAttributes_epoxyGeneratedModel.set(1); onMutation(); @@ -164,7 +215,8 @@ public StyleableModelViewModel_ style(Style style) { return this; } - public StyleableModelViewModel_ styleBuilder(StyleBuilderCallback builderCallback) { + public StyleableModelViewModel_ styleBuilder( + StyleBuilderCallback builderCallback) { StyleableModelViewStyleApplier.StyleBuilder builder = new StyleableModelViewStyleApplier.StyleBuilder(); builderCallback.buildStyle(builder.addDefault()); return style(builder.build()); @@ -243,7 +295,8 @@ public StyleableModelViewModel_ layout(@LayoutRes int arg0) { } @Override - public StyleableModelViewModel_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public StyleableModelViewModel_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -276,6 +329,8 @@ protected int getDefaultLayout() { public StyleableModelViewModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); this.title_String = null; this.style = DEFAULT_PARIS_STYLE; @@ -301,6 +356,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((title_String != null ? !title_String.equals(that.title_String) : that.title_String != null)) { return false; } @@ -315,6 +376,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (title_String != null ? title_String.hashCode() : 0); result = 31 * result + (style != null ? style.hashCode() : 0); return result; diff --git a/epoxy-modelfactory/src/test/resources/TextPropModelViewModel_.java b/epoxy-modelfactory/src/test/resources/TextPropModelViewModel_.java index e4868e0037..a3cc4c3599 100644 --- a/epoxy-modelfactory/src/test/resources/TextPropModelViewModel_.java +++ b/epoxy-modelfactory/src/test/resources/TextPropModelViewModel_.java @@ -24,6 +24,10 @@ public class TextPropModelViewModel_ extends EpoxyModel imple private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + /** * Bitset index: 0 */ private StringAttributeData title_StringAttributeData = new StringAttributeData(); @@ -78,7 +82,8 @@ public void handlePostBind(final TextPropModelView object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public TextPropModelViewModel_ onBind(OnModelBoundListener listener) { + public TextPropModelViewModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -99,12 +104,58 @@ public void unbind(TextPropModelView object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public TextPropModelViewModel_ onUnbind(OnModelUnboundListener listener) { + public TextPropModelViewModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final TextPropModelView object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public TextPropModelViewModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final TextPropModelView object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public TextPropModelViewModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + public CharSequence getTitle(Context context) { return title_StringAttributeData.toString(context); } @@ -210,7 +261,8 @@ public TextPropModelViewModel_ layout(@LayoutRes int arg0) { } @Override - public TextPropModelViewModel_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public TextPropModelViewModel_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -243,6 +295,8 @@ protected int getDefaultLayout() { public TextPropModelViewModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); this.title_StringAttributeData = new StringAttributeData(); super.reset(); @@ -267,6 +321,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((title_StringAttributeData != null ? !title_StringAttributeData.equals(that.title_StringAttributeData) : that.title_StringAttributeData != null)) { return false; } @@ -278,6 +338,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (title_StringAttributeData != null ? title_StringAttributeData.hashCode() : 0); return result; } diff --git a/epoxy-processor/src/main/java/com/airbnb/epoxy/Utils.java b/epoxy-processor/src/main/java/com/airbnb/epoxy/Utils.java index 6c072c2a9f..2125830153 100644 --- a/epoxy-processor/src/main/java/com/airbnb/epoxy/Utils.java +++ b/epoxy-processor/src/main/java/com/airbnb/epoxy/Utils.java @@ -64,8 +64,10 @@ class Utils { static final String ON_UNBIND_MODEL_LISTENER_TYPE = "com.airbnb.epoxy.OnModelUnboundListener"; static final String WRAPPED_LISTENER_TYPE = "com.airbnb.epoxy.WrappedEpoxyModelClickListener"; static final String DATA_BINDING_MODEL_TYPE = "com.airbnb.epoxy.DataBindingEpoxyModel"; - static final String ON_VISIBILITY_STATE_MODEL_LISTENER_TYPE = "com.airbnb.epoxy.OnModelVisibilityStateChangedListener"; - static final String ON_VISIBILITY_MODEL_LISTENER_TYPE = "com.airbnb.epoxy.OnModelVisibilityChangedListener"; + static final String ON_VISIBILITY_STATE_MODEL_LISTENER_TYPE = + "com.airbnb.epoxy.OnModelVisibilityStateChangedListener"; + static final String ON_VISIBILITY_MODEL_LISTENER_TYPE = + "com.airbnb.epoxy.OnModelVisibilityChangedListener"; static void throwError(String msg, Object... args) throws EpoxyProcessorException { diff --git a/epoxy-processortest/src/test/resources/AbstractModelWithHolder_.java b/epoxy-processortest/src/test/resources/AbstractModelWithHolder_.java index b3ef61c5c6..2c6b6bd95b 100755 --- a/epoxy-processortest/src/test/resources/AbstractModelWithHolder_.java +++ b/epoxy-processortest/src/test/resources/AbstractModelWithHolder_.java @@ -15,6 +15,10 @@ public class AbstractModelWithHolder_ extends AbstractModelWithHolder implements private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + public AbstractModelWithHolder_() { super(); } @@ -46,7 +50,8 @@ public void handlePostBind(final AbstractModelWithHolder.Holder object, int posi * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public AbstractModelWithHolder_ onBind(OnModelBoundListener listener) { + public AbstractModelWithHolder_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -67,12 +72,59 @@ public void unbind(AbstractModelWithHolder.Holder object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public AbstractModelWithHolder_ onUnbind(OnModelUnboundListener listener) { + public AbstractModelWithHolder_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, + final AbstractModelWithHolder.Holder object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public AbstractModelWithHolder_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final AbstractModelWithHolder.Holder object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public AbstractModelWithHolder_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + public AbstractModelWithHolder_ value(int value) { onMutation(); super.value = value; @@ -126,7 +178,8 @@ public AbstractModelWithHolder_ layout(@LayoutRes int arg0) { } @Override - public AbstractModelWithHolder_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public AbstractModelWithHolder_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -158,6 +211,8 @@ protected AbstractModelWithHolder.Holder createNewHolder() { public AbstractModelWithHolder_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; super.value = 0; super.reset(); return this; @@ -181,6 +236,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((value != that.value)) { return false; } @@ -192,6 +253,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + value; return result; } diff --git a/epoxy-processortest/src/test/resources/AutoLayoutModelViewMatchParentModel_.java b/epoxy-processortest/src/test/resources/AutoLayoutModelViewMatchParentModel_.java index edebe5ad01..4b1b77ccf6 100644 --- a/epoxy-processortest/src/test/resources/AutoLayoutModelViewMatchParentModel_.java +++ b/epoxy-processortest/src/test/resources/AutoLayoutModelViewMatchParentModel_.java @@ -20,6 +20,10 @@ public class AutoLayoutModelViewMatchParentModel_ extends EpoxyModel onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + /** * Bitset index: 0 */ private int value_Int = 0; @@ -83,7 +87,8 @@ public void handlePostBind(final AutoLayoutModelViewMatchParent object, int posi * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public AutoLayoutModelViewMatchParentModel_ onBind(OnModelBoundListener listener) { + public AutoLayoutModelViewMatchParentModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -104,12 +109,59 @@ public void unbind(AutoLayoutModelViewMatchParent object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public AutoLayoutModelViewMatchParentModel_ onUnbind(OnModelUnboundListener listener) { + public AutoLayoutModelViewMatchParentModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, + final AutoLayoutModelViewMatchParent object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public AutoLayoutModelViewMatchParentModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final AutoLayoutModelViewMatchParent object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public AutoLayoutModelViewMatchParentModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + /** * Optional: Default value is 0 * @@ -169,7 +221,8 @@ public AutoLayoutModelViewMatchParentModel_ layout(@LayoutRes int arg0) { } @Override - public AutoLayoutModelViewMatchParentModel_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public AutoLayoutModelViewMatchParentModel_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -202,6 +255,8 @@ protected int getDefaultLayout() { public AutoLayoutModelViewMatchParentModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); this.value_Int = 0; super.reset(); @@ -226,6 +281,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((value_Int != that.value_Int)) { return false; } @@ -237,6 +298,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + value_Int; return result; } diff --git a/epoxy-processortest/src/test/resources/AutoLayoutModelViewModel_.java b/epoxy-processortest/src/test/resources/AutoLayoutModelViewModel_.java index 77e1a6748a..4e2f1340f6 100644 --- a/epoxy-processortest/src/test/resources/AutoLayoutModelViewModel_.java +++ b/epoxy-processortest/src/test/resources/AutoLayoutModelViewModel_.java @@ -20,6 +20,10 @@ public class AutoLayoutModelViewModel_ extends EpoxyModel i private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + /** * Bitset index: 0 */ private int value_Int = 0; @@ -83,7 +87,8 @@ public void handlePostBind(final AutoLayoutModelView object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public AutoLayoutModelViewModel_ onBind(OnModelBoundListener listener) { + public AutoLayoutModelViewModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -104,12 +109,58 @@ public void unbind(AutoLayoutModelView object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public AutoLayoutModelViewModel_ onUnbind(OnModelUnboundListener listener) { + public AutoLayoutModelViewModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final AutoLayoutModelView object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public AutoLayoutModelViewModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final AutoLayoutModelView object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public AutoLayoutModelViewModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + /** * Optional: Default value is 0 * @@ -168,7 +219,8 @@ public AutoLayoutModelViewModel_ layout(@LayoutRes int arg0) { } @Override - public AutoLayoutModelViewModel_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public AutoLayoutModelViewModel_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -201,6 +253,8 @@ protected int getDefaultLayout() { public AutoLayoutModelViewModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); this.value_Int = 0; super.reset(); @@ -225,6 +279,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((value_Int != that.value_Int)) { return false; } @@ -236,6 +296,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + value_Int; return result; } diff --git a/epoxy-processortest/src/test/resources/BaseModelFromPackageConfigViewModel_.java b/epoxy-processortest/src/test/resources/BaseModelFromPackageConfigViewModel_.java index 3a4afaf3ca..a240efc643 100644 --- a/epoxy-processortest/src/test/resources/BaseModelFromPackageConfigViewModel_.java +++ b/epoxy-processortest/src/test/resources/BaseModelFromPackageConfigViewModel_.java @@ -21,6 +21,10 @@ public class BaseModelViewModel_ extends TestBaseModel implements private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + /** * Bitset index: 0 */ @NonNull @@ -80,7 +84,8 @@ public void handlePostBind(final BaseModelView object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public BaseModelViewModel_ onBind(OnModelBoundListener listener) { + public BaseModelViewModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -101,12 +106,58 @@ public void unbind(BaseModelView object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public BaseModelViewModel_ onUnbind(OnModelUnboundListener listener) { + public BaseModelViewModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final BaseModelView object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public BaseModelViewModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final BaseModelView object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public BaseModelViewModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + /** * Required. * @@ -203,6 +254,8 @@ protected int getDefaultLayout() { public BaseModelViewModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); this.clickListener_String = null; super.reset(); @@ -227,6 +280,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((clickListener_String != null ? !clickListener_String.equals(that.clickListener_String) : that.clickListener_String != null)) { return false; } @@ -238,6 +297,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (clickListener_String != null ? clickListener_String.hashCode() : 0); return result; } diff --git a/epoxy-processortest/src/test/resources/BaseModelOverridesPackageConfigViewModel_.java b/epoxy-processortest/src/test/resources/BaseModelOverridesPackageConfigViewModel_.java index 86de05a465..22f033a4e1 100644 --- a/epoxy-processortest/src/test/resources/BaseModelOverridesPackageConfigViewModel_.java +++ b/epoxy-processortest/src/test/resources/BaseModelOverridesPackageConfigViewModel_.java @@ -21,6 +21,10 @@ public class BaseModelViewModel_ extends EpoxyModel implements Ge private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + /** * Bitset index: 0 */ @NonNull @@ -76,7 +80,8 @@ public void handlePostBind(final BaseModelView object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public BaseModelViewModel_ onBind(OnModelBoundListener listener) { + public BaseModelViewModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -97,12 +102,58 @@ public void unbind(BaseModelView object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public BaseModelViewModel_ onUnbind(OnModelUnboundListener listener) { + public BaseModelViewModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final BaseModelView object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public BaseModelViewModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final BaseModelView object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public BaseModelViewModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + /** * Required. * @@ -199,6 +250,8 @@ protected int getDefaultLayout() { public BaseModelViewModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); this.clickListener_String = null; super.reset(); @@ -223,6 +276,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((clickListener_String != null ? !clickListener_String.equals(that.clickListener_String) : that.clickListener_String != null)) { return false; } @@ -234,6 +293,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (clickListener_String != null ? clickListener_String.hashCode() : 0); return result; } diff --git a/epoxy-processortest/src/test/resources/BaseModelViewModel_.java b/epoxy-processortest/src/test/resources/BaseModelViewModel_.java index 3f144cab67..83215195f2 100644 --- a/epoxy-processortest/src/test/resources/BaseModelViewModel_.java +++ b/epoxy-processortest/src/test/resources/BaseModelViewModel_.java @@ -21,6 +21,10 @@ public class BaseModelViewModel_ extends TestBaseModel implements private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + /** * Bitset index: 0 */ @NonNull @@ -80,7 +84,8 @@ public void handlePostBind(final BaseModelView object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public BaseModelViewModel_ onBind(OnModelBoundListener listener) { + public BaseModelViewModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -101,12 +106,58 @@ public void unbind(BaseModelView object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public BaseModelViewModel_ onUnbind(OnModelUnboundListener listener) { + public BaseModelViewModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final BaseModelView object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public BaseModelViewModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final BaseModelView object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public BaseModelViewModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + /** * Required. * @@ -203,6 +254,8 @@ protected int getDefaultLayout() { public BaseModelViewModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); this.clickListener_String = null; super.reset(); @@ -227,6 +280,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((clickListener_String != null ? !clickListener_String.equals(that.clickListener_String) : that.clickListener_String != null)) { return false; } @@ -238,6 +297,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (clickListener_String != null ? clickListener_String.hashCode() : 0); return result; } diff --git a/epoxy-processortest/src/test/resources/BaseModelViewWithSuperDiffBindModel_.java b/epoxy-processortest/src/test/resources/BaseModelViewWithSuperDiffBindModel_.java index f03989c3af..b1386cf684 100644 --- a/epoxy-processortest/src/test/resources/BaseModelViewWithSuperDiffBindModel_.java +++ b/epoxy-processortest/src/test/resources/BaseModelViewWithSuperDiffBindModel_.java @@ -21,6 +21,10 @@ public class BaseModelViewModel_ extends TestBaseModel implements private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + /** * Bitset index: 0 */ @NonNull @@ -80,7 +84,8 @@ public void handlePostBind(final BaseModelView object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public BaseModelViewModel_ onBind(OnModelBoundListener listener) { + public BaseModelViewModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -101,12 +106,58 @@ public void unbind(BaseModelView object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public BaseModelViewModel_ onUnbind(OnModelUnboundListener listener) { + public BaseModelViewModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final BaseModelView object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public BaseModelViewModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final BaseModelView object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public BaseModelViewModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + /** * Required. * @@ -203,6 +254,8 @@ protected int getDefaultLayout() { public BaseModelViewModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); this.clickListener_String = null; super.reset(); @@ -227,6 +280,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((clickListener_String != null ? !clickListener_String.equals(that.clickListener_String) : that.clickListener_String != null)) { return false; } @@ -238,6 +297,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (clickListener_String != null ? clickListener_String.hashCode() : 0); return result; } diff --git a/epoxy-processortest/src/test/resources/BaseModelWithAttributeViewModel_.java b/epoxy-processortest/src/test/resources/BaseModelWithAttributeViewModel_.java index 4344a51681..06bc894050 100644 --- a/epoxy-processortest/src/test/resources/BaseModelWithAttributeViewModel_.java +++ b/epoxy-processortest/src/test/resources/BaseModelWithAttributeViewModel_.java @@ -21,6 +21,10 @@ public class BaseModelViewModel_ extends TestBaseModel implements private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + /** * Bitset index: 0 */ @NonNull @@ -80,7 +84,8 @@ public void handlePostBind(final BaseModelView object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public BaseModelViewModel_ onBind(OnModelBoundListener listener) { + public BaseModelViewModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -101,12 +106,58 @@ public void unbind(BaseModelView object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public BaseModelViewModel_ onUnbind(OnModelUnboundListener listener) { + public BaseModelViewModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final BaseModelView object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public BaseModelViewModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final BaseModelView object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public BaseModelViewModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + /** * Required. * @@ -214,6 +265,8 @@ protected int getDefaultLayout() { public BaseModelViewModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); this.clickListener_String = null; super.baseModelString = null; @@ -239,6 +292,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((clickListener_String != null ? !clickListener_String.equals(that.clickListener_String) : that.clickListener_String != null)) { return false; } @@ -253,6 +312,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (clickListener_String != null ? clickListener_String.hashCode() : 0); result = 31 * result + (baseModelString != null ? baseModelString.hashCode() : 0); return result; diff --git a/epoxy-processortest/src/test/resources/BasicModelWithAttribute_.java b/epoxy-processortest/src/test/resources/BasicModelWithAttribute_.java index 03b61df2a2..376263f5b1 100755 --- a/epoxy-processortest/src/test/resources/BasicModelWithAttribute_.java +++ b/epoxy-processortest/src/test/resources/BasicModelWithAttribute_.java @@ -15,6 +15,10 @@ public class BasicModelWithAttribute_ extends BasicModelWithAttribute implements private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + public BasicModelWithAttribute_() { super(); } @@ -45,7 +49,8 @@ public void handlePostBind(final Object object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public BasicModelWithAttribute_ onBind(OnModelBoundListener listener) { + public BasicModelWithAttribute_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -66,12 +71,58 @@ public void unbind(Object object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public BasicModelWithAttribute_ onUnbind(OnModelUnboundListener listener) { + public BasicModelWithAttribute_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final Object object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public BasicModelWithAttribute_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final Object object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public BasicModelWithAttribute_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + public BasicModelWithAttribute_ value(int value) { onMutation(); super.value = value; @@ -125,7 +176,8 @@ public BasicModelWithAttribute_ layout(@LayoutRes int arg0) { } @Override - public BasicModelWithAttribute_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public BasicModelWithAttribute_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -152,6 +204,8 @@ public BasicModelWithAttribute_ hide() { public BasicModelWithAttribute_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; super.value = 0; super.reset(); return this; @@ -175,6 +229,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((value != that.value)) { return false; } @@ -186,6 +246,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + value; return result; } diff --git a/epoxy-processortest/src/test/resources/CustomPackageLayoutPatternViewModel_.java b/epoxy-processortest/src/test/resources/CustomPackageLayoutPatternViewModel_.java index a8f9acb50f..c404040622 100644 --- a/epoxy-processortest/src/test/resources/CustomPackageLayoutPatternViewModel_.java +++ b/epoxy-processortest/src/test/resources/CustomPackageLayoutPatternViewModel_.java @@ -18,6 +18,10 @@ public class CustomPackageLayoutPatternViewModel_ extends EpoxyModel onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + @Override public void addTo(EpoxyController controller) { super.addTo(controller); @@ -60,7 +64,8 @@ public void handlePostBind(final CustomPackageLayoutPatternView object, int posi * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public CustomPackageLayoutPatternViewModel_ onBind(OnModelBoundListener listener) { + public CustomPackageLayoutPatternViewModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -81,12 +86,59 @@ public void unbind(CustomPackageLayoutPatternView object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public CustomPackageLayoutPatternViewModel_ onUnbind(OnModelUnboundListener listener) { + public CustomPackageLayoutPatternViewModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, + final CustomPackageLayoutPatternView object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public CustomPackageLayoutPatternViewModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final CustomPackageLayoutPatternView object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public CustomPackageLayoutPatternViewModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + @Override public CustomPackageLayoutPatternViewModel_ id(long id) { super.id(id); @@ -131,7 +183,8 @@ public CustomPackageLayoutPatternViewModel_ layout(@LayoutRes int arg0) { } @Override - public CustomPackageLayoutPatternViewModel_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public CustomPackageLayoutPatternViewModel_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -164,6 +217,8 @@ protected int getDefaultLayout() { public CustomPackageLayoutPatternViewModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); super.reset(); return this; @@ -187,6 +242,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } return true; } @@ -195,6 +256,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); return result; } diff --git a/epoxy-processortest/src/test/resources/DataBindingModelWithAllFieldTypesNoValidation_.java b/epoxy-processortest/src/test/resources/DataBindingModelWithAllFieldTypesNoValidation_.java index 237813176c..c6fa9145ae 100644 --- a/epoxy-processortest/src/test/resources/DataBindingModelWithAllFieldTypesNoValidation_.java +++ b/epoxy-processortest/src/test/resources/DataBindingModelWithAllFieldTypesNoValidation_.java @@ -26,6 +26,10 @@ public class DataBindingModelWithAllFieldTypesNoValidation_ extends DataBindingM private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + public DataBindingModelWithAllFieldTypesNoValidation_() { super(); } @@ -49,7 +53,8 @@ public void handlePostBind(final DataBindingEpoxyModel.DataBindingHolder object, * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public DataBindingModelWithAllFieldTypesNoValidation_ onBind(OnModelBoundListener listener) { + public DataBindingModelWithAllFieldTypesNoValidation_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -70,12 +75,59 @@ public void unbind(DataBindingEpoxyModel.DataBindingHolder object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public DataBindingModelWithAllFieldTypesNoValidation_ onUnbind(OnModelUnboundListener listener) { + public DataBindingModelWithAllFieldTypesNoValidation_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, + final DataBindingEpoxyModel.DataBindingHolder object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public DataBindingModelWithAllFieldTypesNoValidation_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final DataBindingEpoxyModel.DataBindingHolder object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public DataBindingModelWithAllFieldTypesNoValidation_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + public DataBindingModelWithAllFieldTypesNoValidation_ valueInt(int valueInt) { onMutation(); super.valueInt = valueInt; @@ -186,7 +238,8 @@ public double valueDouble() { return valueDouble; } - public DataBindingModelWithAllFieldTypesNoValidation_ valueDoubleWrapper(Double valueDoubleWrapper) { + public DataBindingModelWithAllFieldTypesNoValidation_ valueDoubleWrapper( + Double valueDoubleWrapper) { onMutation(); super.valueDoubleWrapper = valueDoubleWrapper; return this; @@ -226,7 +279,8 @@ public boolean valueBoolean() { return valueBoolean; } - public DataBindingModelWithAllFieldTypesNoValidation_ valueBooleanWrapper(Boolean valueBooleanWrapper) { + public DataBindingModelWithAllFieldTypesNoValidation_ valueBooleanWrapper( + Boolean valueBooleanWrapper) { onMutation(); super.valueBooleanWrapper = valueBooleanWrapper; return this; @@ -246,7 +300,8 @@ public int[] valueIntArray() { return valueIntArray; } - public DataBindingModelWithAllFieldTypesNoValidation_ valueObjectArray(Object[] valueObjectArray) { + public DataBindingModelWithAllFieldTypesNoValidation_ valueObjectArray( + Object[] valueObjectArray) { onMutation(); super.valueObjectArray = valueObjectArray; return this; @@ -330,7 +385,8 @@ public DataBindingModelWithAllFieldTypesNoValidation_ layout(@LayoutRes int arg0 } @Override - public DataBindingModelWithAllFieldTypesNoValidation_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public DataBindingModelWithAllFieldTypesNoValidation_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -454,6 +510,8 @@ protected void setDataBindingVariables(ViewDataBinding binding, EpoxyModel previ public DataBindingModelWithAllFieldTypesNoValidation_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; super.valueInt = 0; super.valueInteger = null; super.valueShort = (short) 0; @@ -497,6 +555,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((valueInt != that.valueInt)) { return false; } @@ -568,6 +632,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); long temp; result = 31 * result + valueInt; result = 31 * result + (valueInteger != null ? valueInteger.hashCode() : 0); diff --git a/epoxy-processortest/src/test/resources/DataBindingModelWithAllFieldTypes_.java b/epoxy-processortest/src/test/resources/DataBindingModelWithAllFieldTypes_.java index c14bf25080..a2f6807df3 100644 --- a/epoxy-processortest/src/test/resources/DataBindingModelWithAllFieldTypes_.java +++ b/epoxy-processortest/src/test/resources/DataBindingModelWithAllFieldTypes_.java @@ -27,6 +27,10 @@ public class DataBindingModelWithAllFieldTypes_ extends DataBindingModelWithAllF private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + public DataBindingModelWithAllFieldTypes_() { super(); } @@ -58,7 +62,8 @@ public void handlePostBind(final DataBindingEpoxyModel.DataBindingHolder object, * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public DataBindingModelWithAllFieldTypes_ onBind(OnModelBoundListener listener) { + public DataBindingModelWithAllFieldTypes_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -79,12 +84,59 @@ public void unbind(DataBindingEpoxyModel.DataBindingHolder object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public DataBindingModelWithAllFieldTypes_ onUnbind(OnModelUnboundListener listener) { + public DataBindingModelWithAllFieldTypes_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, + final DataBindingEpoxyModel.DataBindingHolder object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public DataBindingModelWithAllFieldTypes_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final DataBindingEpoxyModel.DataBindingHolder object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public DataBindingModelWithAllFieldTypes_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + public DataBindingModelWithAllFieldTypes_ valueInt(int valueInt) { onMutation(); super.valueInt = valueInt; @@ -339,7 +391,8 @@ public DataBindingModelWithAllFieldTypes_ layout(@LayoutRes int arg0) { } @Override - public DataBindingModelWithAllFieldTypes_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public DataBindingModelWithAllFieldTypes_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -505,6 +558,8 @@ protected void setDataBindingVariables(ViewDataBinding binding, EpoxyModel previ public DataBindingModelWithAllFieldTypes_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; super.valueInt = 0; super.valueInteger = null; super.valueShort = (short) 0; @@ -548,6 +603,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((valueInt != that.valueInt)) { return false; } @@ -619,6 +680,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); long temp; result = 31 * result + valueInt; result = 31 * result + (valueInteger != null ? valueInteger.hashCode() : 0); diff --git a/epoxy-processortest/src/test/resources/DefaultPackageLayoutPatternViewModel_.java b/epoxy-processortest/src/test/resources/DefaultPackageLayoutPatternViewModel_.java index db107a2e09..953ee1deb9 100644 --- a/epoxy-processortest/src/test/resources/DefaultPackageLayoutPatternViewModel_.java +++ b/epoxy-processortest/src/test/resources/DefaultPackageLayoutPatternViewModel_.java @@ -18,6 +18,10 @@ public class DefaultPackageLayoutPatternViewModel_ extends EpoxyModel onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + @Override public void addTo(EpoxyController controller) { super.addTo(controller); @@ -60,7 +64,8 @@ public void handlePostBind(final DefaultPackageLayoutPatternView object, int pos * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public DefaultPackageLayoutPatternViewModel_ onBind(OnModelBoundListener listener) { + public DefaultPackageLayoutPatternViewModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -81,12 +86,59 @@ public void unbind(DefaultPackageLayoutPatternView object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public DefaultPackageLayoutPatternViewModel_ onUnbind(OnModelUnboundListener listener) { + public DefaultPackageLayoutPatternViewModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, + final DefaultPackageLayoutPatternView object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public DefaultPackageLayoutPatternViewModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final DefaultPackageLayoutPatternView object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public DefaultPackageLayoutPatternViewModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + @Override public DefaultPackageLayoutPatternViewModel_ id(long id) { super.id(id); @@ -131,7 +183,8 @@ public DefaultPackageLayoutPatternViewModel_ layout(@LayoutRes int arg0) { } @Override - public DefaultPackageLayoutPatternViewModel_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public DefaultPackageLayoutPatternViewModel_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -164,6 +217,8 @@ protected int getDefaultLayout() { public DefaultPackageLayoutPatternViewModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); super.reset(); return this; @@ -187,6 +242,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } return true; } @@ -195,6 +256,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); return result; } diff --git a/epoxy-processortest/src/test/resources/DoNotHashViewModel_.java b/epoxy-processortest/src/test/resources/DoNotHashViewModel_.java index 51fb1e580c..dc9d4653a2 100644 --- a/epoxy-processortest/src/test/resources/DoNotHashViewModel_.java +++ b/epoxy-processortest/src/test/resources/DoNotHashViewModel_.java @@ -22,6 +22,10 @@ public class DoNotHashViewModel_ extends EpoxyModel implements Ge private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + /** * Bitset index: 0 */ @NonNull @@ -103,7 +107,8 @@ public void handlePostBind(final DoNotHashView object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public DoNotHashViewModel_ onBind(OnModelBoundListener listener) { + public DoNotHashViewModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -124,12 +129,58 @@ public void unbind(DoNotHashView object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public DoNotHashViewModel_ onUnbind(OnModelUnboundListener listener) { + public DoNotHashViewModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final DoNotHashView object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public DoNotHashViewModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final DoNotHashView object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public DoNotHashViewModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + /** * Required. * @@ -152,7 +203,8 @@ public CharSequence title() { /** * Set a click listener that will provide the parent view, model, and adapter position of the clicked view. This will clear the normal View.OnClickListener if one has been set */ - public DoNotHashViewModel_ clickListener(@NonNull final OnModelClickListener clickListener) { + public DoNotHashViewModel_ clickListener( + @NonNull final OnModelClickListener clickListener) { assignedAttributes_epoxyGeneratedModel.set(1); onMutation(); if (clickListener == null) { @@ -280,6 +332,8 @@ protected int getDefaultLayout() { public DoNotHashViewModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); this.title_CharSequence = null; this.clickListener_OnClickListener = null; @@ -306,6 +360,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if (((title_CharSequence == null) != (that.title_CharSequence == null))) { return false; } @@ -323,6 +383,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (title_CharSequence != null ? 1 : 0); result = 31 * result + (clickListener_OnClickListener != null ? 1 : 0); result = 31 * result + (normalProp_CharSequence != null ? normalProp_CharSequence.hashCode() : 0); diff --git a/epoxy-processortest/src/test/resources/EpoxyModelGroupWithAnnotations_.java b/epoxy-processortest/src/test/resources/EpoxyModelGroupWithAnnotations_.java index 58e2e765b2..771cd6bcbe 100644 --- a/epoxy-processortest/src/test/resources/EpoxyModelGroupWithAnnotations_.java +++ b/epoxy-processortest/src/test/resources/EpoxyModelGroupWithAnnotations_.java @@ -16,6 +16,10 @@ public class EpoxyModelGroupWithAnnotations_ extends EpoxyModelGroupWithAnnotati private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + public EpoxyModelGroupWithAnnotations_(int layoutRes, Collection> models) { super(layoutRes, models); @@ -50,7 +54,8 @@ public void handlePostBind(final EpoxyModelGroup.Holder object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public EpoxyModelGroupWithAnnotations_ onBind(OnModelBoundListener listener) { + public EpoxyModelGroupWithAnnotations_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -71,12 +76,58 @@ public void unbind(EpoxyModelGroup.Holder object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public EpoxyModelGroupWithAnnotations_ onUnbind(OnModelUnboundListener listener) { + public EpoxyModelGroupWithAnnotations_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final EpoxyModelGroup.Holder object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public EpoxyModelGroupWithAnnotations_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final EpoxyModelGroup.Holder object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public EpoxyModelGroupWithAnnotations_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + public EpoxyModelGroupWithAnnotations_ value(int value) { onMutation(); super.value = value; @@ -131,7 +182,8 @@ public EpoxyModelGroupWithAnnotations_ layout(@LayoutRes int arg0) { } @Override - public EpoxyModelGroupWithAnnotations_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public EpoxyModelGroupWithAnnotations_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -158,6 +210,8 @@ public EpoxyModelGroupWithAnnotations_ hide() { public EpoxyModelGroupWithAnnotations_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; super.value = 0; super.reset(); return this; @@ -181,6 +235,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((value != that.value)) { return false; } @@ -192,6 +252,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + value; return result; } diff --git a/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethodNextParentLayout$NoLayout_.java b/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethodNextParentLayout$NoLayout_.java index 36114ca727..f9bdd45cc8 100755 --- a/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethodNextParentLayout$NoLayout_.java +++ b/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethodNextParentLayout$NoLayout_.java @@ -15,6 +15,10 @@ public class GenerateDefaultLayoutMethodNextParentLayout$NoLayout_ extends Gener private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + public GenerateDefaultLayoutMethodNextParentLayout$NoLayout_() { super(); } @@ -45,7 +49,8 @@ public void handlePostBind(final Object object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public GenerateDefaultLayoutMethodNextParentLayout$NoLayout_ onBind(OnModelBoundListener listener) { + public GenerateDefaultLayoutMethodNextParentLayout$NoLayout_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -66,12 +71,58 @@ public void unbind(Object object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public GenerateDefaultLayoutMethodNextParentLayout$NoLayout_ onUnbind(OnModelUnboundListener listener) { + public GenerateDefaultLayoutMethodNextParentLayout$NoLayout_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final Object object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public GenerateDefaultLayoutMethodNextParentLayout$NoLayout_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final Object object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public GenerateDefaultLayoutMethodNextParentLayout$NoLayout_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + public GenerateDefaultLayoutMethodNextParentLayout$NoLayout_ value(int value) { onMutation(); super.value = value; @@ -127,7 +178,8 @@ public int value() { } @Override - public GenerateDefaultLayoutMethodNextParentLayout$NoLayout_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public GenerateDefaultLayoutMethodNextParentLayout$NoLayout_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -160,6 +212,8 @@ protected int getDefaultLayout() { public GenerateDefaultLayoutMethodNextParentLayout$NoLayout_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; super.value = 0; super.reset(); return this; @@ -183,6 +237,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((value != that.value)) { return false; } @@ -194,6 +254,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + value; return result; } diff --git a/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethodNextParentLayout$StillNoLayout_.java b/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethodNextParentLayout$StillNoLayout_.java index 4446defed1..b874a89c32 100755 --- a/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethodNextParentLayout$StillNoLayout_.java +++ b/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethodNextParentLayout$StillNoLayout_.java @@ -15,6 +15,10 @@ public class GenerateDefaultLayoutMethodNextParentLayout$StillNoLayout_ extends private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + public GenerateDefaultLayoutMethodNextParentLayout$StillNoLayout_() { super(); } @@ -45,7 +49,8 @@ public void handlePostBind(final Object object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public GenerateDefaultLayoutMethodNextParentLayout$StillNoLayout_ onBind(OnModelBoundListener listener) { + public GenerateDefaultLayoutMethodNextParentLayout$StillNoLayout_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -66,12 +71,58 @@ public void unbind(Object object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public GenerateDefaultLayoutMethodNextParentLayout$StillNoLayout_ onUnbind(OnModelUnboundListener listener) { + public GenerateDefaultLayoutMethodNextParentLayout$StillNoLayout_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final Object object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public GenerateDefaultLayoutMethodNextParentLayout$StillNoLayout_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final Object object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public GenerateDefaultLayoutMethodNextParentLayout$StillNoLayout_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + @Override public GenerateDefaultLayoutMethodNextParentLayout$StillNoLayout_ id(long id) { super.id(id); @@ -91,7 +142,8 @@ public void unbind(Object object) { } @Override - public GenerateDefaultLayoutMethodNextParentLayout$StillNoLayout_ id(@Nullable CharSequence arg0) { + public GenerateDefaultLayoutMethodNextParentLayout$StillNoLayout_ id( + @Nullable CharSequence arg0) { super.id(arg0); return this; } @@ -117,7 +169,8 @@ public void unbind(Object object) { } @Override - public GenerateDefaultLayoutMethodNextParentLayout$StillNoLayout_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public GenerateDefaultLayoutMethodNextParentLayout$StillNoLayout_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -150,6 +203,8 @@ protected int getDefaultLayout() { public GenerateDefaultLayoutMethodNextParentLayout$StillNoLayout_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; super.reset(); return this; } @@ -172,6 +227,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } return true; } @@ -180,6 +241,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); return result; } diff --git a/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethodNextParentLayout$WithLayout_.java b/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethodNextParentLayout$WithLayout_.java index b3ffd2e514..2242448a4b 100755 --- a/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethodNextParentLayout$WithLayout_.java +++ b/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethodNextParentLayout$WithLayout_.java @@ -15,6 +15,10 @@ public class GenerateDefaultLayoutMethodNextParentLayout$WithLayout_ extends Gen private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + public GenerateDefaultLayoutMethodNextParentLayout$WithLayout_() { super(); } @@ -45,7 +49,8 @@ public void handlePostBind(final Object object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public GenerateDefaultLayoutMethodNextParentLayout$WithLayout_ onBind(OnModelBoundListener listener) { + public GenerateDefaultLayoutMethodNextParentLayout$WithLayout_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -66,12 +71,58 @@ public void unbind(Object object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public GenerateDefaultLayoutMethodNextParentLayout$WithLayout_ onUnbind(OnModelUnboundListener listener) { + public GenerateDefaultLayoutMethodNextParentLayout$WithLayout_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final Object object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public GenerateDefaultLayoutMethodNextParentLayout$WithLayout_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final Object object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public GenerateDefaultLayoutMethodNextParentLayout$WithLayout_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + @Override public GenerateDefaultLayoutMethodNextParentLayout$WithLayout_ id(long id) { super.id(id); @@ -117,7 +168,8 @@ public void unbind(Object object) { } @Override - public GenerateDefaultLayoutMethodNextParentLayout$WithLayout_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public GenerateDefaultLayoutMethodNextParentLayout$WithLayout_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -150,6 +202,8 @@ protected int getDefaultLayout() { public GenerateDefaultLayoutMethodNextParentLayout$WithLayout_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; super.reset(); return this; } @@ -172,6 +226,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } return true; } @@ -180,6 +240,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); return result; } diff --git a/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethodParentLayout$NoLayout_.java b/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethodParentLayout$NoLayout_.java index f00fb86125..9c4d9d04e6 100755 --- a/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethodParentLayout$NoLayout_.java +++ b/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethodParentLayout$NoLayout_.java @@ -15,6 +15,10 @@ public class GenerateDefaultLayoutMethodParentLayout$NoLayout_ extends GenerateD private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + public GenerateDefaultLayoutMethodParentLayout$NoLayout_() { super(); } @@ -45,7 +49,8 @@ public void handlePostBind(final Object object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public GenerateDefaultLayoutMethodParentLayout$NoLayout_ onBind(OnModelBoundListener listener) { + public GenerateDefaultLayoutMethodParentLayout$NoLayout_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -66,12 +71,58 @@ public void unbind(Object object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public GenerateDefaultLayoutMethodParentLayout$NoLayout_ onUnbind(OnModelUnboundListener listener) { + public GenerateDefaultLayoutMethodParentLayout$NoLayout_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final Object object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public GenerateDefaultLayoutMethodParentLayout$NoLayout_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final Object object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public GenerateDefaultLayoutMethodParentLayout$NoLayout_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + public GenerateDefaultLayoutMethodParentLayout$NoLayout_ value(int value) { onMutation(); super.value = value; @@ -127,7 +178,8 @@ public int value() { } @Override - public GenerateDefaultLayoutMethodParentLayout$NoLayout_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public GenerateDefaultLayoutMethodParentLayout$NoLayout_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -160,6 +212,8 @@ protected int getDefaultLayout() { public GenerateDefaultLayoutMethodParentLayout$NoLayout_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; super.value = 0; super.reset(); return this; @@ -183,6 +237,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((value != that.value)) { return false; } @@ -194,6 +254,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + value; return result; } diff --git a/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethodParentLayout$WithLayout_.java b/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethodParentLayout$WithLayout_.java index f04fc10d6d..83fe9ceec7 100755 --- a/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethodParentLayout$WithLayout_.java +++ b/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethodParentLayout$WithLayout_.java @@ -15,6 +15,10 @@ public class GenerateDefaultLayoutMethodParentLayout$WithLayout_ extends Generat private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + public GenerateDefaultLayoutMethodParentLayout$WithLayout_() { super(); } @@ -45,7 +49,8 @@ public void handlePostBind(final Object object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public GenerateDefaultLayoutMethodParentLayout$WithLayout_ onBind(OnModelBoundListener listener) { + public GenerateDefaultLayoutMethodParentLayout$WithLayout_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -66,12 +71,58 @@ public void unbind(Object object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public GenerateDefaultLayoutMethodParentLayout$WithLayout_ onUnbind(OnModelUnboundListener listener) { + public GenerateDefaultLayoutMethodParentLayout$WithLayout_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final Object object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public GenerateDefaultLayoutMethodParentLayout$WithLayout_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final Object object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public GenerateDefaultLayoutMethodParentLayout$WithLayout_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + @Override public GenerateDefaultLayoutMethodParentLayout$WithLayout_ id(long id) { super.id(id); @@ -117,7 +168,8 @@ public void unbind(Object object) { } @Override - public GenerateDefaultLayoutMethodParentLayout$WithLayout_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public GenerateDefaultLayoutMethodParentLayout$WithLayout_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -150,6 +202,8 @@ protected int getDefaultLayout() { public GenerateDefaultLayoutMethodParentLayout$WithLayout_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; super.reset(); return this; } @@ -172,6 +226,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } return true; } @@ -180,6 +240,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); return result; } diff --git a/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethod_.java b/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethod_.java index fc2cbeaa1b..4ae47d590c 100755 --- a/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethod_.java +++ b/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethod_.java @@ -15,6 +15,10 @@ public class GenerateDefaultLayoutMethod_ extends GenerateDefaultLayoutMethod im private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + public GenerateDefaultLayoutMethod_() { super(); } @@ -45,7 +49,8 @@ public void handlePostBind(final Object object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public GenerateDefaultLayoutMethod_ onBind(OnModelBoundListener listener) { + public GenerateDefaultLayoutMethod_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -66,12 +71,58 @@ public void unbind(Object object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public GenerateDefaultLayoutMethod_ onUnbind(OnModelUnboundListener listener) { + public GenerateDefaultLayoutMethod_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final Object object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public GenerateDefaultLayoutMethod_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final Object object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public GenerateDefaultLayoutMethod_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + public GenerateDefaultLayoutMethod_ value(int value) { onMutation(); super.value = value; @@ -126,7 +177,8 @@ public GenerateDefaultLayoutMethod_ layout(@LayoutRes int arg0) { } @Override - public GenerateDefaultLayoutMethod_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public GenerateDefaultLayoutMethod_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -159,6 +211,8 @@ protected int getDefaultLayout() { public GenerateDefaultLayoutMethod_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; super.value = 0; super.reset(); return this; @@ -182,6 +236,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((value != that.value)) { return false; } @@ -193,6 +253,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + value; return result; } diff --git a/epoxy-processortest/src/test/resources/GeneratedModelSuffixViewSuffix_.java b/epoxy-processortest/src/test/resources/GeneratedModelSuffixViewSuffix_.java index f54069183b..a02ebbaaea 100644 --- a/epoxy-processortest/src/test/resources/GeneratedModelSuffixViewSuffix_.java +++ b/epoxy-processortest/src/test/resources/GeneratedModelSuffixViewSuffix_.java @@ -18,6 +18,10 @@ public class GeneratedModelSuffixViewSuffix_ extends EpoxyModel onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + @Override public void addTo(EpoxyController controller) { super.addTo(controller); @@ -60,7 +64,8 @@ public void handlePostBind(final GeneratedModelSuffixView object, int position) * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public GeneratedModelSuffixViewSuffix_ onBind(OnModelBoundListener listener) { + public GeneratedModelSuffixViewSuffix_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -81,12 +86,58 @@ public void unbind(GeneratedModelSuffixView object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public GeneratedModelSuffixViewSuffix_ onUnbind(OnModelUnboundListener listener) { + public GeneratedModelSuffixViewSuffix_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final GeneratedModelSuffixView object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public GeneratedModelSuffixViewSuffix_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final GeneratedModelSuffixView object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public GeneratedModelSuffixViewSuffix_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + @Override public GeneratedModelSuffixViewSuffix_ id(long id) { super.id(id); @@ -131,7 +182,8 @@ public GeneratedModelSuffixViewSuffix_ layout(@LayoutRes int arg0) { } @Override - public GeneratedModelSuffixViewSuffix_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public GeneratedModelSuffixViewSuffix_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -164,6 +216,8 @@ protected int getDefaultLayout() { public GeneratedModelSuffixViewSuffix_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); super.reset(); return this; @@ -187,6 +241,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } return true; } @@ -195,6 +255,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); return result; } diff --git a/epoxy-processortest/src/test/resources/GridSpanCountViewModel_.java b/epoxy-processortest/src/test/resources/GridSpanCountViewModel_.java index 86f3d8f752..44f5b747e5 100644 --- a/epoxy-processortest/src/test/resources/GridSpanCountViewModel_.java +++ b/epoxy-processortest/src/test/resources/GridSpanCountViewModel_.java @@ -21,6 +21,10 @@ public class GridSpanCountViewModel_ extends EpoxyModel imple private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + /** * Bitset index: 0 */ @NonNull @@ -76,7 +80,8 @@ public void handlePostBind(final GridSpanCountView object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public GridSpanCountViewModel_ onBind(OnModelBoundListener listener) { + public GridSpanCountViewModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -97,12 +102,58 @@ public void unbind(GridSpanCountView object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public GridSpanCountViewModel_ onUnbind(OnModelUnboundListener listener) { + public GridSpanCountViewModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final GridSpanCountView object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public GridSpanCountViewModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final GridSpanCountView object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public GridSpanCountViewModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + /** * Required. * @@ -166,7 +217,8 @@ public GridSpanCountViewModel_ layout(@LayoutRes int arg0) { } @Override - public GridSpanCountViewModel_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public GridSpanCountViewModel_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -199,6 +251,8 @@ protected int getDefaultLayout() { public GridSpanCountViewModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); this.clickListener_String = null; super.reset(); @@ -223,6 +277,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((clickListener_String != null ? !clickListener_String.equals(that.clickListener_String) : that.clickListener_String != null)) { return false; } @@ -234,6 +294,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (clickListener_String != null ? clickListener_String.hashCode() : 0); return result; } diff --git a/epoxy-processortest/src/test/resources/IgnoreRequireHashCodeViewModel_.java b/epoxy-processortest/src/test/resources/IgnoreRequireHashCodeViewModel_.java index 8425af4388..a6f63bf08c 100644 --- a/epoxy-processortest/src/test/resources/IgnoreRequireHashCodeViewModel_.java +++ b/epoxy-processortest/src/test/resources/IgnoreRequireHashCodeViewModel_.java @@ -22,6 +22,10 @@ public class IgnoreRequireHashCodeViewModel_ extends EpoxyModel onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + /** * Bitset index: 0 */ @NonNull @@ -77,7 +81,8 @@ public void handlePostBind(final IgnoreRequireHashCodeView object, int position) * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public IgnoreRequireHashCodeViewModel_ onBind(OnModelBoundListener listener) { + public IgnoreRequireHashCodeViewModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -98,15 +103,62 @@ public void unbind(IgnoreRequireHashCodeView object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public IgnoreRequireHashCodeViewModel_ onUnbind(OnModelUnboundListener listener) { + public IgnoreRequireHashCodeViewModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final IgnoreRequireHashCodeView object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public IgnoreRequireHashCodeViewModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final IgnoreRequireHashCodeView object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public IgnoreRequireHashCodeViewModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + /** * Set a click listener that will provide the parent view, model, and adapter position of the clicked view. This will clear the normal View.OnClickListener if one has been set */ - public IgnoreRequireHashCodeViewModel_ clickListener(@NonNull final OnModelClickListener clickListener) { + public IgnoreRequireHashCodeViewModel_ clickListener( + @NonNull final OnModelClickListener clickListener) { assignedAttributes_epoxyGeneratedModel.set(0); onMutation(); if (clickListener == null) { @@ -123,7 +175,8 @@ public IgnoreRequireHashCodeViewModel_ clickListener(@NonNull final OnModelClick * * @see IgnoreRequireHashCodeView#setClickListener(View.OnClickListener) */ - public IgnoreRequireHashCodeViewModel_ clickListener(@NonNull View.OnClickListener clickListener) { + public IgnoreRequireHashCodeViewModel_ clickListener( + @NonNull View.OnClickListener clickListener) { if (clickListener == null) { throw new IllegalArgumentException("clickListener cannot be null"); } @@ -182,7 +235,8 @@ public IgnoreRequireHashCodeViewModel_ layout(@LayoutRes int arg0) { } @Override - public IgnoreRequireHashCodeViewModel_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public IgnoreRequireHashCodeViewModel_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -215,6 +269,8 @@ protected int getDefaultLayout() { public IgnoreRequireHashCodeViewModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); this.clickListener_OnClickListener = null; super.reset(); @@ -239,6 +295,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((clickListener_OnClickListener != null ? !clickListener_OnClickListener.equals(that.clickListener_OnClickListener) : that.clickListener_OnClickListener != null)) { return false; } @@ -250,6 +312,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (clickListener_OnClickListener != null ? clickListener_OnClickListener.hashCode() : 0); return result; } diff --git a/epoxy-processortest/src/test/resources/LayoutOverloadsViewModel_.java b/epoxy-processortest/src/test/resources/LayoutOverloadsViewModel_.java index 1c35c861a2..7ed092baaf 100644 --- a/epoxy-processortest/src/test/resources/LayoutOverloadsViewModel_.java +++ b/epoxy-processortest/src/test/resources/LayoutOverloadsViewModel_.java @@ -18,6 +18,10 @@ public class LayoutOverloadsViewModel_ extends EpoxyModel i private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + @Override public void addTo(EpoxyController controller) { super.addTo(controller); @@ -60,7 +64,8 @@ public void handlePostBind(final LayoutOverloadsView object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public LayoutOverloadsViewModel_ onBind(OnModelBoundListener listener) { + public LayoutOverloadsViewModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -81,12 +86,58 @@ public void unbind(LayoutOverloadsView object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public LayoutOverloadsViewModel_ onUnbind(OnModelUnboundListener listener) { + public LayoutOverloadsViewModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final LayoutOverloadsView object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public LayoutOverloadsViewModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final LayoutOverloadsView object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public LayoutOverloadsViewModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + @Override public LayoutOverloadsViewModel_ id(long id) { super.id(id); @@ -130,7 +181,8 @@ public LayoutOverloadsViewModel_ layout(@LayoutRes int arg0) { } @Override - public LayoutOverloadsViewModel_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public LayoutOverloadsViewModel_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -173,6 +225,8 @@ public LayoutOverloadsViewModel_ withTwoLayout() { public LayoutOverloadsViewModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); super.reset(); return this; @@ -196,6 +250,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } return true; } @@ -204,6 +264,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); return result; } diff --git a/epoxy-processortest/src/test/resources/ModelDoNotHash_.java b/epoxy-processortest/src/test/resources/ModelDoNotHash_.java index 90d5d4ee8e..8039b70cf8 100644 --- a/epoxy-processortest/src/test/resources/ModelDoNotHash_.java +++ b/epoxy-processortest/src/test/resources/ModelDoNotHash_.java @@ -15,6 +15,10 @@ public class ModelDoNotHash_ extends ModelDoNotHash implements GeneratedModel onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + public ModelDoNotHash_() { super(); } @@ -72,6 +76,51 @@ public ModelDoNotHash_ onUnbind(OnModelUnboundListener return this; } + @Override + public void visibilityStateChanged(int visibilityState, final Object object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelDoNotHash_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final Object object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelDoNotHash_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + public ModelDoNotHash_ value(int value) { onMutation(); super.value = value; @@ -172,6 +221,8 @@ public ModelDoNotHash_ hide() { public ModelDoNotHash_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; super.value = 0; super.value2 = 0; super.value3 = null; @@ -197,6 +248,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((value != that.value)) { return false; } @@ -211,6 +268,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + value; result = 31 * result + (value3 != null ? 1 : 0); return result; diff --git a/epoxy-processortest/src/test/resources/ModelDoNotUseInToString_.java b/epoxy-processortest/src/test/resources/ModelDoNotUseInToString_.java index 732c6f3193..d753420b6c 100644 --- a/epoxy-processortest/src/test/resources/ModelDoNotUseInToString_.java +++ b/epoxy-processortest/src/test/resources/ModelDoNotUseInToString_.java @@ -15,6 +15,10 @@ public class ModelDoNotUseInToString_ extends ModelDoNotUseInToString implements private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + public ModelDoNotUseInToString_() { super(); } @@ -45,7 +49,8 @@ public void handlePostBind(final Object object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelDoNotUseInToString_ onBind(OnModelBoundListener listener) { + public ModelDoNotUseInToString_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -66,12 +71,58 @@ public void unbind(Object object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelDoNotUseInToString_ onUnbind(OnModelUnboundListener listener) { + public ModelDoNotUseInToString_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final Object object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelDoNotUseInToString_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final Object object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelDoNotUseInToString_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + public ModelDoNotUseInToString_ value(int value) { onMutation(); super.value = value; @@ -145,7 +196,8 @@ public ModelDoNotUseInToString_ layout(@LayoutRes int arg0) { } @Override - public ModelDoNotUseInToString_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public ModelDoNotUseInToString_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -172,6 +224,8 @@ public ModelDoNotUseInToString_ hide() { public ModelDoNotUseInToString_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; super.value = 0; super.value2 = 0; super.value3 = null; @@ -197,6 +251,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((value != that.value)) { return false; } @@ -214,6 +274,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + value; result = 31 * result + value2; result = 31 * result + (value3 != null ? value3.hashCode() : 0); diff --git a/epoxy-processortest/src/test/resources/ModelForRProcessingTest_.java b/epoxy-processortest/src/test/resources/ModelForRProcessingTest_.java index b45f6b3206..7fdbe00d2a 100755 --- a/epoxy-processortest/src/test/resources/ModelForRProcessingTest_.java +++ b/epoxy-processortest/src/test/resources/ModelForRProcessingTest_.java @@ -15,6 +15,10 @@ public class ModelForRProcessingTest_ extends ModelForRProcessingTest implements private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + public ModelForRProcessingTest_() { super(); } @@ -45,7 +49,8 @@ public void handlePostBind(final Object object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelForRProcessingTest_ onBind(OnModelBoundListener listener) { + public ModelForRProcessingTest_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -66,12 +71,58 @@ public void unbind(Object object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelForRProcessingTest_ onUnbind(OnModelUnboundListener listener) { + public ModelForRProcessingTest_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final Object object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelForRProcessingTest_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final Object object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelForRProcessingTest_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + public ModelForRProcessingTest_ value(int value) { onMutation(); super.value = value; @@ -125,7 +176,8 @@ public ModelForRProcessingTest_ layout(@LayoutRes int arg0) { } @Override - public ModelForRProcessingTest_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public ModelForRProcessingTest_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -158,6 +210,8 @@ protected int getDefaultLayout() { public ModelForRProcessingTest_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; super.value = 0; super.reset(); return this; @@ -181,6 +235,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((value != that.value)) { return false; } @@ -192,6 +252,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + value; return result; } diff --git a/epoxy-processortest/src/test/resources/ModelForTestingDuplicateRValues_.java b/epoxy-processortest/src/test/resources/ModelForTestingDuplicateRValues_.java index 727b85f2df..cad25caf15 100644 --- a/epoxy-processortest/src/test/resources/ModelForTestingDuplicateRValues_.java +++ b/epoxy-processortest/src/test/resources/ModelForTestingDuplicateRValues_.java @@ -16,6 +16,10 @@ public class ModelForTestingDuplicateRValues_ extends ModelForTestingDuplicateRV private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + public ModelForTestingDuplicateRValues_() { super(); } @@ -46,7 +50,8 @@ public void handlePostBind(final Object object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelForTestingDuplicateRValues_ onBind(OnModelBoundListener listener) { + public ModelForTestingDuplicateRValues_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -67,12 +72,58 @@ public void unbind(Object object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelForTestingDuplicateRValues_ onUnbind(OnModelUnboundListener listener) { + public ModelForTestingDuplicateRValues_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final Object object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelForTestingDuplicateRValues_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final Object object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelForTestingDuplicateRValues_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + public ModelForTestingDuplicateRValues_ value(int value) { onMutation(); super.value = value; @@ -127,7 +178,8 @@ public ModelForTestingDuplicateRValues_ layout(@LayoutRes int arg0) { } @Override - public ModelForTestingDuplicateRValues_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public ModelForTestingDuplicateRValues_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -160,6 +212,8 @@ protected int getDefaultLayout() { public ModelForTestingDuplicateRValues_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; super.value = 0; super.reset(); return this; @@ -183,6 +237,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((value != that.value)) { return false; } @@ -194,6 +254,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + value; return result; } diff --git a/epoxy-processortest/src/test/resources/ModelNoValidation_.java b/epoxy-processortest/src/test/resources/ModelNoValidation_.java index 86878b32e0..d790f11807 100644 --- a/epoxy-processortest/src/test/resources/ModelNoValidation_.java +++ b/epoxy-processortest/src/test/resources/ModelNoValidation_.java @@ -15,6 +15,10 @@ public class ModelNoValidation_ extends ModelNoValidation implements GeneratedMo private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + public ModelNoValidation_() { super(); } @@ -64,6 +68,51 @@ public ModelNoValidation_ onUnbind(OnModelUnboundListener + * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelNoValidation_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final Object object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelNoValidation_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + public ModelNoValidation_ value(int value) { onMutation(); super.value = value; @@ -144,6 +193,8 @@ public ModelNoValidation_ hide() { public ModelNoValidation_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; super.value = 0; super.reset(); return this; @@ -167,6 +218,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((value != that.value)) { return false; } @@ -178,6 +235,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + value; return result; } diff --git a/epoxy-processortest/src/test/resources/ModelReturningClassTypeWithVarargs_.java b/epoxy-processortest/src/test/resources/ModelReturningClassTypeWithVarargs_.java index 96448d3bfc..5687a68516 100755 --- a/epoxy-processortest/src/test/resources/ModelReturningClassTypeWithVarargs_.java +++ b/epoxy-processortest/src/test/resources/ModelReturningClassTypeWithVarargs_.java @@ -15,6 +15,10 @@ public class ModelReturningClassTypeWithVarargs_ extends ModelReturningClassType private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + public ModelReturningClassTypeWithVarargs_() { super(); } @@ -45,7 +49,8 @@ public void handlePostBind(final Object object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelReturningClassTypeWithVarargs_ onBind(OnModelBoundListener listener) { + public ModelReturningClassTypeWithVarargs_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -66,12 +71,58 @@ public void unbind(Object object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelReturningClassTypeWithVarargs_ onUnbind(OnModelUnboundListener listener) { + public ModelReturningClassTypeWithVarargs_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final Object object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelReturningClassTypeWithVarargs_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final Object object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelReturningClassTypeWithVarargs_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + public ModelReturningClassTypeWithVarargs_ value(int value) { onMutation(); super.value = value; @@ -138,7 +189,8 @@ public ModelReturningClassTypeWithVarargs_ layout(@LayoutRes int arg0) { } @Override - public ModelReturningClassTypeWithVarargs_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public ModelReturningClassTypeWithVarargs_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -165,6 +217,8 @@ public ModelReturningClassTypeWithVarargs_ hide() { public ModelReturningClassTypeWithVarargs_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; super.value = 0; super.reset(); return this; @@ -188,6 +242,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((value != that.value)) { return false; } @@ -199,6 +259,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + value; return result; } diff --git a/epoxy-processortest/src/test/resources/ModelReturningClassType_.java b/epoxy-processortest/src/test/resources/ModelReturningClassType_.java index 043fe5f23f..c456ff9e7e 100755 --- a/epoxy-processortest/src/test/resources/ModelReturningClassType_.java +++ b/epoxy-processortest/src/test/resources/ModelReturningClassType_.java @@ -16,6 +16,10 @@ public class ModelReturningClassType_ extends ModelReturningClassType implements private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + public ModelReturningClassType_() { super(); } @@ -46,7 +50,8 @@ public void handlePostBind(final Object object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelReturningClassType_ onBind(OnModelBoundListener listener) { + public ModelReturningClassType_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -67,12 +72,58 @@ public void unbind(Object object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelReturningClassType_ onUnbind(OnModelUnboundListener listener) { + public ModelReturningClassType_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final Object object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelReturningClassType_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final Object object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelReturningClassType_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + public ModelReturningClassType_ value(int value) { onMutation(); super.value = value; @@ -144,7 +195,8 @@ public ModelReturningClassType_ layout(@LayoutRes int arg0) { } @Override - public ModelReturningClassType_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public ModelReturningClassType_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -171,6 +223,8 @@ public ModelReturningClassType_ hide() { public ModelReturningClassType_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; super.value = 0; super.reset(); return this; @@ -194,6 +248,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((value != that.value)) { return false; } @@ -205,6 +265,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + value; return result; } diff --git a/epoxy-processortest/src/test/resources/ModelViewExtendingSuperClassModel_.java b/epoxy-processortest/src/test/resources/ModelViewExtendingSuperClassModel_.java index 76c09bb4c6..d23ac76365 100644 --- a/epoxy-processortest/src/test/resources/ModelViewExtendingSuperClassModel_.java +++ b/epoxy-processortest/src/test/resources/ModelViewExtendingSuperClassModel_.java @@ -20,6 +20,10 @@ public class ModelViewExtendingSuperClassModel_ extends EpoxyModel onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + /** * Bitset index: 0 */ private int subClassValue_Int = 0; @@ -94,7 +98,8 @@ public void handlePostBind(final ModelViewExtendingSuperClass object, int positi * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelViewExtendingSuperClassModel_ onBind(OnModelBoundListener listener) { + public ModelViewExtendingSuperClassModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -117,12 +122,59 @@ public void unbind(ModelViewExtendingSuperClass object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelViewExtendingSuperClassModel_ onUnbind(OnModelUnboundListener listener) { + public ModelViewExtendingSuperClassModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, + final ModelViewExtendingSuperClass object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelViewExtendingSuperClassModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final ModelViewExtendingSuperClass object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelViewExtendingSuperClassModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + /** * Optional: Default value is 0 * @@ -198,7 +250,8 @@ public ModelViewExtendingSuperClassModel_ layout(@LayoutRes int arg0) { } @Override - public ModelViewExtendingSuperClassModel_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public ModelViewExtendingSuperClassModel_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -231,6 +284,8 @@ protected int getDefaultLayout() { public ModelViewExtendingSuperClassModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); this.subClassValue_Int = 0; this.superClassValue_Int = 0; @@ -256,6 +311,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((subClassValue_Int != that.subClassValue_Int)) { return false; } @@ -270,6 +331,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + subClassValue_Int; result = 31 * result + superClassValue_Int; return result; diff --git a/epoxy-processortest/src/test/resources/ModelViewSuperClassModel_.java b/epoxy-processortest/src/test/resources/ModelViewSuperClassModel_.java index 56ee5a4d7c..3c6730f999 100644 --- a/epoxy-processortest/src/test/resources/ModelViewSuperClassModel_.java +++ b/epoxy-processortest/src/test/resources/ModelViewSuperClassModel_.java @@ -20,6 +20,10 @@ public class ModelViewSuperClassModel_ extends EpoxyModel i private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + /** * Bitset index: 0 */ private int superClassValue_Int = 0; @@ -84,7 +88,8 @@ public void handlePostBind(final ModelViewSuperClass object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelViewSuperClassModel_ onBind(OnModelBoundListener listener) { + public ModelViewSuperClassModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -106,12 +111,58 @@ public void unbind(ModelViewSuperClass object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelViewSuperClassModel_ onUnbind(OnModelUnboundListener listener) { + public ModelViewSuperClassModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final ModelViewSuperClass object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelViewSuperClassModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final ModelViewSuperClass object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelViewSuperClassModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + /** * Optional: Default value is 0 * @@ -170,7 +221,8 @@ public ModelViewSuperClassModel_ layout(@LayoutRes int arg0) { } @Override - public ModelViewSuperClassModel_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public ModelViewSuperClassModel_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -203,6 +255,8 @@ protected int getDefaultLayout() { public ModelViewSuperClassModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); this.superClassValue_Int = 0; super.reset(); @@ -227,6 +281,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((superClassValue_Int != that.superClassValue_Int)) { return false; } @@ -238,6 +298,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + superClassValue_Int; return result; } diff --git a/epoxy-processortest/src/test/resources/ModelViewWithParisModel_.java b/epoxy-processortest/src/test/resources/ModelViewWithParisModel_.java index 67ca84d823..d734b8c672 100644 --- a/epoxy-processortest/src/test/resources/ModelViewWithParisModel_.java +++ b/epoxy-processortest/src/test/resources/ModelViewWithParisModel_.java @@ -37,6 +37,10 @@ public class ModelViewWithParisModel_ extends EpoxyModel imp private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + /** * Bitset index: 0 */ private int value_Int = 0; @@ -128,7 +132,8 @@ public void handlePostBind(final ModelViewWithParis object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelViewWithParisModel_ onBind(OnModelBoundListener listener) { + public ModelViewWithParisModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -149,12 +154,58 @@ public void unbind(ModelViewWithParis object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelViewWithParisModel_ onUnbind(OnModelUnboundListener listener) { + public ModelViewWithParisModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final ModelViewWithParis object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelViewWithParisModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final ModelViewWithParis object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelViewWithParisModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + public ModelViewWithParisModel_ style(Style style) { assignedAttributes_epoxyGeneratedModel.set(1); onMutation(); @@ -162,7 +213,8 @@ public ModelViewWithParisModel_ style(Style style) { return this; } - public ModelViewWithParisModel_ styleBuilder(StyleBuilderCallback builderCallback) { + public ModelViewWithParisModel_ styleBuilder( + StyleBuilderCallback builderCallback) { ModelViewWithParisStyleApplier.StyleBuilder builder = new ModelViewWithParisStyleApplier.StyleBuilder(); builderCallback.buildStyle(builder.addDefault()); return style(builder.build()); @@ -259,7 +311,8 @@ public ModelViewWithParisModel_ layout(@LayoutRes int arg0) { } @Override - public ModelViewWithParisModel_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public ModelViewWithParisModel_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -292,6 +345,8 @@ protected int getDefaultLayout() { public ModelViewWithParisModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); this.value_Int = 0; this.style = DEFAULT_PARIS_STYLE; @@ -317,6 +372,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((value_Int != that.value_Int)) { return false; } @@ -331,6 +392,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + value_Int; result = 31 * result + (style != null ? style.hashCode() : 0); return result; diff --git a/epoxy-processortest/src/test/resources/ModelWithAbstractClassAndAnnotation_.java b/epoxy-processortest/src/test/resources/ModelWithAbstractClassAndAnnotation_.java index eed0256035..2f792d8f91 100644 --- a/epoxy-processortest/src/test/resources/ModelWithAbstractClassAndAnnotation_.java +++ b/epoxy-processortest/src/test/resources/ModelWithAbstractClassAndAnnotation_.java @@ -15,6 +15,10 @@ public class ModelWithAbstractClassAndAnnotation_ extends ModelWithAbstractClass private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + public ModelWithAbstractClassAndAnnotation_() { super(); } @@ -45,7 +49,8 @@ public void handlePostBind(final Object object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelWithAbstractClassAndAnnotation_ onBind(OnModelBoundListener listener) { + public ModelWithAbstractClassAndAnnotation_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -66,12 +71,58 @@ public void unbind(Object object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelWithAbstractClassAndAnnotation_ onUnbind(OnModelUnboundListener listener) { + public ModelWithAbstractClassAndAnnotation_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final Object object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithAbstractClassAndAnnotation_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final Object object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithAbstractClassAndAnnotation_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + @Override public ModelWithAbstractClassAndAnnotation_ id(long id) { super.id(id); @@ -116,7 +167,8 @@ public ModelWithAbstractClassAndAnnotation_ layout(@LayoutRes int arg0) { } @Override - public ModelWithAbstractClassAndAnnotation_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public ModelWithAbstractClassAndAnnotation_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -143,6 +195,8 @@ public ModelWithAbstractClassAndAnnotation_ hide() { public ModelWithAbstractClassAndAnnotation_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; super.reset(); return this; } @@ -165,6 +219,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } return true; } @@ -173,6 +233,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); return result; } diff --git a/epoxy-processortest/src/test/resources/ModelWithAllFieldTypesBuilder.java b/epoxy-processortest/src/test/resources/ModelWithAllFieldTypesBuilder.java index 38ae3a6ebc..9272115857 100644 --- a/epoxy-processortest/src/test/resources/ModelWithAllFieldTypesBuilder.java +++ b/epoxy-processortest/src/test/resources/ModelWithAllFieldTypesBuilder.java @@ -17,9 +17,17 @@ import java.util.List; public interface ModelWithAllFieldTypesBuilder { - ModelWithAllFieldTypesBuilder onBind(OnModelBoundListener listener); + ModelWithAllFieldTypesBuilder onBind( + OnModelBoundListener listener); - ModelWithAllFieldTypesBuilder onUnbind(OnModelUnboundListener listener); + ModelWithAllFieldTypesBuilder onUnbind( + OnModelUnboundListener listener); + + ModelWithAllFieldTypesBuilder onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener); + + ModelWithAllFieldTypesBuilder onVisibilityChanged( + OnModelVisibilityChangedListener listener); ModelWithAllFieldTypesBuilder valueInt(int valueInt); @@ -77,5 +85,6 @@ public interface ModelWithAllFieldTypesBuilder { ModelWithAllFieldTypesBuilder layout(@LayoutRes int arg0); - ModelWithAllFieldTypesBuilder spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0); + ModelWithAllFieldTypesBuilder spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0); } \ No newline at end of file diff --git a/epoxy-processortest/src/test/resources/ModelWithAllFieldTypes_.java b/epoxy-processortest/src/test/resources/ModelWithAllFieldTypes_.java index 25fc4167c8..7f4b279728 100755 --- a/epoxy-processortest/src/test/resources/ModelWithAllFieldTypes_.java +++ b/epoxy-processortest/src/test/resources/ModelWithAllFieldTypes_.java @@ -25,6 +25,10 @@ public class ModelWithAllFieldTypes_ extends ModelWithAllFieldTypes implements G private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + public ModelWithAllFieldTypes_() { super(); } @@ -55,7 +59,8 @@ public void handlePostBind(final Object object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelWithAllFieldTypes_ onBind(OnModelBoundListener listener) { + public ModelWithAllFieldTypes_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -76,12 +81,58 @@ public void unbind(Object object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelWithAllFieldTypes_ onUnbind(OnModelUnboundListener listener) { + public ModelWithAllFieldTypes_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final Object object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithAllFieldTypes_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final Object object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithAllFieldTypes_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + public ModelWithAllFieldTypes_ valueInt(int valueInt) { onMutation(); super.valueInt = valueInt; @@ -335,7 +386,8 @@ public ModelWithAllFieldTypes_ layout(@LayoutRes int arg0) { } @Override - public ModelWithAllFieldTypes_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public ModelWithAllFieldTypes_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -362,6 +414,8 @@ public ModelWithAllFieldTypes_ hide() { public ModelWithAllFieldTypes_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; super.valueInt = 0; super.valueInteger = null; super.valueShort = (short) 0; @@ -405,6 +459,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((valueInt != that.valueInt)) { return false; } @@ -476,6 +536,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); long temp; result = 31 * result + valueInt; result = 31 * result + (valueInteger != null ? valueInteger.hashCode() : 0); diff --git a/epoxy-processortest/src/test/resources/ModelWithAllPrivateFieldTypes_.java b/epoxy-processortest/src/test/resources/ModelWithAllPrivateFieldTypes_.java index 2f1415af98..b732617b49 100755 --- a/epoxy-processortest/src/test/resources/ModelWithAllPrivateFieldTypes_.java +++ b/epoxy-processortest/src/test/resources/ModelWithAllPrivateFieldTypes_.java @@ -25,6 +25,10 @@ public class ModelWithAllPrivateFieldTypes_ extends ModelWithAllPrivateFieldType private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + public ModelWithAllPrivateFieldTypes_() { super(); } @@ -55,7 +59,8 @@ public void handlePostBind(final Object object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelWithAllPrivateFieldTypes_ onBind(OnModelBoundListener listener) { + public ModelWithAllPrivateFieldTypes_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -76,12 +81,58 @@ public void unbind(Object object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelWithAllPrivateFieldTypes_ onUnbind(OnModelUnboundListener listener) { + public ModelWithAllPrivateFieldTypes_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final Object object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithAllPrivateFieldTypes_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final Object object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithAllPrivateFieldTypes_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + public ModelWithAllPrivateFieldTypes_ valueInt(int valueInt) { onMutation(); super.setValueInt(valueInt); @@ -342,7 +393,8 @@ public ModelWithAllPrivateFieldTypes_ layout(@LayoutRes int arg0) { } @Override - public ModelWithAllPrivateFieldTypes_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public ModelWithAllPrivateFieldTypes_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -369,6 +421,8 @@ public ModelWithAllPrivateFieldTypes_ hide() { public ModelWithAllPrivateFieldTypes_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; super.setValueInt(0); super.setValueInteger(null); super.setValueShort((short) 0); @@ -412,6 +466,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((getValueInt() != that.getValueInt())) { return false; } @@ -483,6 +543,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); long temp; result = 31 * result + getValueInt(); result = 31 * result + (getValueInteger() != null ? getValueInteger().hashCode() : 0); diff --git a/epoxy-processortest/src/test/resources/ModelWithAnnotatedClassAndSuperAttributes$SubModelWithAnnotatedClassAndSuperAttributes_.java b/epoxy-processortest/src/test/resources/ModelWithAnnotatedClassAndSuperAttributes$SubModelWithAnnotatedClassAndSuperAttributes_.java index 7c611c6c06..36a1b98028 100755 --- a/epoxy-processortest/src/test/resources/ModelWithAnnotatedClassAndSuperAttributes$SubModelWithAnnotatedClassAndSuperAttributes_.java +++ b/epoxy-processortest/src/test/resources/ModelWithAnnotatedClassAndSuperAttributes$SubModelWithAnnotatedClassAndSuperAttributes_.java @@ -15,6 +15,10 @@ public class ModelWithAnnotatedClassAndSuperAttributes$SubModelWithAnnotatedClas private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + public ModelWithAnnotatedClassAndSuperAttributes$SubModelWithAnnotatedClassAndSuperAttributes_() { super(); } @@ -45,7 +49,8 @@ public void handlePostBind(final Object object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelWithAnnotatedClassAndSuperAttributes$SubModelWithAnnotatedClassAndSuperAttributes_ onBind(OnModelBoundListener listener) { + public ModelWithAnnotatedClassAndSuperAttributes$SubModelWithAnnotatedClassAndSuperAttributes_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -66,13 +71,60 @@ public void unbind(Object object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelWithAnnotatedClassAndSuperAttributes$SubModelWithAnnotatedClassAndSuperAttributes_ onUnbind(OnModelUnboundListener listener) { + public ModelWithAnnotatedClassAndSuperAttributes$SubModelWithAnnotatedClassAndSuperAttributes_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } - public ModelWithAnnotatedClassAndSuperAttributes$SubModelWithAnnotatedClassAndSuperAttributes_ superValue(int superValue) { + @Override + public void visibilityStateChanged(int visibilityState, final Object object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithAnnotatedClassAndSuperAttributes$SubModelWithAnnotatedClassAndSuperAttributes_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final Object object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithAnnotatedClassAndSuperAttributes$SubModelWithAnnotatedClassAndSuperAttributes_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + + public ModelWithAnnotatedClassAndSuperAttributes$SubModelWithAnnotatedClassAndSuperAttributes_ superValue( + int superValue) { onMutation(); super.superValue = superValue; return this; @@ -83,78 +135,89 @@ public int superValue() { } @Override - public ModelWithAnnotatedClassAndSuperAttributes$SubModelWithAnnotatedClassAndSuperAttributes_ id(long id) { + public ModelWithAnnotatedClassAndSuperAttributes$SubModelWithAnnotatedClassAndSuperAttributes_ id( + long id) { super.id(id); return this; } @Override - public ModelWithAnnotatedClassAndSuperAttributes$SubModelWithAnnotatedClassAndSuperAttributes_ id(@Nullable Number... arg0) { + public ModelWithAnnotatedClassAndSuperAttributes$SubModelWithAnnotatedClassAndSuperAttributes_ id( + @Nullable Number... arg0) { super.id(arg0); return this; } @Override - public ModelWithAnnotatedClassAndSuperAttributes$SubModelWithAnnotatedClassAndSuperAttributes_ id(long id1, - long id2) { + public ModelWithAnnotatedClassAndSuperAttributes$SubModelWithAnnotatedClassAndSuperAttributes_ id( + long id1, long id2) { super.id(id1, id2); return this; } @Override - public ModelWithAnnotatedClassAndSuperAttributes$SubModelWithAnnotatedClassAndSuperAttributes_ id(@Nullable CharSequence arg0) { + public ModelWithAnnotatedClassAndSuperAttributes$SubModelWithAnnotatedClassAndSuperAttributes_ id( + @Nullable CharSequence arg0) { super.id(arg0); return this; } @Override - public ModelWithAnnotatedClassAndSuperAttributes$SubModelWithAnnotatedClassAndSuperAttributes_ id(@Nullable CharSequence arg0, - @Nullable CharSequence... arg1) { + public ModelWithAnnotatedClassAndSuperAttributes$SubModelWithAnnotatedClassAndSuperAttributes_ id( + @Nullable CharSequence arg0, @Nullable CharSequence... arg1) { super.id(arg0, arg1); return this; } @Override - public ModelWithAnnotatedClassAndSuperAttributes$SubModelWithAnnotatedClassAndSuperAttributes_ id(@Nullable CharSequence arg0, - long arg1) { + public ModelWithAnnotatedClassAndSuperAttributes$SubModelWithAnnotatedClassAndSuperAttributes_ id( + @Nullable CharSequence arg0, long arg1) { super.id(arg0, arg1); return this; } @Override - public ModelWithAnnotatedClassAndSuperAttributes$SubModelWithAnnotatedClassAndSuperAttributes_ layout(@LayoutRes int arg0) { + public ModelWithAnnotatedClassAndSuperAttributes$SubModelWithAnnotatedClassAndSuperAttributes_ layout( + @LayoutRes int arg0) { super.layout(arg0); return this; } @Override - public ModelWithAnnotatedClassAndSuperAttributes$SubModelWithAnnotatedClassAndSuperAttributes_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public ModelWithAnnotatedClassAndSuperAttributes$SubModelWithAnnotatedClassAndSuperAttributes_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @Override - public ModelWithAnnotatedClassAndSuperAttributes$SubModelWithAnnotatedClassAndSuperAttributes_ show() { + public ModelWithAnnotatedClassAndSuperAttributes$SubModelWithAnnotatedClassAndSuperAttributes_ show( + ) { super.show(); return this; } @Override - public ModelWithAnnotatedClassAndSuperAttributes$SubModelWithAnnotatedClassAndSuperAttributes_ show(boolean show) { + public ModelWithAnnotatedClassAndSuperAttributes$SubModelWithAnnotatedClassAndSuperAttributes_ show( + boolean show) { super.show(show); return this; } @Override - public ModelWithAnnotatedClassAndSuperAttributes$SubModelWithAnnotatedClassAndSuperAttributes_ hide() { + public ModelWithAnnotatedClassAndSuperAttributes$SubModelWithAnnotatedClassAndSuperAttributes_ hide( + ) { super.hide(); return this; } @Override - public ModelWithAnnotatedClassAndSuperAttributes$SubModelWithAnnotatedClassAndSuperAttributes_ reset() { + public ModelWithAnnotatedClassAndSuperAttributes$SubModelWithAnnotatedClassAndSuperAttributes_ reset( + ) { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; super.superValue = 0; super.reset(); return this; @@ -178,6 +241,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((superValue != that.superValue)) { return false; } @@ -189,6 +258,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + superValue; return result; } diff --git a/epoxy-processortest/src/test/resources/ModelWithAnnotatedClassAndSuperAttributes_.java b/epoxy-processortest/src/test/resources/ModelWithAnnotatedClassAndSuperAttributes_.java index cc51e3ef32..80b4fa9bcf 100644 --- a/epoxy-processortest/src/test/resources/ModelWithAnnotatedClassAndSuperAttributes_.java +++ b/epoxy-processortest/src/test/resources/ModelWithAnnotatedClassAndSuperAttributes_.java @@ -15,6 +15,10 @@ public class ModelWithAnnotatedClassAndSuperAttributes_ extends ModelWithAnnotat private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + public ModelWithAnnotatedClassAndSuperAttributes_() { super(); } @@ -45,7 +49,8 @@ public void handlePostBind(final Object object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelWithAnnotatedClassAndSuperAttributes_ onBind(OnModelBoundListener listener) { + public ModelWithAnnotatedClassAndSuperAttributes_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -66,12 +71,58 @@ public void unbind(Object object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelWithAnnotatedClassAndSuperAttributes_ onUnbind(OnModelUnboundListener listener) { + public ModelWithAnnotatedClassAndSuperAttributes_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final Object object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithAnnotatedClassAndSuperAttributes_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final Object object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithAnnotatedClassAndSuperAttributes_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + public ModelWithAnnotatedClassAndSuperAttributes_ superValue(int superValue) { onMutation(); super.superValue = superValue; @@ -126,7 +177,8 @@ public ModelWithAnnotatedClassAndSuperAttributes_ layout(@LayoutRes int arg0) { } @Override - public ModelWithAnnotatedClassAndSuperAttributes_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public ModelWithAnnotatedClassAndSuperAttributes_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -153,6 +205,8 @@ public ModelWithAnnotatedClassAndSuperAttributes_ hide() { public ModelWithAnnotatedClassAndSuperAttributes_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; super.superValue = 0; super.reset(); return this; @@ -176,6 +230,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((superValue != that.superValue)) { return false; } @@ -187,6 +247,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + superValue; return result; } diff --git a/epoxy-processortest/src/test/resources/ModelWithAnnotatedClass_.java b/epoxy-processortest/src/test/resources/ModelWithAnnotatedClass_.java index 307726e126..45c80c975b 100755 --- a/epoxy-processortest/src/test/resources/ModelWithAnnotatedClass_.java +++ b/epoxy-processortest/src/test/resources/ModelWithAnnotatedClass_.java @@ -15,6 +15,10 @@ public class ModelWithAnnotatedClass_ extends ModelWithAnnotatedClass implements private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + public ModelWithAnnotatedClass_() { super(); } @@ -45,7 +49,8 @@ public void handlePostBind(final Object object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelWithAnnotatedClass_ onBind(OnModelBoundListener listener) { + public ModelWithAnnotatedClass_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -66,12 +71,58 @@ public void unbind(Object object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelWithAnnotatedClass_ onUnbind(OnModelUnboundListener listener) { + public ModelWithAnnotatedClass_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final Object object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithAnnotatedClass_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final Object object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithAnnotatedClass_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + @Override public ModelWithAnnotatedClass_ id(long id) { super.id(id); @@ -115,7 +166,8 @@ public ModelWithAnnotatedClass_ layout(@LayoutRes int arg0) { } @Override - public ModelWithAnnotatedClass_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public ModelWithAnnotatedClass_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -142,6 +194,8 @@ public ModelWithAnnotatedClass_ hide() { public ModelWithAnnotatedClass_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; super.reset(); return this; } @@ -164,6 +218,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } return true; } @@ -172,6 +232,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); return result; } diff --git a/epoxy-processortest/src/test/resources/ModelWithAnnotation_.java b/epoxy-processortest/src/test/resources/ModelWithAnnotation_.java index 99ba578c45..f138272cab 100755 --- a/epoxy-processortest/src/test/resources/ModelWithAnnotation_.java +++ b/epoxy-processortest/src/test/resources/ModelWithAnnotation_.java @@ -17,6 +17,10 @@ public class ModelWithAnnotation_ extends ModelWithAnnotation implements Generat private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + public ModelWithAnnotation_() { super(); } @@ -68,12 +72,58 @@ public void unbind(Object object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelWithAnnotation_ onUnbind(OnModelUnboundListener listener) { + public ModelWithAnnotation_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final Object object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithAnnotation_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final Object object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithAnnotation_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + @Override public ModelWithAnnotation_ id(long id) { super.id(id); @@ -144,6 +194,8 @@ public ModelWithAnnotation_ hide() { public ModelWithAnnotation_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; super.reset(); return this; } @@ -166,6 +218,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } return true; } @@ -174,6 +232,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); return result; } diff --git a/epoxy-processortest/src/test/resources/ModelWithConstructors_.java b/epoxy-processortest/src/test/resources/ModelWithConstructors_.java index 8a023f155f..122aa28ac1 100755 --- a/epoxy-processortest/src/test/resources/ModelWithConstructors_.java +++ b/epoxy-processortest/src/test/resources/ModelWithConstructors_.java @@ -15,6 +15,10 @@ public class ModelWithConstructors_ extends ModelWithConstructors implements Gen private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + public ModelWithConstructors_(long id, int valueInt) { super(id, valueInt); } @@ -53,7 +57,8 @@ public void handlePostBind(final Object object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelWithConstructors_ onBind(OnModelBoundListener listener) { + public ModelWithConstructors_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -74,12 +79,58 @@ public void unbind(Object object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelWithConstructors_ onUnbind(OnModelUnboundListener listener) { + public ModelWithConstructors_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final Object object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithConstructors_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final Object object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithConstructors_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + public ModelWithConstructors_ valueInt(int valueInt) { onMutation(); super.valueInt = valueInt; @@ -133,7 +184,8 @@ public ModelWithConstructors_ layout(@LayoutRes int arg0) { } @Override - public ModelWithConstructors_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public ModelWithConstructors_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -160,6 +212,8 @@ public ModelWithConstructors_ hide() { public ModelWithConstructors_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; super.valueInt = 0; super.reset(); return this; @@ -183,6 +237,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((valueInt != that.valueInt)) { return false; } @@ -194,6 +254,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + valueInt; return result; } diff --git a/epoxy-processortest/src/test/resources/ModelWithDataBindingBindingModel_.java b/epoxy-processortest/src/test/resources/ModelWithDataBindingBindingModel_.java index becf879183..334acbc7d3 100755 --- a/epoxy-processortest/src/test/resources/ModelWithDataBindingBindingModel_.java +++ b/epoxy-processortest/src/test/resources/ModelWithDataBindingBindingModel_.java @@ -17,6 +17,10 @@ public class ModelWithDataBindingBindingModel_ extends DataBindingEpoxyModel imp private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + private String stringValue; @Override @@ -46,7 +50,8 @@ public void handlePostBind(final DataBindingEpoxyModel.DataBindingHolder object, * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelWithDataBindingBindingModel_ onBind(OnModelBoundListener listener) { + public ModelWithDataBindingBindingModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -67,12 +72,59 @@ public void unbind(DataBindingEpoxyModel.DataBindingHolder object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelWithDataBindingBindingModel_ onUnbind(OnModelUnboundListener listener) { + public ModelWithDataBindingBindingModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, + final DataBindingEpoxyModel.DataBindingHolder object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithDataBindingBindingModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final DataBindingEpoxyModel.DataBindingHolder object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithDataBindingBindingModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + public ModelWithDataBindingBindingModel_ stringValue(String stringValue) { onMutation(); this.stringValue = stringValue; @@ -127,7 +179,8 @@ public ModelWithDataBindingBindingModel_ layout(@LayoutRes int arg0) { } @Override - public ModelWithDataBindingBindingModel_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public ModelWithDataBindingBindingModel_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -179,6 +232,8 @@ protected void setDataBindingVariables(ViewDataBinding binding, EpoxyModel previ public ModelWithDataBindingBindingModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; this.stringValue = null; super.reset(); return this; @@ -202,6 +257,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((stringValue != null ? !stringValue.equals(that.stringValue) : that.stringValue != null)) { return false; } @@ -213,6 +274,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (stringValue != null ? stringValue.hashCode() : 0); return result; } diff --git a/epoxy-processortest/src/test/resources/ModelWithDataBindingWithoutDonothashBindingModel_.java b/epoxy-processortest/src/test/resources/ModelWithDataBindingWithoutDonothashBindingModel_.java index 0f23f27b96..4b3b2b9c11 100644 --- a/epoxy-processortest/src/test/resources/ModelWithDataBindingWithoutDonothashBindingModel_.java +++ b/epoxy-processortest/src/test/resources/ModelWithDataBindingWithoutDonothashBindingModel_.java @@ -18,6 +18,10 @@ public class ModelWithDataBindingWithoutDonothashBindingModel_ extends DataBindi private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + private String stringValue; private View.OnClickListener clickListener; @@ -78,6 +82,52 @@ public ModelWithDataBindingWithoutDonothashBindingModel_ onUnbind( return this; } + @Override + public void visibilityStateChanged(int visibilityState, + final DataBindingEpoxyModel.DataBindingHolder object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithDataBindingWithoutDonothashBindingModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final DataBindingEpoxyModel.DataBindingHolder object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithDataBindingWithoutDonothashBindingModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + public ModelWithDataBindingWithoutDonothashBindingModel_ stringValue(String stringValue) { onMutation(); this.stringValue = stringValue; @@ -217,6 +267,8 @@ protected void setDataBindingVariables(ViewDataBinding binding, EpoxyModel previ public ModelWithDataBindingWithoutDonothashBindingModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; this.stringValue = null; this.clickListener = null; super.reset(); @@ -241,6 +293,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((stringValue != null ? !stringValue.equals(that.stringValue) : that.stringValue != null)) { return false; } @@ -255,6 +313,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (stringValue != null ? stringValue.hashCode() : 0); result = 31 * result + (clickListener != null ? clickListener.hashCode() : 0); return result; diff --git a/epoxy-processortest/src/test/resources/ModelWithFieldAnnotation_.java b/epoxy-processortest/src/test/resources/ModelWithFieldAnnotation_.java index 0c72b02ad7..33cf118870 100755 --- a/epoxy-processortest/src/test/resources/ModelWithFieldAnnotation_.java +++ b/epoxy-processortest/src/test/resources/ModelWithFieldAnnotation_.java @@ -15,6 +15,10 @@ public class ModelWithFieldAnnotation_ extends ModelWithFieldAnnotation implemen private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + public ModelWithFieldAnnotation_() { super(); } @@ -45,7 +49,8 @@ public void handlePostBind(final Object object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelWithFieldAnnotation_ onBind(OnModelBoundListener listener) { + public ModelWithFieldAnnotation_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -66,12 +71,58 @@ public void unbind(Object object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelWithFieldAnnotation_ onUnbind(OnModelUnboundListener listener) { + public ModelWithFieldAnnotation_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final Object object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithFieldAnnotation_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final Object object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithFieldAnnotation_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + public ModelWithFieldAnnotation_ title(@Nullable String title) { onMutation(); super.title = title; @@ -126,7 +177,8 @@ public ModelWithFieldAnnotation_ layout(@LayoutRes int arg0) { } @Override - public ModelWithFieldAnnotation_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public ModelWithFieldAnnotation_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -153,6 +205,8 @@ public ModelWithFieldAnnotation_ hide() { public ModelWithFieldAnnotation_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; super.title = null; super.reset(); return this; @@ -176,6 +230,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((title != null ? !title.equals(that.title) : that.title != null)) { return false; } @@ -187,6 +247,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (title != null ? title.hashCode() : 0); return result; } diff --git a/epoxy-processortest/src/test/resources/ModelWithFinalField_.java b/epoxy-processortest/src/test/resources/ModelWithFinalField_.java index 1230990f35..2bab56487f 100755 --- a/epoxy-processortest/src/test/resources/ModelWithFinalField_.java +++ b/epoxy-processortest/src/test/resources/ModelWithFinalField_.java @@ -15,6 +15,10 @@ public class ModelWithFinalField_ extends ModelWithFinalField implements Generat private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + public ModelWithFinalField_(long id, int valueInt) { super(id, valueInt); } @@ -66,12 +70,58 @@ public void unbind(Object object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelWithFinalField_ onUnbind(OnModelUnboundListener listener) { + public ModelWithFinalField_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final Object object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithFinalField_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final Object object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithFinalField_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + public int valueInt() { return valueInt; } @@ -146,6 +196,8 @@ public ModelWithFinalField_ hide() { public ModelWithFinalField_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; super.reset(); return this; } @@ -168,6 +220,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((valueInt != that.valueInt)) { return false; } @@ -179,6 +237,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + valueInt; return result; } diff --git a/epoxy-processortest/src/test/resources/ModelWithIntDef_.java b/epoxy-processortest/src/test/resources/ModelWithIntDef_.java index aaefb98bcd..bf16418e2a 100644 --- a/epoxy-processortest/src/test/resources/ModelWithIntDef_.java +++ b/epoxy-processortest/src/test/resources/ModelWithIntDef_.java @@ -8,6 +8,8 @@ import com.airbnb.epoxy.GeneratedModel; import com.airbnb.epoxy.OnModelBoundListener; import com.airbnb.epoxy.OnModelUnboundListener; +import com.airbnb.epoxy.OnModelVisibilityChangedListener; +import com.airbnb.epoxy.OnModelVisibilityStateChangedListener; import java.lang.CharSequence; import java.lang.Number; import java.lang.Object; @@ -21,6 +23,10 @@ public class ModelWithIntDef_ extends ModelWithIntDef implements GeneratedModel< private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + public ModelWithIntDef_() { super(); } @@ -78,6 +84,51 @@ public ModelWithIntDef_ onUnbind(OnModelUnboundListener + * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithIntDef_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final Object object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithIntDef_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + public ModelWithIntDef_ type(@ModelWithIntDef.MyType int type) { onMutation(); super.type = type; @@ -159,6 +210,8 @@ public ModelWithIntDef_ hide() { public ModelWithIntDef_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; super.type = 0; super.reset(); return this; @@ -182,6 +235,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((type != that.type)) { return false; } @@ -193,6 +252,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + type; return result; } diff --git a/epoxy-processortest/src/test/resources/ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_.java b/epoxy-processortest/src/test/resources/ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_.java index 708f36645f..af81493013 100755 --- a/epoxy-processortest/src/test/resources/ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_.java +++ b/epoxy-processortest/src/test/resources/ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_.java @@ -15,6 +15,10 @@ public class ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_ extends Mo private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + public ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_() { super(); } @@ -45,7 +49,8 @@ public void handlePostBind(final Object object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_ onBind(OnModelBoundListener listener) { + public ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -66,12 +71,58 @@ public void unbind(Object object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_ onUnbind(OnModelUnboundListener listener) { + public ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final Object object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final Object object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + public ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_ isValue(boolean isValue) { onMutation(); super.setValue(isValue); @@ -127,7 +178,8 @@ public ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_ layout(@LayoutRe } @Override - public ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -154,6 +206,8 @@ public ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_ hide() { public ModelWithPrivateFieldWithSameAsFieldGetterAndSetterName_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; super.setValue(false); super.reset(); return this; @@ -177,6 +231,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((isValue() != that.isValue())) { return false; } @@ -188,6 +248,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (isValue() ? 1 : 0); return result; } diff --git a/epoxy-processortest/src/test/resources/ModelWithPrivateViewClickListener_.java b/epoxy-processortest/src/test/resources/ModelWithPrivateViewClickListener_.java index 1374efb305..b13e0543dd 100644 --- a/epoxy-processortest/src/test/resources/ModelWithPrivateViewClickListener_.java +++ b/epoxy-processortest/src/test/resources/ModelWithPrivateViewClickListener_.java @@ -16,6 +16,10 @@ public class ModelWithPrivateViewClickListener_ extends ModelWithPrivateViewClic private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + public ModelWithPrivateViewClickListener_() { super(); } @@ -46,7 +50,8 @@ public void handlePostBind(final Object object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelWithPrivateViewClickListener_ onBind(OnModelBoundListener listener) { + public ModelWithPrivateViewClickListener_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -67,15 +72,62 @@ public void unbind(Object object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelWithPrivateViewClickListener_ onUnbind(OnModelUnboundListener listener) { + public ModelWithPrivateViewClickListener_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final Object object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithPrivateViewClickListener_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final Object object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithPrivateViewClickListener_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + /** * Set a click listener that will provide the parent view, model, and adapter position of the clicked view. This will clear the normal View.OnClickListener if one has been set */ - public ModelWithPrivateViewClickListener_ clickListener(final OnModelClickListener clickListener) { + public ModelWithPrivateViewClickListener_ clickListener( + final OnModelClickListener clickListener) { onMutation(); if (clickListener == null) { super.setClickListener(null); @@ -140,7 +192,8 @@ public ModelWithPrivateViewClickListener_ layout(@LayoutRes int arg0) { } @Override - public ModelWithPrivateViewClickListener_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public ModelWithPrivateViewClickListener_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -167,6 +220,8 @@ public ModelWithPrivateViewClickListener_ hide() { public ModelWithPrivateViewClickListener_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; super.setClickListener(null); super.reset(); return this; @@ -190,6 +245,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if (((getClickListener() == null) != (that.getClickListener() == null))) { return false; } @@ -201,6 +262,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (getClickListener() != null ? 1 : 0); return result; } diff --git a/epoxy-processortest/src/test/resources/ModelWithSuperAttributes$SubModelWithSuperAttributes_.java b/epoxy-processortest/src/test/resources/ModelWithSuperAttributes$SubModelWithSuperAttributes_.java index c6a4e07a18..0e5e1d67e0 100755 --- a/epoxy-processortest/src/test/resources/ModelWithSuperAttributes$SubModelWithSuperAttributes_.java +++ b/epoxy-processortest/src/test/resources/ModelWithSuperAttributes$SubModelWithSuperAttributes_.java @@ -15,6 +15,10 @@ public class ModelWithSuperAttributes$SubModelWithSuperAttributes_ extends Model private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + public ModelWithSuperAttributes$SubModelWithSuperAttributes_() { super(); } @@ -45,7 +49,8 @@ public void handlePostBind(final Object object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelWithSuperAttributes$SubModelWithSuperAttributes_ onBind(OnModelBoundListener listener) { + public ModelWithSuperAttributes$SubModelWithSuperAttributes_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -66,12 +71,58 @@ public void unbind(Object object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelWithSuperAttributes$SubModelWithSuperAttributes_ onUnbind(OnModelUnboundListener listener) { + public ModelWithSuperAttributes$SubModelWithSuperAttributes_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final Object object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithSuperAttributes$SubModelWithSuperAttributes_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final Object object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithSuperAttributes$SubModelWithSuperAttributes_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + public ModelWithSuperAttributes$SubModelWithSuperAttributes_ subValue(int subValue) { onMutation(); super.subValue = subValue; @@ -137,7 +188,8 @@ public int superValue() { } @Override - public ModelWithSuperAttributes$SubModelWithSuperAttributes_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public ModelWithSuperAttributes$SubModelWithSuperAttributes_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -164,6 +216,8 @@ public int superValue() { public ModelWithSuperAttributes$SubModelWithSuperAttributes_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; super.subValue = 0; super.superValue = 0; super.reset(); @@ -188,6 +242,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((subValue != that.subValue)) { return false; } @@ -202,6 +262,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + subValue; result = 31 * result + superValue; return result; diff --git a/epoxy-processortest/src/test/resources/ModelWithSuperAttributes_.java b/epoxy-processortest/src/test/resources/ModelWithSuperAttributes_.java index 546837f621..2f26b33c62 100755 --- a/epoxy-processortest/src/test/resources/ModelWithSuperAttributes_.java +++ b/epoxy-processortest/src/test/resources/ModelWithSuperAttributes_.java @@ -15,6 +15,10 @@ public class ModelWithSuperAttributes_ extends ModelWithSuperAttributes implemen private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + public ModelWithSuperAttributes_() { super(); } @@ -45,7 +49,8 @@ public void handlePostBind(final Object object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelWithSuperAttributes_ onBind(OnModelBoundListener listener) { + public ModelWithSuperAttributes_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -66,12 +71,58 @@ public void unbind(Object object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelWithSuperAttributes_ onUnbind(OnModelUnboundListener listener) { + public ModelWithSuperAttributes_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final Object object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithSuperAttributes_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final Object object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithSuperAttributes_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + public ModelWithSuperAttributes_ superValue(int superValue) { onMutation(); super.superValue = superValue; @@ -125,7 +176,8 @@ public ModelWithSuperAttributes_ layout(@LayoutRes int arg0) { } @Override - public ModelWithSuperAttributes_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public ModelWithSuperAttributes_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -152,6 +204,8 @@ public ModelWithSuperAttributes_ hide() { public ModelWithSuperAttributes_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; super.superValue = 0; super.reset(); return this; @@ -175,6 +229,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((superValue != that.superValue)) { return false; } @@ -186,6 +246,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + superValue; return result; } diff --git a/epoxy-processortest/src/test/resources/ModelWithSuper_.java b/epoxy-processortest/src/test/resources/ModelWithSuper_.java index bfc4e97693..ec0e069a1e 100755 --- a/epoxy-processortest/src/test/resources/ModelWithSuper_.java +++ b/epoxy-processortest/src/test/resources/ModelWithSuper_.java @@ -15,6 +15,10 @@ public class ModelWithSuper_ extends ModelWithSuper implements GeneratedModel onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + public ModelWithSuper_() { super(); } @@ -72,6 +76,51 @@ public ModelWithSuper_ onUnbind(OnModelUnboundListener return this; } + @Override + public void visibilityStateChanged(int visibilityState, final Object object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithSuper_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final Object object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithSuper_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + public ModelWithSuper_ valueInt(int valueInt) { onMutation(); super.valueInt = valueInt; @@ -153,6 +202,8 @@ public ModelWithSuper_ hide() { public ModelWithSuper_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; super.valueInt = 0; super.reset(); return this; @@ -176,6 +227,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((valueInt != that.valueInt)) { return false; } @@ -187,6 +244,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + valueInt; return result; } diff --git a/epoxy-processortest/src/test/resources/ModelWithType_.java b/epoxy-processortest/src/test/resources/ModelWithType_.java index 87a87aebc7..57b65b3220 100755 --- a/epoxy-processortest/src/test/resources/ModelWithType_.java +++ b/epoxy-processortest/src/test/resources/ModelWithType_.java @@ -15,6 +15,10 @@ public class ModelWithType_ extends ModelWithType implement private OnModelUnboundListener, Object> onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener, Object> onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener, Object> onModelVisibilityChangedListener_epoxyGeneratedModel; + public ModelWithType_() { super(); } @@ -72,6 +76,51 @@ public ModelWithType_ onUnbind(OnModelUnboundListener, Obje return this; } + @Override + public void visibilityStateChanged(int visibilityState, final Object object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithType_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener, Object> listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final Object object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithType_ onVisibilityChanged( + OnModelVisibilityChangedListener, Object> listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + public ModelWithType_ value(int value) { onMutation(); super.value = value; @@ -152,6 +201,8 @@ public ModelWithType_ hide() { public ModelWithType_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; super.value = 0; super.reset(); return this; @@ -175,6 +226,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((value != that.value)) { return false; } @@ -186,6 +243,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + value; return result; } diff --git a/epoxy-processortest/src/test/resources/ModelWithVarargsConstructors_.java b/epoxy-processortest/src/test/resources/ModelWithVarargsConstructors_.java index d10094943a..a1a22c9d67 100755 --- a/epoxy-processortest/src/test/resources/ModelWithVarargsConstructors_.java +++ b/epoxy-processortest/src/test/resources/ModelWithVarargsConstructors_.java @@ -16,6 +16,10 @@ public class ModelWithVarargsConstructors_ extends ModelWithVarargsConstructors private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + public ModelWithVarargsConstructors_(String... varargs) { super(varargs); } @@ -50,7 +54,8 @@ public void handlePostBind(final Object object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelWithVarargsConstructors_ onBind(OnModelBoundListener listener) { + public ModelWithVarargsConstructors_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -71,12 +76,58 @@ public void unbind(Object object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelWithVarargsConstructors_ onUnbind(OnModelUnboundListener listener) { + public ModelWithVarargsConstructors_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final Object object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithVarargsConstructors_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final Object object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithVarargsConstructors_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + public ModelWithVarargsConstructors_ valueInt(int valueInt) { onMutation(); super.valueInt = valueInt; @@ -141,7 +192,8 @@ public ModelWithVarargsConstructors_ layout(@LayoutRes int arg0) { } @Override - public ModelWithVarargsConstructors_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public ModelWithVarargsConstructors_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -168,6 +220,8 @@ public ModelWithVarargsConstructors_ hide() { public ModelWithVarargsConstructors_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; super.valueInt = 0; super.varargs = null; super.reset(); @@ -192,6 +246,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((valueInt != that.valueInt)) { return false; } @@ -206,6 +266,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + valueInt; result = 31 * result + Arrays.hashCode(varargs); return result; diff --git a/epoxy-processortest/src/test/resources/ModelWithViewClickListener_.java b/epoxy-processortest/src/test/resources/ModelWithViewClickListener_.java index 1703bfebe9..550c45db83 100644 --- a/epoxy-processortest/src/test/resources/ModelWithViewClickListener_.java +++ b/epoxy-processortest/src/test/resources/ModelWithViewClickListener_.java @@ -16,6 +16,10 @@ public class ModelWithViewClickListener_ extends ModelWithViewClickListener impl private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + public ModelWithViewClickListener_() { super(); } @@ -46,7 +50,8 @@ public void handlePostBind(final Object object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelWithViewClickListener_ onBind(OnModelBoundListener listener) { + public ModelWithViewClickListener_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -67,15 +72,62 @@ public void unbind(Object object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelWithViewClickListener_ onUnbind(OnModelUnboundListener listener) { + public ModelWithViewClickListener_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final Object object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithViewClickListener_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final Object object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithViewClickListener_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + /** * Set a click listener that will provide the parent view, model, and adapter position of the clicked view. This will clear the normal View.OnClickListener if one has been set */ - public ModelWithViewClickListener_ clickListener(final OnModelClickListener clickListener) { + public ModelWithViewClickListener_ clickListener( + final OnModelClickListener clickListener) { onMutation(); if (clickListener == null) { super.clickListener = null; @@ -140,7 +192,8 @@ public ModelWithViewClickListener_ layout(@LayoutRes int arg0) { } @Override - public ModelWithViewClickListener_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public ModelWithViewClickListener_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -167,6 +220,8 @@ public ModelWithViewClickListener_ hide() { public ModelWithViewClickListener_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; super.clickListener = null; super.reset(); return this; @@ -190,6 +245,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if (((clickListener == null) != (that.clickListener == null))) { return false; } @@ -201,6 +262,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (clickListener != null ? 1 : 0); return result; } diff --git a/epoxy-processortest/src/test/resources/ModelWithViewLongClickListener_.java b/epoxy-processortest/src/test/resources/ModelWithViewLongClickListener_.java index 268451f40c..a4b01b3d73 100644 --- a/epoxy-processortest/src/test/resources/ModelWithViewLongClickListener_.java +++ b/epoxy-processortest/src/test/resources/ModelWithViewLongClickListener_.java @@ -16,6 +16,10 @@ public class ModelWithViewLongClickListener_ extends ModelWithViewLongClickListe private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + public ModelWithViewLongClickListener_() { super(); } @@ -46,7 +50,8 @@ public void handlePostBind(final Object object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelWithViewLongClickListener_ onBind(OnModelBoundListener listener) { + public ModelWithViewLongClickListener_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -67,15 +72,62 @@ public void unbind(Object object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelWithViewLongClickListener_ onUnbind(OnModelUnboundListener listener) { + public ModelWithViewLongClickListener_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final Object object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithViewLongClickListener_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final Object object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithViewLongClickListener_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + /** * Set a click listener that will provide the parent view, model, and adapter position of the clicked view. This will clear the normal View.OnClickListener if one has been set */ - public ModelWithViewLongClickListener_ clickListener(final OnModelLongClickListener clickListener) { + public ModelWithViewLongClickListener_ clickListener( + final OnModelLongClickListener clickListener) { onMutation(); if (clickListener == null) { super.clickListener = null; @@ -140,7 +192,8 @@ public ModelWithViewLongClickListener_ layout(@LayoutRes int arg0) { } @Override - public ModelWithViewLongClickListener_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public ModelWithViewLongClickListener_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -167,6 +220,8 @@ public ModelWithViewLongClickListener_ hide() { public ModelWithViewLongClickListener_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; super.clickListener = null; super.reset(); return this; @@ -190,6 +245,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if (((clickListener == null) != (that.clickListener == null))) { return false; } @@ -201,6 +262,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (clickListener != null ? 1 : 0); return result; } diff --git a/epoxy-processortest/src/test/resources/ModelWithoutHash_.java b/epoxy-processortest/src/test/resources/ModelWithoutHash_.java index 8e3e018cc2..0353a968f8 100644 --- a/epoxy-processortest/src/test/resources/ModelWithoutHash_.java +++ b/epoxy-processortest/src/test/resources/ModelWithoutHash_.java @@ -15,6 +15,10 @@ public class ModelWithoutHash_ extends ModelWithoutHash implements GeneratedMode private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + public ModelWithoutHash_() { super(); } @@ -72,6 +76,51 @@ public ModelWithoutHash_ onUnbind(OnModelUnboundListener + * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithoutHash_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final Object object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithoutHash_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + public ModelWithoutHash_ value(int value) { onMutation(); super.value = value; @@ -172,6 +221,8 @@ public ModelWithoutHash_ hide() { public ModelWithoutHash_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; super.value = 0; super.value2 = 0; super.value3 = null; @@ -197,6 +248,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((value != that.value)) { return false; } @@ -211,6 +268,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + value; result = 31 * result + (value3 != null ? 1 : 0); return result; diff --git a/epoxy-processortest/src/test/resources/ModelWithoutSetter_.java b/epoxy-processortest/src/test/resources/ModelWithoutSetter_.java index a0795636ba..2368d781d0 100755 --- a/epoxy-processortest/src/test/resources/ModelWithoutSetter_.java +++ b/epoxy-processortest/src/test/resources/ModelWithoutSetter_.java @@ -15,6 +15,10 @@ public class ModelWithoutSetter_ extends ModelWithoutSetter implements Generated private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + public ModelWithoutSetter_() { super(); } @@ -66,12 +70,58 @@ public void unbind(Object object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public ModelWithoutSetter_ onUnbind(OnModelUnboundListener listener) { + public ModelWithoutSetter_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final Object object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithoutSetter_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final Object object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public ModelWithoutSetter_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + public int value() { return value; } @@ -146,6 +196,8 @@ public ModelWithoutSetter_ hide() { public ModelWithoutSetter_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; super.value = 0; super.reset(); return this; @@ -169,6 +221,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((value != that.value)) { return false; } @@ -180,6 +238,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + value; return result; } diff --git a/epoxy-processortest/src/test/resources/NullOnRecycleViewModel_.java b/epoxy-processortest/src/test/resources/NullOnRecycleViewModel_.java index ef2e1355cb..d9be6b6873 100644 --- a/epoxy-processortest/src/test/resources/NullOnRecycleViewModel_.java +++ b/epoxy-processortest/src/test/resources/NullOnRecycleViewModel_.java @@ -18,6 +18,10 @@ public class NullOnRecycleViewModel_ extends EpoxyModel imple private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + /** * Bitset index: 0 */ @Nullable @@ -70,7 +74,8 @@ public void handlePostBind(final NullOnRecycleView object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public NullOnRecycleViewModel_ onBind(OnModelBoundListener listener) { + public NullOnRecycleViewModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -92,12 +97,58 @@ public void unbind(NullOnRecycleView object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public NullOnRecycleViewModel_ onUnbind(OnModelUnboundListener listener) { + public NullOnRecycleViewModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final NullOnRecycleView object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public NullOnRecycleViewModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final NullOnRecycleView object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public NullOnRecycleViewModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + /** * Optional: Default value is (CharSequence) null * @@ -158,7 +209,8 @@ public NullOnRecycleViewModel_ layout(@LayoutRes int arg0) { } @Override - public NullOnRecycleViewModel_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public NullOnRecycleViewModel_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -191,6 +243,8 @@ protected int getDefaultLayout() { public NullOnRecycleViewModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); this.title_CharSequence = (CharSequence) null; super.reset(); @@ -215,6 +269,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((title_CharSequence != null ? !title_CharSequence.equals(that.title_CharSequence) : that.title_CharSequence != null)) { return false; } @@ -226,6 +286,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (title_CharSequence != null ? title_CharSequence.hashCode() : 0); return result; } diff --git a/epoxy-processortest/src/test/resources/OnViewRecycledViewModel_.java b/epoxy-processortest/src/test/resources/OnViewRecycledViewModel_.java index 331cb76d78..614c1f5dd1 100644 --- a/epoxy-processortest/src/test/resources/OnViewRecycledViewModel_.java +++ b/epoxy-processortest/src/test/resources/OnViewRecycledViewModel_.java @@ -21,6 +21,10 @@ public class OnViewRecycledViewModel_ extends EpoxyModel imp private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + /** * Bitset index: 0 */ @NonNull @@ -76,7 +80,8 @@ public void handlePostBind(final OnViewRecycledView object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public OnViewRecycledViewModel_ onBind(OnModelBoundListener listener) { + public OnViewRecycledViewModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -99,12 +104,58 @@ public void unbind(OnViewRecycledView object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public OnViewRecycledViewModel_ onUnbind(OnModelUnboundListener listener) { + public OnViewRecycledViewModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final OnViewRecycledView object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public OnViewRecycledViewModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final OnViewRecycledView object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public OnViewRecycledViewModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + /** * Required. * @@ -168,7 +219,8 @@ public OnViewRecycledViewModel_ layout(@LayoutRes int arg0) { } @Override - public OnViewRecycledViewModel_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public OnViewRecycledViewModel_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -201,6 +253,8 @@ protected int getDefaultLayout() { public OnViewRecycledViewModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); this.title_CharSequence = null; super.reset(); @@ -225,6 +279,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((title_CharSequence != null ? !title_CharSequence.equals(that.title_CharSequence) : that.title_CharSequence != null)) { return false; } @@ -236,6 +296,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (title_CharSequence != null ? title_CharSequence.hashCode() : 0); return result; } diff --git a/epoxy-processortest/src/test/resources/PropDefaultsViewModel_.java b/epoxy-processortest/src/test/resources/PropDefaultsViewModel_.java index 9de023f3e5..47f45f6be4 100644 --- a/epoxy-processortest/src/test/resources/PropDefaultsViewModel_.java +++ b/epoxy-processortest/src/test/resources/PropDefaultsViewModel_.java @@ -21,6 +21,10 @@ public class PropDefaultsViewModel_ extends EpoxyModel impleme private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + /** * Bitset index: 0 */ @Nullable @@ -124,7 +128,8 @@ public void handlePostBind(final PropDefaultsView object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public PropDefaultsViewModel_ onBind(OnModelBoundListener listener) { + public PropDefaultsViewModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -145,12 +150,58 @@ public void unbind(PropDefaultsView object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public PropDefaultsViewModel_ onUnbind(OnModelUnboundListener listener) { + public PropDefaultsViewModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final PropDefaultsView object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public PropDefaultsViewModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final PropDefaultsView object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public PropDefaultsViewModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + /** * Optional: Default value is (CharSequence) null * @@ -173,7 +224,8 @@ public CharSequence defaultsToNull() { * * @see PropDefaultsView#noDefaultSoItIsRequired(CharSequence) */ - public PropDefaultsViewModel_ noDefaultSoItIsRequired(@NonNull CharSequence noDefaultSoItIsRequired) { + public PropDefaultsViewModel_ noDefaultSoItIsRequired( + @NonNull CharSequence noDefaultSoItIsRequired) { if (noDefaultSoItIsRequired == null) { throw new IllegalArgumentException("noDefaultSoItIsRequired cannot be null"); } @@ -193,7 +245,8 @@ public CharSequence noDefaultSoItIsRequired() { * * @see PropDefaultsView#primitivesHaveImplicitDefaultsAndCannotBeRequired(int) */ - public PropDefaultsViewModel_ primitivesHaveImplicitDefaultsAndCannotBeRequired(int primitivesHaveImplicitDefaultsAndCannotBeRequired) { + public PropDefaultsViewModel_ primitivesHaveImplicitDefaultsAndCannotBeRequired( + int primitivesHaveImplicitDefaultsAndCannotBeRequired) { assignedAttributes_epoxyGeneratedModel.set(2); onMutation(); this.primitivesHaveImplicitDefaultsAndCannotBeRequired_Int = primitivesHaveImplicitDefaultsAndCannotBeRequired; @@ -245,7 +298,8 @@ public String objectWithDefault() { * * @see PropDefaultsView#objectWithDefaultAndNullable(String) */ - public PropDefaultsViewModel_ objectWithDefaultAndNullable(@Nullable String objectWithDefaultAndNullable) { + public PropDefaultsViewModel_ objectWithDefaultAndNullable( + @Nullable String objectWithDefaultAndNullable) { assignedAttributes_epoxyGeneratedModel.set(5); onMutation(); this.objectWithDefaultAndNullable_String = objectWithDefaultAndNullable; @@ -300,7 +354,8 @@ public PropDefaultsViewModel_ layout(@LayoutRes int arg0) { } @Override - public PropDefaultsViewModel_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public PropDefaultsViewModel_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -333,6 +388,8 @@ protected int getDefaultLayout() { public PropDefaultsViewModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); this.defaultsToNull_CharSequence = (CharSequence) null; this.noDefaultSoItIsRequired_CharSequence = null; @@ -362,6 +419,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((defaultsToNull_CharSequence != null ? !defaultsToNull_CharSequence.equals(that.defaultsToNull_CharSequence) : that.defaultsToNull_CharSequence != null)) { return false; } @@ -388,6 +451,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (defaultsToNull_CharSequence != null ? defaultsToNull_CharSequence.hashCode() : 0); result = 31 * result + (noDefaultSoItIsRequired_CharSequence != null ? noDefaultSoItIsRequired_CharSequence.hashCode() : 0); result = 31 * result + primitivesHaveImplicitDefaultsAndCannotBeRequired_Int; diff --git a/epoxy-processortest/src/test/resources/PropGroupsViewModel_.java b/epoxy-processortest/src/test/resources/PropGroupsViewModel_.java index abb414a3a2..03d7ce705d 100644 --- a/epoxy-processortest/src/test/resources/PropGroupsViewModel_.java +++ b/epoxy-processortest/src/test/resources/PropGroupsViewModel_.java @@ -21,6 +21,10 @@ public class PropGroupsViewModel_ extends EpoxyModel implements private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + /** * Bitset index: 0 */ @Nullable @@ -289,7 +293,8 @@ public void handlePostBind(final PropGroupsView object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public PropGroupsViewModel_ onBind(OnModelBoundListener listener) { + public PropGroupsViewModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -310,12 +315,58 @@ public void unbind(PropGroupsView object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public PropGroupsViewModel_ onUnbind(OnModelUnboundListener listener) { + public PropGroupsViewModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final PropGroupsView object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public PropGroupsViewModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final PropGroupsView object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public PropGroupsViewModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + /** * Optional: Default value is (CharSequence) null * @@ -470,7 +521,8 @@ public long primitiveWithDefaultLong() { * * @see PropGroupsView#primitiveAndObjectGroupWithPrimitiveDefault(long) */ - public PropGroupsViewModel_ primitiveAndObjectGroupWithPrimitiveDefault(long primitiveAndObjectGroupWithPrimitiveDefault) { + public PropGroupsViewModel_ primitiveAndObjectGroupWithPrimitiveDefault( + long primitiveAndObjectGroupWithPrimitiveDefault) { assignedAttributes_epoxyGeneratedModel.set(8); assignedAttributes_epoxyGeneratedModel.clear(9); this.primitiveAndObjectGroupWithPrimitiveDefault_CharSequence = null; @@ -488,7 +540,8 @@ public long primitiveAndObjectGroupWithPrimitiveDefaultLong() { * * @see PropGroupsView#primitiveAndObjectGroupWithPrimitiveDefault(CharSequence) */ - public PropGroupsViewModel_ primitiveAndObjectGroupWithPrimitiveDefault(@NonNull CharSequence primitiveAndObjectGroupWithPrimitiveDefault) { + public PropGroupsViewModel_ primitiveAndObjectGroupWithPrimitiveDefault( + @NonNull CharSequence primitiveAndObjectGroupWithPrimitiveDefault) { if (primitiveAndObjectGroupWithPrimitiveDefault == null) { throw new IllegalArgumentException("primitiveAndObjectGroupWithPrimitiveDefault cannot be null"); } @@ -665,6 +718,8 @@ protected int getDefaultLayout() { public PropGroupsViewModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); this.something_CharSequence = (CharSequence) null; this.something_Int = 0; @@ -702,6 +757,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((something_CharSequence != null ? !something_CharSequence.equals(that.something_CharSequence) : that.something_CharSequence != null)) { return false; } @@ -752,6 +813,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (something_CharSequence != null ? something_CharSequence.hashCode() : 0); result = 31 * result + something_Int; result = 31 * result + (somethingElse_CharSequence != null ? somethingElse_CharSequence.hashCode() : 0); diff --git a/epoxy-processortest/src/test/resources/RLayoutInViewModelAnnotationWorksViewModel_.java b/epoxy-processortest/src/test/resources/RLayoutInViewModelAnnotationWorksViewModel_.java index 67baf9ee3a..5f05bbf6b9 100644 --- a/epoxy-processortest/src/test/resources/RLayoutInViewModelAnnotationWorksViewModel_.java +++ b/epoxy-processortest/src/test/resources/RLayoutInViewModelAnnotationWorksViewModel_.java @@ -18,6 +18,10 @@ public class RLayoutInViewModelAnnotationWorksViewModel_ extends EpoxyModel onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + @Override public void addTo(EpoxyController controller) { super.addTo(controller); @@ -60,7 +64,8 @@ public void handlePostBind(final RLayoutInViewModelAnnotationWorksView object, i * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public RLayoutInViewModelAnnotationWorksViewModel_ onBind(OnModelBoundListener listener) { + public RLayoutInViewModelAnnotationWorksViewModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -81,12 +86,59 @@ public void unbind(RLayoutInViewModelAnnotationWorksView object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public RLayoutInViewModelAnnotationWorksViewModel_ onUnbind(OnModelUnboundListener listener) { + public RLayoutInViewModelAnnotationWorksViewModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, + final RLayoutInViewModelAnnotationWorksView object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public RLayoutInViewModelAnnotationWorksViewModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final RLayoutInViewModelAnnotationWorksView object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public RLayoutInViewModelAnnotationWorksViewModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + @Override public RLayoutInViewModelAnnotationWorksViewModel_ id(long id) { super.id(id); @@ -131,7 +183,8 @@ public RLayoutInViewModelAnnotationWorksViewModel_ layout(@LayoutRes int arg0) { } @Override - public RLayoutInViewModelAnnotationWorksViewModel_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public RLayoutInViewModelAnnotationWorksViewModel_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -164,6 +217,8 @@ protected int getDefaultLayout() { public RLayoutInViewModelAnnotationWorksViewModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); super.reset(); return this; @@ -187,6 +242,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } return true; } @@ -195,6 +256,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); return result; } diff --git a/epoxy-processortest/src/test/resources/SavedStateViewModel_.java b/epoxy-processortest/src/test/resources/SavedStateViewModel_.java index b531018f23..9e0260111e 100644 --- a/epoxy-processortest/src/test/resources/SavedStateViewModel_.java +++ b/epoxy-processortest/src/test/resources/SavedStateViewModel_.java @@ -21,6 +21,10 @@ public class SavedStateViewModel_ extends EpoxyModel implements private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + /** * Bitset index: 0 */ @NonNull @@ -76,7 +80,8 @@ public void handlePostBind(final SavedStateView object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public SavedStateViewModel_ onBind(OnModelBoundListener listener) { + public SavedStateViewModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -97,12 +102,58 @@ public void unbind(SavedStateView object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public SavedStateViewModel_ onUnbind(OnModelUnboundListener listener) { + public SavedStateViewModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final SavedStateView object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public SavedStateViewModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final SavedStateView object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public SavedStateViewModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + /** * Required. * @@ -199,6 +250,8 @@ protected int getDefaultLayout() { public SavedStateViewModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); this.clickListener_String = null; super.reset(); @@ -223,6 +276,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((clickListener_String != null ? !clickListener_String.equals(that.clickListener_String) : that.clickListener_String != null)) { return false; } @@ -234,6 +293,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (clickListener_String != null ? clickListener_String.hashCode() : 0); return result; } diff --git a/epoxy-processortest/src/test/resources/TestAfterBindPropsViewModel_.java b/epoxy-processortest/src/test/resources/TestAfterBindPropsViewModel_.java index ec3f71a879..1f5068d287 100644 --- a/epoxy-processortest/src/test/resources/TestAfterBindPropsViewModel_.java +++ b/epoxy-processortest/src/test/resources/TestAfterBindPropsViewModel_.java @@ -18,6 +18,10 @@ public class TestAfterBindPropsViewModel_ extends EpoxyModel onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + /** * Bitset index: 0 */ private boolean flag_Boolean = false; @@ -80,7 +84,8 @@ public void handlePostBind(final TestAfterBindPropsView object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public TestAfterBindPropsViewModel_ onBind(OnModelBoundListener listener) { + public TestAfterBindPropsViewModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -101,12 +106,58 @@ public void unbind(TestAfterBindPropsView object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public TestAfterBindPropsViewModel_ onUnbind(OnModelUnboundListener listener) { + public TestAfterBindPropsViewModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final TestAfterBindPropsView object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public TestAfterBindPropsViewModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final TestAfterBindPropsView object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public TestAfterBindPropsViewModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + /** * Optional: Default value is false * @@ -183,7 +234,8 @@ public TestAfterBindPropsViewModel_ layout(@LayoutRes int arg0) { } @Override - public TestAfterBindPropsViewModel_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public TestAfterBindPropsViewModel_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -216,6 +268,8 @@ protected int getDefaultLayout() { public TestAfterBindPropsViewModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); this.flag_Boolean = false; this.flagSuper_Boolean = false; @@ -241,6 +295,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((flag_Boolean != that.flag_Boolean)) { return false; } @@ -255,6 +315,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (flag_Boolean ? 1 : 0); result = 31 * result + (flagSuper_Boolean ? 1 : 0); return result; diff --git a/epoxy-processortest/src/test/resources/TestCallbackPropViewModel_.java b/epoxy-processortest/src/test/resources/TestCallbackPropViewModel_.java index ae72050955..bdf37726bc 100644 --- a/epoxy-processortest/src/test/resources/TestCallbackPropViewModel_.java +++ b/epoxy-processortest/src/test/resources/TestCallbackPropViewModel_.java @@ -19,6 +19,10 @@ public class TestCallbackPropViewModel_ extends EpoxyModel private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + /** * Bitset index: 0 */ @Nullable @@ -71,7 +75,8 @@ public void handlePostBind(final TestCallbackPropView object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public TestCallbackPropViewModel_ onBind(OnModelBoundListener listener) { + public TestCallbackPropViewModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -93,15 +98,62 @@ public void unbind(TestCallbackPropView object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public TestCallbackPropViewModel_ onUnbind(OnModelUnboundListener listener) { + public TestCallbackPropViewModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final TestCallbackPropView object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public TestCallbackPropViewModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final TestCallbackPropView object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public TestCallbackPropViewModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + /** * Set a click listener that will provide the parent view, model, and adapter position of the clicked view. This will clear the normal View.OnClickListener if one has been set */ - public TestCallbackPropViewModel_ listener(@Nullable final OnModelClickListener listener) { + public TestCallbackPropViewModel_ listener( + @Nullable final OnModelClickListener listener) { assignedAttributes_epoxyGeneratedModel.set(0); onMutation(); if (listener == null) { @@ -174,7 +226,8 @@ public TestCallbackPropViewModel_ layout(@LayoutRes int arg0) { } @Override - public TestCallbackPropViewModel_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public TestCallbackPropViewModel_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -207,6 +260,8 @@ protected int getDefaultLayout() { public TestCallbackPropViewModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); this.listener_OnClickListener = (View.OnClickListener) null; super.reset(); @@ -231,6 +286,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if (((listener_OnClickListener == null) != (that.listener_OnClickListener == null))) { return false; } @@ -242,6 +303,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (listener_OnClickListener != null ? 1 : 0); return result; } diff --git a/epoxy-processortest/src/test/resources/TestFieldPropCallbackPropViewModel_.java b/epoxy-processortest/src/test/resources/TestFieldPropCallbackPropViewModel_.java index 605d6d9aa8..52bcf60133 100644 --- a/epoxy-processortest/src/test/resources/TestFieldPropCallbackPropViewModel_.java +++ b/epoxy-processortest/src/test/resources/TestFieldPropCallbackPropViewModel_.java @@ -21,6 +21,10 @@ public class TestFieldPropCallbackPropViewModel_ extends EpoxyModel onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + /** * Bitset index: 0 */ @Nullable @@ -86,7 +90,8 @@ public void handlePostBind(final TestFieldPropCallbackPropView object, int posit * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public TestFieldPropCallbackPropViewModel_ onBind(OnModelBoundListener listener) { + public TestFieldPropCallbackPropViewModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -108,15 +113,63 @@ public void unbind(TestFieldPropCallbackPropView object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public TestFieldPropCallbackPropViewModel_ onUnbind(OnModelUnboundListener listener) { + public TestFieldPropCallbackPropViewModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, + final TestFieldPropCallbackPropView object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public TestFieldPropCallbackPropViewModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final TestFieldPropCallbackPropView object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public TestFieldPropCallbackPropViewModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + /** * Set a click listener that will provide the parent view, model, and adapter position of the clicked view. This will clear the normal View.OnClickListener if one has been set */ - public TestFieldPropCallbackPropViewModel_ value(@Nullable final OnModelClickListener value) { + public TestFieldPropCallbackPropViewModel_ value( + @Nullable final OnModelClickListener value) { assignedAttributes_epoxyGeneratedModel.set(0); onMutation(); if (value == null) { @@ -188,7 +241,8 @@ public TestFieldPropCallbackPropViewModel_ layout(@LayoutRes int arg0) { } @Override - public TestFieldPropCallbackPropViewModel_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public TestFieldPropCallbackPropViewModel_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -221,6 +275,8 @@ protected int getDefaultLayout() { public TestFieldPropCallbackPropViewModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); this.value_OnClickListener = (View.OnClickListener) null; super.reset(); @@ -245,6 +301,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if (((value_OnClickListener == null) != (that.value_OnClickListener == null))) { return false; } @@ -256,6 +318,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (value_OnClickListener != null ? 1 : 0); return result; } diff --git a/epoxy-processortest/src/test/resources/TestFieldPropChildViewModel_.java b/epoxy-processortest/src/test/resources/TestFieldPropChildViewModel_.java index 4e914557a0..6cc1e1b59a 100644 --- a/epoxy-processortest/src/test/resources/TestFieldPropChildViewModel_.java +++ b/epoxy-processortest/src/test/resources/TestFieldPropChildViewModel_.java @@ -27,6 +27,10 @@ public class TestFieldPropChildViewModel_ extends EpoxyModel onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + /** * Bitset index: 0 */ private StringAttributeData textValue_StringAttributeData = new StringAttributeData(); @@ -104,7 +108,8 @@ public void handlePostBind(final TestFieldPropChildView object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public TestFieldPropChildViewModel_ onBind(OnModelBoundListener listener) { + public TestFieldPropChildViewModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -126,12 +131,58 @@ public void unbind(TestFieldPropChildView object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public TestFieldPropChildViewModel_ onUnbind(OnModelUnboundListener listener) { + public TestFieldPropChildViewModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final TestFieldPropChildView object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public TestFieldPropChildViewModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final TestFieldPropChildView object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public TestFieldPropChildViewModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + public CharSequence getTextValue(Context context) { return textValue_StringAttributeData.toString(context); } @@ -196,7 +247,8 @@ public TestFieldPropChildViewModel_ textValueQuantityRes(@PluralsRes int pluralR /** * Set a click listener that will provide the parent view, model, and adapter position of the clicked view. This will clear the normal View.OnClickListener if one has been set */ - public TestFieldPropChildViewModel_ value(@Nullable final OnModelClickListener value) { + public TestFieldPropChildViewModel_ value( + @Nullable final OnModelClickListener value) { assignedAttributes_epoxyGeneratedModel.set(1); onMutation(); if (value == null) { @@ -269,7 +321,8 @@ public TestFieldPropChildViewModel_ layout(@LayoutRes int arg0) { } @Override - public TestFieldPropChildViewModel_ spanSizeOverride(@android.support.annotation.Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public TestFieldPropChildViewModel_ spanSizeOverride( + @android.support.annotation.Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -302,6 +355,8 @@ protected int getDefaultLayout() { public TestFieldPropChildViewModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); this.textValue_StringAttributeData = new StringAttributeData(); this.value_OnClickListener = (View.OnClickListener) null; @@ -327,6 +382,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((textValue_StringAttributeData != null ? !textValue_StringAttributeData.equals(that.textValue_StringAttributeData) : that.textValue_StringAttributeData != null)) { return false; } @@ -341,6 +402,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (textValue_StringAttributeData != null ? textValue_StringAttributeData.hashCode() : 0); result = 31 * result + (value_OnClickListener != null ? value_OnClickListener.hashCode() : 0); return result; diff --git a/epoxy-processortest/src/test/resources/TestFieldPropDoNotHashOptionViewModel_.java b/epoxy-processortest/src/test/resources/TestFieldPropDoNotHashOptionViewModel_.java index c1f90631cc..4d856d840a 100644 --- a/epoxy-processortest/src/test/resources/TestFieldPropDoNotHashOptionViewModel_.java +++ b/epoxy-processortest/src/test/resources/TestFieldPropDoNotHashOptionViewModel_.java @@ -24,6 +24,10 @@ public class TestFieldPropDoNotHashOptionViewModel_ extends EpoxyModel onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + /** * Bitset index: 0 */ @NonNull @@ -92,7 +96,8 @@ public void handlePostBind(final TestFieldPropDoNotHashOptionView object, int po * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public TestFieldPropDoNotHashOptionViewModel_ onBind(OnModelBoundListener listener) { + public TestFieldPropDoNotHashOptionViewModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -113,15 +118,63 @@ public void unbind(TestFieldPropDoNotHashOptionView object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public TestFieldPropDoNotHashOptionViewModel_ onUnbind(OnModelUnboundListener listener) { + public TestFieldPropDoNotHashOptionViewModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, + final TestFieldPropDoNotHashOptionView object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public TestFieldPropDoNotHashOptionViewModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final TestFieldPropDoNotHashOptionView object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public TestFieldPropDoNotHashOptionViewModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + /** * Set a click listener that will provide the parent view, model, and adapter position of the clicked view. This will clear the normal View.OnClickListener if one has been set */ - public TestFieldPropDoNotHashOptionViewModel_ value(@NonNull final OnModelClickListener value) { + public TestFieldPropDoNotHashOptionViewModel_ value( + @NonNull final OnModelClickListener value) { assignedAttributes_epoxyGeneratedModel.set(0); onMutation(); if (value == null) { @@ -196,7 +249,8 @@ public TestFieldPropDoNotHashOptionViewModel_ layout(@LayoutRes int arg0) { } @Override - public TestFieldPropDoNotHashOptionViewModel_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public TestFieldPropDoNotHashOptionViewModel_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -229,6 +283,8 @@ protected int getDefaultLayout() { public TestFieldPropDoNotHashOptionViewModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); this.value_OnClickListener = null; super.reset(); @@ -253,6 +309,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if (((value_OnClickListener == null) != (that.value_OnClickListener == null))) { return false; } @@ -264,6 +326,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (value_OnClickListener != null ? 1 : 0); return result; } diff --git a/epoxy-processortest/src/test/resources/TestFieldPropGenerateStringOverloadsOptionViewModel_.java b/epoxy-processortest/src/test/resources/TestFieldPropGenerateStringOverloadsOptionViewModel_.java index abb2a3ddc7..d379a1945b 100644 --- a/epoxy-processortest/src/test/resources/TestFieldPropGenerateStringOverloadsOptionViewModel_.java +++ b/epoxy-processortest/src/test/resources/TestFieldPropGenerateStringOverloadsOptionViewModel_.java @@ -26,6 +26,10 @@ public class TestFieldPropGenerateStringOverloadsOptionViewModel_ extends EpoxyM private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + /** * Bitset index: 0 */ private StringAttributeData value_StringAttributeData = new StringAttributeData(); @@ -95,7 +99,8 @@ public void handlePostBind(final TestFieldPropGenerateStringOverloadsOptionView * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public TestFieldPropGenerateStringOverloadsOptionViewModel_ onBind(OnModelBoundListener listener) { + public TestFieldPropGenerateStringOverloadsOptionViewModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -116,12 +121,60 @@ public void unbind(TestFieldPropGenerateStringOverloadsOptionView object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public TestFieldPropGenerateStringOverloadsOptionViewModel_ onUnbind(OnModelUnboundListener listener) { + public TestFieldPropGenerateStringOverloadsOptionViewModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, + final TestFieldPropGenerateStringOverloadsOptionView object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public TestFieldPropGenerateStringOverloadsOptionViewModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, + final TestFieldPropGenerateStringOverloadsOptionView object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public TestFieldPropGenerateStringOverloadsOptionViewModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + public CharSequence getValue(Context context) { return value_StringAttributeData.toString(context); } @@ -177,8 +230,8 @@ public TestFieldPropGenerateStringOverloadsOptionViewModel_ value(@StringRes int * * @see TestFieldPropGenerateStringOverloadsOptionView#value */ - public TestFieldPropGenerateStringOverloadsOptionViewModel_ valueQuantityRes(@PluralsRes int pluralRes, - int quantity, Object... formatArgs) { + public TestFieldPropGenerateStringOverloadsOptionViewModel_ valueQuantityRes( + @PluralsRes int pluralRes, int quantity, Object... formatArgs) { onMutation(); assignedAttributes_epoxyGeneratedModel.set(0); value_StringAttributeData.setValue(pluralRes, quantity, formatArgs); @@ -229,7 +282,8 @@ public TestFieldPropGenerateStringOverloadsOptionViewModel_ layout(@LayoutRes in } @Override - public TestFieldPropGenerateStringOverloadsOptionViewModel_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public TestFieldPropGenerateStringOverloadsOptionViewModel_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -262,6 +316,8 @@ protected int getDefaultLayout() { public TestFieldPropGenerateStringOverloadsOptionViewModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); this.value_StringAttributeData = new StringAttributeData(); super.reset(); @@ -286,6 +342,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((value_StringAttributeData != null ? !value_StringAttributeData.equals(that.value_StringAttributeData) : that.value_StringAttributeData != null)) { return false; } @@ -297,6 +359,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (value_StringAttributeData != null ? value_StringAttributeData.hashCode() : 0); return result; } diff --git a/epoxy-processortest/src/test/resources/TestFieldPropIgnoreRequireHashCodeOptionViewModel_.java b/epoxy-processortest/src/test/resources/TestFieldPropIgnoreRequireHashCodeOptionViewModel_.java index 933ac6932c..0e2e095042 100644 --- a/epoxy-processortest/src/test/resources/TestFieldPropIgnoreRequireHashCodeOptionViewModel_.java +++ b/epoxy-processortest/src/test/resources/TestFieldPropIgnoreRequireHashCodeOptionViewModel_.java @@ -24,6 +24,10 @@ public class TestFieldPropIgnoreRequireHashCodeOptionViewModel_ extends EpoxyMod private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + /** * Bitset index: 0 */ @NonNull @@ -94,7 +98,8 @@ public void handlePostBind(final TestFieldPropIgnoreRequireHashCodeOptionView ob * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public TestFieldPropIgnoreRequireHashCodeOptionViewModel_ onBind(OnModelBoundListener listener) { + public TestFieldPropIgnoreRequireHashCodeOptionViewModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -115,15 +120,64 @@ public void unbind(TestFieldPropIgnoreRequireHashCodeOptionView object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public TestFieldPropIgnoreRequireHashCodeOptionViewModel_ onUnbind(OnModelUnboundListener listener) { + public TestFieldPropIgnoreRequireHashCodeOptionViewModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, + final TestFieldPropIgnoreRequireHashCodeOptionView object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public TestFieldPropIgnoreRequireHashCodeOptionViewModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, + final TestFieldPropIgnoreRequireHashCodeOptionView object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public TestFieldPropIgnoreRequireHashCodeOptionViewModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + /** * Set a click listener that will provide the parent view, model, and adapter position of the clicked view. This will clear the normal View.OnClickListener if one has been set */ - public TestFieldPropIgnoreRequireHashCodeOptionViewModel_ value(@NonNull final OnModelClickListener value) { + public TestFieldPropIgnoreRequireHashCodeOptionViewModel_ value( + @NonNull final OnModelClickListener value) { assignedAttributes_epoxyGeneratedModel.set(0); onMutation(); if (value == null) { @@ -140,7 +194,8 @@ public TestFieldPropIgnoreRequireHashCodeOptionViewModel_ value(@NonNull final O * * @see TestFieldPropIgnoreRequireHashCodeOptionView#value */ - public TestFieldPropIgnoreRequireHashCodeOptionViewModel_ value(@NonNull View.OnClickListener value) { + public TestFieldPropIgnoreRequireHashCodeOptionViewModel_ value( + @NonNull View.OnClickListener value) { if (value == null) { throw new IllegalArgumentException("value cannot be null"); } @@ -199,7 +254,8 @@ public TestFieldPropIgnoreRequireHashCodeOptionViewModel_ layout(@LayoutRes int } @Override - public TestFieldPropIgnoreRequireHashCodeOptionViewModel_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public TestFieldPropIgnoreRequireHashCodeOptionViewModel_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -232,6 +288,8 @@ protected int getDefaultLayout() { public TestFieldPropIgnoreRequireHashCodeOptionViewModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); this.value_OnClickListener = null; super.reset(); @@ -256,6 +314,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((value_OnClickListener != null ? !value_OnClickListener.equals(that.value_OnClickListener) : that.value_OnClickListener != null)) { return false; } @@ -267,6 +331,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (value_OnClickListener != null ? value_OnClickListener.hashCode() : 0); return result; } diff --git a/epoxy-processortest/src/test/resources/TestFieldPropModelPropViewModel_.java b/epoxy-processortest/src/test/resources/TestFieldPropModelPropViewModel_.java index 748c6ce5cb..51b668fc2f 100644 --- a/epoxy-processortest/src/test/resources/TestFieldPropModelPropViewModel_.java +++ b/epoxy-processortest/src/test/resources/TestFieldPropModelPropViewModel_.java @@ -20,6 +20,10 @@ public class TestFieldPropModelPropViewModel_ extends EpoxyModel onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + /** * Bitset index: 0 */ private int value_Int = 0; @@ -84,7 +88,8 @@ public void handlePostBind(final TestFieldPropModelPropView object, int position * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public TestFieldPropModelPropViewModel_ onBind(OnModelBoundListener listener) { + public TestFieldPropModelPropViewModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -105,12 +110,58 @@ public void unbind(TestFieldPropModelPropView object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public TestFieldPropModelPropViewModel_ onUnbind(OnModelUnboundListener listener) { + public TestFieldPropModelPropViewModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final TestFieldPropModelPropView object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public TestFieldPropModelPropViewModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final TestFieldPropModelPropView object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public TestFieldPropModelPropViewModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + /** * Optional: Default value is 0 * @@ -170,7 +221,8 @@ public TestFieldPropModelPropViewModel_ layout(@LayoutRes int arg0) { } @Override - public TestFieldPropModelPropViewModel_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public TestFieldPropModelPropViewModel_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -203,6 +255,8 @@ protected int getDefaultLayout() { public TestFieldPropModelPropViewModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); this.value_Int = 0; super.reset(); @@ -227,6 +281,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((value_Int != that.value_Int)) { return false; } @@ -238,6 +298,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + value_Int; return result; } diff --git a/epoxy-processortest/src/test/resources/TestFieldPropNullOnRecycleOptionViewModel_.java b/epoxy-processortest/src/test/resources/TestFieldPropNullOnRecycleOptionViewModel_.java index bbd51c3cf3..f682047bb6 100644 --- a/epoxy-processortest/src/test/resources/TestFieldPropNullOnRecycleOptionViewModel_.java +++ b/epoxy-processortest/src/test/resources/TestFieldPropNullOnRecycleOptionViewModel_.java @@ -21,6 +21,10 @@ public class TestFieldPropNullOnRecycleOptionViewModel_ extends EpoxyModel onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + /** * Bitset index: 0 */ @Nullable @@ -86,7 +90,8 @@ public void handlePostBind(final TestFieldPropNullOnRecycleOptionView object, in * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public TestFieldPropNullOnRecycleOptionViewModel_ onBind(OnModelBoundListener listener) { + public TestFieldPropNullOnRecycleOptionViewModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -108,15 +113,63 @@ public void unbind(TestFieldPropNullOnRecycleOptionView object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public TestFieldPropNullOnRecycleOptionViewModel_ onUnbind(OnModelUnboundListener listener) { + public TestFieldPropNullOnRecycleOptionViewModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, + final TestFieldPropNullOnRecycleOptionView object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public TestFieldPropNullOnRecycleOptionViewModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final TestFieldPropNullOnRecycleOptionView object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public TestFieldPropNullOnRecycleOptionViewModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + /** * Set a click listener that will provide the parent view, model, and adapter position of the clicked view. This will clear the normal View.OnClickListener if one has been set */ - public TestFieldPropNullOnRecycleOptionViewModel_ value(@Nullable final OnModelClickListener value) { + public TestFieldPropNullOnRecycleOptionViewModel_ value( + @Nullable final OnModelClickListener value) { assignedAttributes_epoxyGeneratedModel.set(0); onMutation(); if (value == null) { @@ -152,7 +205,8 @@ public TestFieldPropNullOnRecycleOptionViewModel_ id(long id) { } @Override - public TestFieldPropNullOnRecycleOptionViewModel_ id(@android.support.annotation.Nullable Number... arg0) { + public TestFieldPropNullOnRecycleOptionViewModel_ id( + @android.support.annotation.Nullable Number... arg0) { super.id(arg0); return this; } @@ -164,21 +218,23 @@ public TestFieldPropNullOnRecycleOptionViewModel_ id(long id1, long id2) { } @Override - public TestFieldPropNullOnRecycleOptionViewModel_ id(@android.support.annotation.Nullable CharSequence arg0) { + public TestFieldPropNullOnRecycleOptionViewModel_ id( + @android.support.annotation.Nullable CharSequence arg0) { super.id(arg0); return this; } @Override - public TestFieldPropNullOnRecycleOptionViewModel_ id(@android.support.annotation.Nullable CharSequence arg0, + public TestFieldPropNullOnRecycleOptionViewModel_ id( + @android.support.annotation.Nullable CharSequence arg0, @android.support.annotation.Nullable CharSequence... arg1) { super.id(arg0, arg1); return this; } @Override - public TestFieldPropNullOnRecycleOptionViewModel_ id(@android.support.annotation.Nullable CharSequence arg0, - long arg1) { + public TestFieldPropNullOnRecycleOptionViewModel_ id( + @android.support.annotation.Nullable CharSequence arg0, long arg1) { super.id(arg0, arg1); return this; } @@ -189,7 +245,8 @@ public TestFieldPropNullOnRecycleOptionViewModel_ layout(@LayoutRes int arg0) { } @Override - public TestFieldPropNullOnRecycleOptionViewModel_ spanSizeOverride(@android.support.annotation.Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public TestFieldPropNullOnRecycleOptionViewModel_ spanSizeOverride( + @android.support.annotation.Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -222,6 +279,8 @@ protected int getDefaultLayout() { public TestFieldPropNullOnRecycleOptionViewModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); this.value_OnClickListener = (View.OnClickListener) null; super.reset(); @@ -246,6 +305,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((value_OnClickListener != null ? !value_OnClickListener.equals(that.value_OnClickListener) : that.value_OnClickListener != null)) { return false; } @@ -257,6 +322,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (value_OnClickListener != null ? value_OnClickListener.hashCode() : 0); return result; } diff --git a/epoxy-processortest/src/test/resources/TestFieldPropTextPropViewModel_.java b/epoxy-processortest/src/test/resources/TestFieldPropTextPropViewModel_.java index a1722211eb..a34ec3efac 100644 --- a/epoxy-processortest/src/test/resources/TestFieldPropTextPropViewModel_.java +++ b/epoxy-processortest/src/test/resources/TestFieldPropTextPropViewModel_.java @@ -26,6 +26,10 @@ public class TestFieldPropTextPropViewModel_ extends EpoxyModel onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + /** * Bitset index: 0 */ private StringAttributeData value_StringAttributeData = new StringAttributeData(); @@ -93,7 +97,8 @@ public void handlePostBind(final TestFieldPropTextPropView object, int position) * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public TestFieldPropTextPropViewModel_ onBind(OnModelBoundListener listener) { + public TestFieldPropTextPropViewModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -114,12 +119,58 @@ public void unbind(TestFieldPropTextPropView object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public TestFieldPropTextPropViewModel_ onUnbind(OnModelUnboundListener listener) { + public TestFieldPropTextPropViewModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final TestFieldPropTextPropView object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public TestFieldPropTextPropViewModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final TestFieldPropTextPropView object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public TestFieldPropTextPropViewModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + public CharSequence getValue(Context context) { return value_StringAttributeData.toString(context); } @@ -225,7 +276,8 @@ public TestFieldPropTextPropViewModel_ layout(@LayoutRes int arg0) { } @Override - public TestFieldPropTextPropViewModel_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public TestFieldPropTextPropViewModel_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -258,6 +310,8 @@ protected int getDefaultLayout() { public TestFieldPropTextPropViewModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); this.value_StringAttributeData = new StringAttributeData(); super.reset(); @@ -282,6 +336,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((value_StringAttributeData != null ? !value_StringAttributeData.equals(that.value_StringAttributeData) : that.value_StringAttributeData != null)) { return false; } @@ -293,6 +353,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (value_StringAttributeData != null ? value_StringAttributeData.hashCode() : 0); return result; } diff --git a/epoxy-processortest/src/test/resources/TestManyTypesViewModelBuilder.java b/epoxy-processortest/src/test/resources/TestManyTypesViewModelBuilder.java index 0d6f16667a..1b2197442b 100644 --- a/epoxy-processortest/src/test/resources/TestManyTypesViewModelBuilder.java +++ b/epoxy-processortest/src/test/resources/TestManyTypesViewModelBuilder.java @@ -17,9 +17,17 @@ import java.util.List; public interface TestManyTypesViewModelBuilder { - TestManyTypesViewModelBuilder onBind(OnModelBoundListener listener); + TestManyTypesViewModelBuilder onBind( + OnModelBoundListener listener); - TestManyTypesViewModelBuilder onUnbind(OnModelUnboundListener listener); + TestManyTypesViewModelBuilder onUnbind( + OnModelUnboundListener listener); + + TestManyTypesViewModelBuilder onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener); + + TestManyTypesViewModelBuilder onVisibilityChanged( + OnModelVisibilityChangedListener listener); TestManyTypesViewModelBuilder stringValue(@NonNull String stringValue); @@ -29,11 +37,14 @@ public interface TestManyTypesViewModelBuilder { TestManyTypesViewModelBuilder intValueWithAnnotation(@StringRes int intValueWithAnnotation); - TestManyTypesViewModelBuilder intValueWithRangeAnnotation(@IntRange(from = 0, to = 200) int intValueWithRangeAnnotation); + TestManyTypesViewModelBuilder intValueWithRangeAnnotation( + @IntRange(from = 0, to = 200) int intValueWithRangeAnnotation); - TestManyTypesViewModelBuilder intValueWithDimenTypeAnnotation(@Dimension(unit = 0) int intValueWithDimenTypeAnnotation); + TestManyTypesViewModelBuilder intValueWithDimenTypeAnnotation( + @Dimension(unit = 0) int intValueWithDimenTypeAnnotation); - TestManyTypesViewModelBuilder intWithMultipleAnnotations(@IntRange(from = 0, to = 200) @Dimension(unit = 0) int intWithMultipleAnnotations); + TestManyTypesViewModelBuilder intWithMultipleAnnotations( + @IntRange(from = 0, to = 200) @Dimension(unit = 0) int intWithMultipleAnnotations); TestManyTypesViewModelBuilder integerValue(@NonNull Integer integerValue); @@ -45,7 +56,8 @@ public interface TestManyTypesViewModelBuilder { TestManyTypesViewModelBuilder listValue(@NonNull List listValue); - TestManyTypesViewModelBuilder clickListener(@NonNull final OnModelClickListener clickListener); + TestManyTypesViewModelBuilder clickListener( + @NonNull final OnModelClickListener clickListener); TestManyTypesViewModelBuilder clickListener(@NonNull View.OnClickListener clickListener); @@ -72,5 +84,6 @@ TestManyTypesViewModelBuilder titleQuantityRes(@PluralsRes int pluralRes, int qu TestManyTypesViewModelBuilder layout(@LayoutRes int arg0); - TestManyTypesViewModelBuilder spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0); + TestManyTypesViewModelBuilder spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0); } \ No newline at end of file diff --git a/epoxy-processortest/src/test/resources/TestManyTypesViewModel_.java b/epoxy-processortest/src/test/resources/TestManyTypesViewModel_.java index 89a2bd9604..52756d0758 100644 --- a/epoxy-processortest/src/test/resources/TestManyTypesViewModel_.java +++ b/epoxy-processortest/src/test/resources/TestManyTypesViewModel_.java @@ -31,6 +31,10 @@ public class TestManyTypesViewModel_ extends EpoxyModel imple private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + /** * Bitset index: 0 */ @NonNull @@ -239,7 +243,8 @@ public void handlePostBind(final TestManyTypesView object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public TestManyTypesViewModel_ onBind(OnModelBoundListener listener) { + public TestManyTypesViewModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -260,12 +265,58 @@ public void unbind(TestManyTypesView object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public TestManyTypesViewModel_ onUnbind(OnModelUnboundListener listener) { + public TestManyTypesViewModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final TestManyTypesView object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public TestManyTypesViewModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final TestManyTypesView object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public TestManyTypesViewModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + /** * Required. * @@ -341,7 +392,8 @@ public int intValueWithAnnotation() { * * @see TestManyTypesView#setIntValueWithRangeAnnotation(int) */ - public TestManyTypesViewModel_ intValueWithRangeAnnotation(@IntRange(from = 0, to = 200) int intValueWithRangeAnnotation) { + public TestManyTypesViewModel_ intValueWithRangeAnnotation( + @IntRange(from = 0, to = 200) int intValueWithRangeAnnotation) { assignedAttributes_epoxyGeneratedModel.set(4); onMutation(); this.intValueWithRangeAnnotation_Int = intValueWithRangeAnnotation; @@ -361,7 +413,8 @@ public int intValueWithRangeAnnotation() { * * @see TestManyTypesView#setIntValueWithDimenTypeAnnotation(int) */ - public TestManyTypesViewModel_ intValueWithDimenTypeAnnotation(@Dimension(unit = 0) int intValueWithDimenTypeAnnotation) { + public TestManyTypesViewModel_ intValueWithDimenTypeAnnotation( + @Dimension(unit = 0) int intValueWithDimenTypeAnnotation) { assignedAttributes_epoxyGeneratedModel.set(5); onMutation(); this.intValueWithDimenTypeAnnotation_Int = intValueWithDimenTypeAnnotation; @@ -380,7 +433,8 @@ public int intValueWithDimenTypeAnnotation() { * * @see TestManyTypesView#setIntWithMultipleAnnotations(int) */ - public TestManyTypesViewModel_ intWithMultipleAnnotations(@IntRange(from = 0, to = 200) @Dimension(unit = 0) int intWithMultipleAnnotations) { + public TestManyTypesViewModel_ intWithMultipleAnnotations( + @IntRange(from = 0, to = 200) @Dimension(unit = 0) int intWithMultipleAnnotations) { assignedAttributes_epoxyGeneratedModel.set(6); onMutation(); this.intWithMultipleAnnotations_Int = intWithMultipleAnnotations; @@ -496,7 +550,8 @@ public List listValue() { /** * Set a click listener that will provide the parent view, model, and adapter position of the clicked view. This will clear the normal View.OnClickListener if one has been set */ - public TestManyTypesViewModel_ clickListener(@NonNull final OnModelClickListener clickListener) { + public TestManyTypesViewModel_ clickListener( + @NonNull final OnModelClickListener clickListener) { assignedAttributes_epoxyGeneratedModel.set(12); onMutation(); if (clickListener == null) { @@ -631,7 +686,8 @@ public TestManyTypesViewModel_ layout(@LayoutRes int arg0) { } @Override - public TestManyTypesViewModel_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public TestManyTypesViewModel_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -664,6 +720,8 @@ protected int getDefaultLayout() { public TestManyTypesViewModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); this.stringValue_String = null; this.nullableStringValue_String = (String) null; @@ -701,6 +759,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((stringValue_String != null ? !stringValue_String.equals(that.stringValue_String) : that.stringValue_String != null)) { return false; } @@ -751,6 +815,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (stringValue_String != null ? stringValue_String.hashCode() : 0); result = 31 * result + (nullableStringValue_String != null ? nullableStringValue_String.hashCode() : 0); result = 31 * result + intValue_Int; diff --git a/epoxy-processortest/src/test/resources/TestNullStringOverloadsViewModel_.java b/epoxy-processortest/src/test/resources/TestNullStringOverloadsViewModel_.java index 06c0cb400b..72bff9b1c4 100644 --- a/epoxy-processortest/src/test/resources/TestNullStringOverloadsViewModel_.java +++ b/epoxy-processortest/src/test/resources/TestNullStringOverloadsViewModel_.java @@ -21,6 +21,10 @@ public class TestNullStringOverloadsViewModel_ extends EpoxyModel onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + /** * Bitset index: 0 */ private StringAttributeData title_StringAttributeData = new StringAttributeData((CharSequence) null); @@ -72,7 +76,8 @@ public void handlePostBind(final TestNullStringOverloadsView object, int positio * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public TestNullStringOverloadsViewModel_ onBind(OnModelBoundListener listener) { + public TestNullStringOverloadsViewModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -93,12 +98,59 @@ public void unbind(TestNullStringOverloadsView object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public TestNullStringOverloadsViewModel_ onUnbind(OnModelUnboundListener listener) { + public TestNullStringOverloadsViewModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, + final TestNullStringOverloadsView object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public TestNullStringOverloadsViewModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final TestNullStringOverloadsView object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public TestNullStringOverloadsViewModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + @Nullable public CharSequence getTitle(Context context) { return title_StringAttributeData.toString(context); @@ -203,7 +255,8 @@ public TestNullStringOverloadsViewModel_ layout(@LayoutRes int arg0) { } @Override - public TestNullStringOverloadsViewModel_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public TestNullStringOverloadsViewModel_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -236,6 +289,8 @@ protected int getDefaultLayout() { public TestNullStringOverloadsViewModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); this.title_StringAttributeData = new StringAttributeData((CharSequence) null); super.reset(); @@ -260,6 +315,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((title_StringAttributeData != null ? !title_StringAttributeData.equals(that.title_StringAttributeData) : that.title_StringAttributeData != null)) { return false; } @@ -271,6 +332,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (title_StringAttributeData != null ? title_StringAttributeData.hashCode() : 0); return result; } diff --git a/epoxy-processortest/src/test/resources/TestStringOverloadsViewModel_.java b/epoxy-processortest/src/test/resources/TestStringOverloadsViewModel_.java index 71bb399761..d871408bab 100644 --- a/epoxy-processortest/src/test/resources/TestStringOverloadsViewModel_.java +++ b/epoxy-processortest/src/test/resources/TestStringOverloadsViewModel_.java @@ -25,6 +25,10 @@ public class TestStringOverloadsViewModel_ extends EpoxyModel onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + /** * Bitset index: 0 */ private StringAttributeData title_StringAttributeData = new StringAttributeData(); @@ -112,7 +116,8 @@ public void handlePostBind(final TestStringOverloadsView object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public TestStringOverloadsViewModel_ onBind(OnModelBoundListener listener) { + public TestStringOverloadsViewModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -133,12 +138,58 @@ public void unbind(TestStringOverloadsView object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public TestStringOverloadsViewModel_ onUnbind(OnModelUnboundListener listener) { + public TestStringOverloadsViewModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final TestStringOverloadsView object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public TestStringOverloadsViewModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final TestStringOverloadsView object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public TestStringOverloadsViewModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + public CharSequence titleStringAttributeData(Context context) { return title_StringAttributeData.toString(context); } @@ -229,7 +280,8 @@ public CharSequence getTitleViaValueShortcut(Context context) { * * @see TestStringOverloadsView#setTitleViaValueShortcut(CharSequence) */ - public TestStringOverloadsViewModel_ titleViaValueShortcut(@NonNull CharSequence titleViaValueShortcut) { + public TestStringOverloadsViewModel_ titleViaValueShortcut( + @NonNull CharSequence titleViaValueShortcut) { onMutation(); assignedAttributes_epoxyGeneratedModel.set(2); if (titleViaValueShortcut == null) { @@ -327,7 +379,8 @@ public TestStringOverloadsViewModel_ layout(@LayoutRes int arg0) { } @Override - public TestStringOverloadsViewModel_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public TestStringOverloadsViewModel_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -360,6 +413,8 @@ protected int getDefaultLayout() { public TestStringOverloadsViewModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); this.title_StringAttributeData = new StringAttributeData(); this.title_List = (List) null; @@ -386,6 +441,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((title_StringAttributeData != null ? !title_StringAttributeData.equals(that.title_StringAttributeData) : that.title_StringAttributeData != null)) { return false; } @@ -403,6 +464,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (title_StringAttributeData != null ? title_StringAttributeData.hashCode() : 0); result = 31 * result + (title_List != null ? title_List.hashCode() : 0); result = 31 * result + (titleViaValueShortcut_StringAttributeData != null ? titleViaValueShortcut_StringAttributeData.hashCode() : 0); diff --git a/epoxy-processortest/src/test/resources/TestTextPropViewModel_.java b/epoxy-processortest/src/test/resources/TestTextPropViewModel_.java index 3d9f7f09ca..4863a4f70b 100644 --- a/epoxy-processortest/src/test/resources/TestTextPropViewModel_.java +++ b/epoxy-processortest/src/test/resources/TestTextPropViewModel_.java @@ -24,6 +24,10 @@ public class TestTextPropViewModel_ extends EpoxyModel impleme private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + /** * Bitset index: 0 */ private StringAttributeData title_StringAttributeData = new StringAttributeData(); @@ -78,7 +82,8 @@ public void handlePostBind(final TestTextPropView object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public TestTextPropViewModel_ onBind(OnModelBoundListener listener) { + public TestTextPropViewModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -99,12 +104,58 @@ public void unbind(TestTextPropView object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public TestTextPropViewModel_ onUnbind(OnModelUnboundListener listener) { + public TestTextPropViewModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final TestTextPropView object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public TestTextPropViewModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final TestTextPropView object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public TestTextPropViewModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + public CharSequence getTitle(Context context) { return title_StringAttributeData.toString(context); } @@ -210,7 +261,8 @@ public TestTextPropViewModel_ layout(@LayoutRes int arg0) { } @Override - public TestTextPropViewModel_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public TestTextPropViewModel_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -243,6 +295,8 @@ protected int getDefaultLayout() { public TestTextPropViewModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); this.title_StringAttributeData = new StringAttributeData(); super.reset(); @@ -267,6 +321,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((title_StringAttributeData != null ? !title_StringAttributeData.equals(that.title_StringAttributeData) : that.title_StringAttributeData != null)) { return false; } @@ -278,6 +338,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (title_StringAttributeData != null ? title_StringAttributeData.hashCode() : 0); return result; } diff --git a/epoxy-processortest/src/test/resources/TextPropDefaultViewModel_.java b/epoxy-processortest/src/test/resources/TextPropDefaultViewModel_.java index c45cf00780..ee05c44a29 100644 --- a/epoxy-processortest/src/test/resources/TextPropDefaultViewModel_.java +++ b/epoxy-processortest/src/test/resources/TextPropDefaultViewModel_.java @@ -24,6 +24,10 @@ public class TextPropDefaultViewModel_ extends EpoxyModel i private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + /** * Bitset index: 0 */ private StringAttributeData textWithDefault_StringAttributeData = new StringAttributeData(R.string.string_resource_value); @@ -87,7 +91,8 @@ public void handlePostBind(final TextPropDefaultView object, int position) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public TextPropDefaultViewModel_ onBind(OnModelBoundListener listener) { + public TextPropDefaultViewModel_ onBind( + OnModelBoundListener listener) { onMutation(); this.onModelBoundListener_epoxyGeneratedModel = listener; return this; @@ -108,12 +113,58 @@ public void unbind(TextPropDefaultView object) { * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. *

* You may clear the listener by setting a null value, or by calling {@link #reset()} */ - public TextPropDefaultViewModel_ onUnbind(OnModelUnboundListener listener) { + public TextPropDefaultViewModel_ onUnbind( + OnModelUnboundListener listener) { onMutation(); this.onModelUnboundListener_epoxyGeneratedModel = listener; return this; } + @Override + public void visibilityStateChanged(int visibilityState, final TextPropDefaultView object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.visibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public TextPropDefaultViewModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final TextPropDefaultView object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public TextPropDefaultViewModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + public CharSequence getTextWithDefault(Context context) { return textWithDefault_StringAttributeData.toString(context); } @@ -186,7 +237,8 @@ public CharSequence getNullableTextWithDefault(Context context) { * * @see TextPropDefaultView#nullableTextWithDefault(CharSequence) */ - public TextPropDefaultViewModel_ nullableTextWithDefault(@Nullable CharSequence nullableTextWithDefault) { + public TextPropDefaultViewModel_ nullableTextWithDefault( + @Nullable CharSequence nullableTextWithDefault) { onMutation(); assignedAttributes_epoxyGeneratedModel.set(1); nullableTextWithDefault_StringAttributeData.setValue(nullableTextWithDefault); @@ -280,7 +332,8 @@ public TextPropDefaultViewModel_ layout(@LayoutRes int arg0) { } @Override - public TextPropDefaultViewModel_ spanSizeOverride(@Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + public TextPropDefaultViewModel_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { super.spanSizeOverride(arg0); return this; } @@ -313,6 +366,8 @@ protected int getDefaultLayout() { public TextPropDefaultViewModel_ reset() { onModelBoundListener_epoxyGeneratedModel = null; onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; assignedAttributes_epoxyGeneratedModel.clear(); this.textWithDefault_StringAttributeData = new StringAttributeData(R.string.string_resource_value); this.nullableTextWithDefault_StringAttributeData = new StringAttributeData(R.string.string_resource_value); @@ -338,6 +393,12 @@ public boolean equals(Object o) { if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { return false; } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } if ((textWithDefault_StringAttributeData != null ? !textWithDefault_StringAttributeData.equals(that.textWithDefault_StringAttributeData) : that.textWithDefault_StringAttributeData != null)) { return false; } @@ -352,6 +413,8 @@ public int hashCode() { int result = super.hashCode(); result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); result = 31 * result + (textWithDefault_StringAttributeData != null ? textWithDefault_StringAttributeData.hashCode() : 0); result = 31 * result + (nullableTextWithDefault_StringAttributeData != null ? nullableTextWithDefault_StringAttributeData.hashCode() : 0); return result; From 51fb99fdf57008ab434a1c42ec5a3e4d326ce549 Mon Sep 17 00:00:00 2001 From: Emmanuel Boudrant Date: Mon, 8 Oct 2018 09:03:39 -0700 Subject: [PATCH 10/38] Send unfocused event on detach event --- .../java/com/airbnb/epoxy/EpoxyVisibilityItem.java | 10 +++++----- .../java/com/airbnb/epoxy/EpoxyVisibilityTracker.java | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java index ca96befa36..298744b97b 100644 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java @@ -92,8 +92,8 @@ void handleFocusedVisible(EpoxyViewHolder epoxyHolder) { } } - void handleUnfocusedVisible(EpoxyViewHolder epoxyHolder) { - if (focusedVisible && isUnfocusedVisible()) { + void handleUnfocusedVisible(EpoxyViewHolder epoxyHolder, boolean detachEvent) { + if (focusedVisible && isUnfocusedVisible(detachEvent)) { epoxyHolder.visibilityStateChanged(OnModelVisibilityStateChangedListener.UNFOCUSED_VISIBLE); } } @@ -137,11 +137,11 @@ private boolean isFocusedVisible() { size >= viewportSize / 2 || (visibleSize == size && size < viewportSize / 2); } - private boolean isUnfocusedVisible() { + private boolean isUnfocusedVisible(boolean detachEvent) { // true when the Component is no longer focused, i.e. it is not fully visible and does not // occupy at least half the viewport. - boolean unfocusedVisible = - !(size >= viewportSize / 2 || (visibleSize == size && size < viewportSize / 2)); + boolean unfocusedVisible = detachEvent + || !(size >= viewportSize / 2 || (visibleSize == size && size < viewportSize / 2)); if (unfocusedVisible) { focusedVisible = false; } diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityTracker.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityTracker.java index 43694321bd..8e3419b62a 100644 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityTracker.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityTracker.java @@ -124,7 +124,7 @@ private void processVisibilityEvents( vi.handleVisible(epoxyHolder); vi.handleInvisible(epoxyHolder, detachEvent); vi.handleFocusedVisible(epoxyHolder); - vi.handleUnfocusedVisible(epoxyHolder); + vi.handleUnfocusedVisible(epoxyHolder, detachEvent); vi.handleFullImpressionVisible(epoxyHolder); vi.handleChanged(epoxyHolder); } From 16d71f6da9e4f86a4c80adba42a93a984c3c07ad Mon Sep 17 00:00:00 2001 From: Emmanuel Boudrant Date: Tue, 9 Oct 2018 17:21:29 -0700 Subject: [PATCH 11/38] Add float ranges --- .../src/main/java/com/airbnb/epoxy/EpoxyModel.java | 10 ++++++++-- .../main/java/com/airbnb/epoxy/EpoxyViewHolder.java | 9 +++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModel.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModel.java index ae8cb10485..9b352b5589 100755 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModel.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModel.java @@ -1,5 +1,6 @@ package com.airbnb.epoxy; +import android.support.annotation.FloatRange; import android.support.annotation.LayoutRes; import android.support.annotation.NonNull; import android.support.annotation.Nullable; @@ -159,8 +160,13 @@ public void unbind(@NonNull T view) { public void visibilityStateChanged(@VisibilityState int visibilityState, @NonNull T view) { } - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, - int visibleHeight, int visibleWidth, @NonNull T view) { + public void visibilityChanged( + @FloatRange(from = 0.0f, to = 100.0f) float percentVisibleHeight, + @FloatRange(from = 0.0f, to = 100.0f) float percentVisibleWidth, + int visibleHeight, + int visibleWidth, + @NonNull T view + ) { } public long id() { diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyViewHolder.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyViewHolder.java index 7f53e5c8a8..dc67598bf5 100755 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyViewHolder.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyViewHolder.java @@ -1,6 +1,7 @@ package com.airbnb.epoxy; +import android.support.annotation.FloatRange; import android.support.annotation.Nullable; import android.support.v7.widget.RecyclerView; import android.view.View; @@ -89,8 +90,12 @@ public void visibilityStateChanged(@VisibilityState int visibilityState) { epoxyModel.visibilityStateChanged(visibilityState, objectToBind()); } - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, - int visibleHeight, int visibleWidth) { + public void visibilityChanged( + @FloatRange(from = 0.0f, to = 100.0f) float percentVisibleHeight, + @FloatRange(from = 0.0f, to = 100.0f) float percentVisibleWidth, + int visibleHeight, + int visibleWidth + ) { assertBound(); // noinspection unchecked epoxyModel.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, From 62478baf93de4cc9ebbb3415b87b5d46733d3116 Mon Sep 17 00:00:00 2001 From: Emmanuel Boudrant Date: Tue, 9 Oct 2018 17:21:52 -0700 Subject: [PATCH 12/38] Rename to sizeInScrollingDirection; --- .../com/airbnb/epoxy/EpoxyVisibilityItem.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java index 298744b97b..b063e15034 100644 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java @@ -14,7 +14,7 @@ class EpoxyVisibilityItem { private int adapterPosition = RecyclerView.NO_POSITION; @Px - int size; + int sizeInScrollingDirection; private int otherSize; @@ -45,21 +45,21 @@ boolean update(@NonNull View view, @NonNull RecyclerView parent, int orientation view.getLocalVisibleRect(localVisibleRect); vertical = orientation == LinearLayoutManager.VERTICAL; if (vertical) { - size = view.getMeasuredHeight(); + sizeInScrollingDirection = view.getMeasuredHeight(); otherSize = view.getMeasuredWidth(); viewportSize = parent.getMeasuredHeight(); visibleSize = localVisibleRect.height(); } else { otherSize = view.getMeasuredHeight(); - size = view.getMeasuredWidth(); + sizeInScrollingDirection = view.getMeasuredWidth(); viewportSize = parent.getMeasuredWidth(); visibleSize = localVisibleRect.width(); } - percentVisibleSize = 100.f / size * visibleSize; - if (visibleSize != size) { + percentVisibleSize = 100.f / sizeInScrollingDirection * visibleSize; + if (visibleSize != sizeInScrollingDirection) { fullyVisible = false; } - return size > 0; + return sizeInScrollingDirection > 0; } int getAdapterPosition() { @@ -134,14 +134,16 @@ private boolean isFocusedVisible() { // true when either the Component occupies at least half of the viewport, or, if the Component // is smaller than half the viewport, when it is fully visible. return focusedVisible = - size >= viewportSize / 2 || (visibleSize == size && size < viewportSize / 2); + sizeInScrollingDirection >= viewportSize / 2 || (visibleSize == sizeInScrollingDirection + && sizeInScrollingDirection < viewportSize / 2); } private boolean isUnfocusedVisible(boolean detachEvent) { // true when the Component is no longer focused, i.e. it is not fully visible and does not // occupy at least half the viewport. boolean unfocusedVisible = detachEvent - || !(size >= viewportSize / 2 || (visibleSize == size && size < viewportSize / 2)); + || !(sizeInScrollingDirection >= viewportSize / 2 || ( + visibleSize == sizeInScrollingDirection && sizeInScrollingDirection < viewportSize / 2)); if (unfocusedVisible) { focusedVisible = false; } @@ -150,7 +152,7 @@ private boolean isUnfocusedVisible(boolean detachEvent) { private boolean isFullImpressionVisible() { // true when the entire Component has passed through the viewport at some point. - return fullyVisible = visibleSize == size; + return fullyVisible = visibleSize == sizeInScrollingDirection; } } From aa39ae25c7cdf5140c570d05f9b373a84f9e9923 Mon Sep 17 00:00:00 2001 From: Emmanuel Boudrant Date: Tue, 9 Oct 2018 23:39:56 -0700 Subject: [PATCH 13/38] Can be private --- .../src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java index b063e15034..d67f939aab 100644 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java @@ -14,7 +14,7 @@ class EpoxyVisibilityItem { private int adapterPosition = RecyclerView.NO_POSITION; @Px - int sizeInScrollingDirection; + private int sizeInScrollingDirection; private int otherSize; From cd5619ff708d105b19601f3eeea5066864dbdd94 Mon Sep 17 00:00:00 2001 From: Emmanuel Boudrant Date: Tue, 9 Oct 2018 23:41:12 -0700 Subject: [PATCH 14/38] typo --- .../src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java index d67f939aab..c8d920e352 100644 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java @@ -30,7 +30,7 @@ class EpoxyVisibilityItem { private boolean visible = false; private boolean focusedVisible = false; - /** Store last value for deduping */ + /** Store last value for de-duping */ private int lastVisibleSizeNotified = -1; /** From 25ce009ebb63d0c94dc7c20b4bd34f3d3f9e2534 Mon Sep 17 00:00:00 2001 From: Emmanuel Boudrant Date: Tue, 9 Oct 2018 23:41:34 -0700 Subject: [PATCH 15/38] Remove dependency to LinearLayoutManager --- .../com/airbnb/epoxy/EpoxyVisibilityItem.java | 7 ++- .../airbnb/epoxy/EpoxyVisibilityTracker.java | 44 +++++-------------- 2 files changed, 15 insertions(+), 36 deletions(-) diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java index c8d920e352..486ff47ff6 100644 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java @@ -3,7 +3,6 @@ import android.graphics.Rect; import android.support.annotation.NonNull; import android.support.annotation.Px; -import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.view.View; @@ -38,12 +37,12 @@ class EpoxyVisibilityItem { * * @param view the current {@link com.airbnb.epoxy.EpoxyViewHolder}'s itemView * @param parent the {@link android.support.v7.widget.RecyclerView} - * @param orientation the {@link android.support.v7.widget.LinearLayoutManager}'s orientation + * @param vertical true if it scroll vertically * @return true if the view has been measured */ - boolean update(@NonNull View view, @NonNull RecyclerView parent, int orientation) { + boolean update(@NonNull View view, @NonNull RecyclerView parent, boolean vertical) { view.getLocalVisibleRect(localVisibleRect); - vertical = orientation == LinearLayoutManager.VERTICAL; + this.vertical = vertical; if (vertical) { sizeInScrollingDirection = view.getMeasuredHeight(); otherSize = view.getMeasuredWidth(); diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityTracker.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityTracker.java index 8e3419b62a..7925ac2f49 100644 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityTracker.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityTracker.java @@ -2,9 +2,7 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; -import android.support.v7.widget.RecyclerView.LayoutManager; import android.support.v7.widget.RecyclerView.OnChildAttachStateChangeListener; import android.support.v7.widget.RecyclerView.OnScrollListener; import android.support.v7.widget.RecyclerView.ViewHolder; @@ -26,9 +24,6 @@ class EpoxyVisibilityTracker { @Nullable private RecyclerView attachedRecyclerView = null; - @Nullable - private LinearLayoutManager attachedLinearLayoutManager = null; - /** * Attach the tracker. * @@ -51,28 +46,13 @@ void detach(@NonNull EpoxyRecyclerView recyclerView) { recyclerView.removeOnLayoutChangeListener(this.listener); recyclerView.removeOnChildAttachStateChangeListener(this.listener); attachedRecyclerView = null; - attachedLinearLayoutManager = null; - } - - @Nullable - private LinearLayoutManager getLinearLayoutManager() { - if (attachedLinearLayoutManager == null && attachedRecyclerView != null) { - final LayoutManager lm = attachedRecyclerView.getLayoutManager(); - if (lm instanceof LinearLayoutManager) { - attachedLinearLayoutManager = (LinearLayoutManager) lm; - } else { - throw new IllegalStateException("setVisibilityTrackingEnabled(true) require to have a " - + "LinearLayoutManager, found " + lm.getClass().getName() + "."); - } - } - return attachedLinearLayoutManager; } private void processChildren() { - final LinearLayoutManager llm = getLinearLayoutManager(); - if (llm != null) { - for (int i = 0; i < llm.getChildCount(); i++) { - final View child = llm.getChildAt(i); + final RecyclerView recyclerView = attachedRecyclerView; + if (recyclerView != null) { + for (int i = 0; i < recyclerView.getChildCount(); i++) { + final View child = recyclerView.getChildAt(i); if (child != null) { processChild(child); } @@ -85,13 +65,13 @@ private void processChild(@NonNull View child) { } private void processChild(@NonNull View child, boolean detachEvent) { - final LinearLayoutManager llm = getLinearLayoutManager(); - if (attachedRecyclerView != null && llm != null) { - attachedRecyclerView.getChildViewHolder(child); - final ViewHolder holder = attachedRecyclerView.getChildViewHolder(child); + final RecyclerView recyclerView = attachedRecyclerView; + if (recyclerView != null) { + recyclerView.getChildViewHolder(child); + final ViewHolder holder = recyclerView.getChildViewHolder(child); if (holder instanceof EpoxyViewHolder) { - processVisibilityEvents(attachedRecyclerView, (EpoxyViewHolder) holder, - llm.getOrientation(), detachEvent); + processVisibilityEvents(recyclerView, (EpoxyViewHolder) holder, + recyclerView.getLayoutManager().canScrollVertically(), detachEvent); } } } @@ -99,7 +79,7 @@ private void processChild(@NonNull View child, boolean detachEvent) { private void processVisibilityEvents( @NonNull RecyclerView recyclerView, @NonNull EpoxyViewHolder epoxyHolder, - int orientation, boolean detachEvent + boolean vertical, boolean detachEvent ) { if (epoxyHolder.getAdapterPosition() == RecyclerView.NO_POSITION) { return; @@ -119,7 +99,7 @@ private void processVisibilityEvents( vi.reset(epoxyHolder.getAdapterPosition()); } - if (vi.update(itemView, recyclerView, orientation)) { + if (vi.update(itemView, recyclerView, vertical)) { // View is measured, process events vi.handleVisible(epoxyHolder); vi.handleInvisible(epoxyHolder, detachEvent); From c3f5e2ea4d77590ef6e5c063f1cf035cdab2b62b Mon Sep 17 00:00:00 2001 From: Emmanuel Boudrant Date: Tue, 9 Oct 2018 23:48:12 -0700 Subject: [PATCH 16/38] Remove dependency to EpoxyRecyclerView. Make visibility tracker public. --- .../com/airbnb/epoxy/EpoxyRecyclerView.java | 39 ------------------- .../airbnb/epoxy/EpoxyVisibilityTracker.java | 12 +++--- .../airbnb/epoxy/kotlinsample/MainActivity.kt | 6 ++- 3 files changed, 11 insertions(+), 46 deletions(-) diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyRecyclerView.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyRecyclerView.java index 29224e22c0..215946354e 100644 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyRecyclerView.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyRecyclerView.java @@ -78,11 +78,6 @@ public class EpoxyRecyclerView extends RecyclerView { private EpoxyController epoxyController; - private boolean visibilityTrackingEnabled = false; - - @NonNull - private final EpoxyVisibilityTracker epoxyVisibilityTracker = new EpoxyVisibilityTracker(); - /** * The adapter that was removed because the RecyclerView was detached from the window. We save it * so we can reattach it if the RecyclerView is reattached to window. This allows us to @@ -235,40 +230,6 @@ protected RecycledViewPool createViewPool() { return new UnboundedViewPool(); } - /** - * Enable visibility event tracking : - *

- * - Visible Event: this event is triggered when at least one pixel of the Component is visible. - *

- * - Invisible Event: this event is triggered when the Component no longer has any pixels on the - * screen. - *

- * - Focused Visible Event: this event is triggered when either the Component occupies at least - * half of the viewport, or, if the Component is smaller than half the viewport, when it is fully - * visible. - *

- * - Unfocused Visible Event: this event is triggered when the Component is no longer focused, - * i.e. it is not fully visible and does not occupy at least half the viewport. - *

- * - Full Impression Visible Event: this event is triggered when the entire Component has passed - * through the viewport at some point. - *

- * - VisibilityChangedEvent: this event is triggered when the visibility of the Component on the - * screen changes. - * - * By default visibility event tracking is not enabled. - */ - public void setVisibilityTrackingEnabled(boolean enabled) { - if (visibilityTrackingEnabled != enabled) { - visibilityTrackingEnabled = enabled; - if (visibilityTrackingEnabled) { - epoxyVisibilityTracker.attach(this); - } else { - epoxyVisibilityTracker.detach(this); - } - } - } - /** * To maximize view recycling by default we share the same view pool across all {@link * EpoxyRecyclerView} instances in the same Activity. This behavior can be disabled by returning diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityTracker.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityTracker.java index 7925ac2f49..9831a103cc 100644 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityTracker.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityTracker.java @@ -11,9 +11,9 @@ import android.view.View.OnLayoutChangeListener; /** - * Helper class to handle visibility event from an {@link com.airbnb.epoxy.EpoxyRecyclerView}. + * Helper class to handle visibility event from a {@link android.support.v7.widget.RecyclerView}. */ -class EpoxyVisibilityTracker { +public class EpoxyVisibilityTracker { /** Maintain visibility item indexed by view id (identity hashcode) */ private final SparseArray visibilityIdToItemMap = new SparseArray<>(); @@ -27,9 +27,9 @@ class EpoxyVisibilityTracker { /** * Attach the tracker. * - * @param recyclerView The EpoxyRecyclerView. + * @param recyclerView The RecyclerView. */ - void attach(@NonNull EpoxyRecyclerView recyclerView) { + public void attach(@NonNull RecyclerView recyclerView) { attachedRecyclerView = recyclerView; recyclerView.addOnScrollListener(this.listener); recyclerView.addOnLayoutChangeListener(this.listener); @@ -39,9 +39,9 @@ void attach(@NonNull EpoxyRecyclerView recyclerView) { /** * Detach the tracker * - * @param recyclerView The EpoxyRecyclerView. + * @param recyclerView The RecyclerView. */ - void detach(@NonNull EpoxyRecyclerView recyclerView) { + public void detach(@NonNull RecyclerView recyclerView) { recyclerView.removeOnScrollListener(this.listener); recyclerView.removeOnLayoutChangeListener(this.listener); recyclerView.removeOnChildAttachStateChangeListener(this.listener); diff --git a/kotlinsample/src/main/java/com/airbnb/epoxy/kotlinsample/MainActivity.kt b/kotlinsample/src/main/java/com/airbnb/epoxy/kotlinsample/MainActivity.kt index 862af53e66..3e469ed47c 100644 --- a/kotlinsample/src/main/java/com/airbnb/epoxy/kotlinsample/MainActivity.kt +++ b/kotlinsample/src/main/java/com/airbnb/epoxy/kotlinsample/MainActivity.kt @@ -7,6 +7,7 @@ import android.util.Log import android.widget.Toast import com.airbnb.epoxy.EpoxyController import com.airbnb.epoxy.EpoxyRecyclerView +import com.airbnb.epoxy.EpoxyVisibilityTracker import com.airbnb.epoxy.OnModelVisibilityStateChangedListener import com.airbnb.epoxy.kotlinsample.models.ItemDataClass import com.airbnb.epoxy.kotlinsample.models.itemCustomView @@ -20,7 +21,10 @@ class MainActivity : AppCompatActivity() { setContentView(R.layout.activity) recyclerView = findViewById(R.id.recycler_view) - recyclerView.setVisibilityTrackingEnabled(true) + + // Attach the visibility tracker to the RecyclerView. This will enable visibility events. + val epoxyVisibilityTracker = EpoxyVisibilityTracker() + epoxyVisibilityTracker.attach(recyclerView) recyclerView.withModels { From b1bcc9f36fcb73266b0ce0fb1682e6972a174bb6 Mon Sep 17 00:00:00 2001 From: Emmanuel Boudrant Date: Wed, 10 Oct 2018 00:01:56 -0700 Subject: [PATCH 17/38] parameter names inverted --- .../main/java/com/airbnb/epoxy/EpoxyModelWithHolder.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModelWithHolder.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModelWithHolder.java index 5de19bec3b..28e37a08cf 100644 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModelWithHolder.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModelWithHolder.java @@ -48,11 +48,11 @@ public void visibilityStateChanged(@VisibilityState int visibilityState, @NonNul super.visibilityStateChanged(visibilityState, view); } - @Override - public void visibilityChanged(float visibleHeight, float visibleWidth, int percentVisibleHeight, - int percentVisibleWidth, @NonNull T view) { - super.visibilityChanged(visibleHeight, visibleWidth, percentVisibleHeight, percentVisibleWidth, + public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, + int visibleWidth, @NonNull T view) { + super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, view); } From 22d5126d89850ab7e795de540dce8f19bbd0a903 Mon Sep 17 00:00:00 2001 From: Emmanuel Boudrant Date: Wed, 10 Oct 2018 00:03:51 -0700 Subject: [PATCH 18/38] Add toto regarding nested list (carousel) --- .../src/main/java/com/airbnb/epoxy/EpoxyVisibilityTracker.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityTracker.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityTracker.java index 9831a103cc..232c7518d0 100644 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityTracker.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityTracker.java @@ -12,6 +12,8 @@ /** * Helper class to handle visibility event from a {@link android.support.v7.widget.RecyclerView}. + * + * TODO: The visibility event tracking is not working well with nested list (ex: carousel). */ public class EpoxyVisibilityTracker { From 38267bb4472a4ea52714de3d6554214fd6c6ccb3 Mon Sep 17 00:00:00 2001 From: Emmanuel Boudrant Date: Wed, 10 Oct 2018 08:03:32 -0700 Subject: [PATCH 19/38] visibility...() -> onVisibility...() --- .../src/main/java/com/airbnb/epoxy/EpoxyModel.java | 4 ++-- .../com/airbnb/epoxy/EpoxyModelWithHolder.java | 14 ++++++++------ .../java/com/airbnb/epoxy/EpoxyViewHolder.java | 4 ++-- .../test/resources/AllTypesModelViewModel_.java | 8 ++++---- .../src/test/resources/BaseModelViewModel_.java | 8 ++++---- .../test/resources/BasicModelWithAttribute_.java | 8 ++++---- .../resources/BasicModelWithFinalAttribute_.java | 8 ++++---- .../resources/CallbackPropModelViewModel_.java | 8 ++++---- ...ortedAttributeDifferentNameModelViewModel_.java | 8 ++++---- ...eSupportedAttributeSameNameModelViewModel_.java | 8 ++++---- ...ropSingleSupportedAttributeModelViewModel_.java | 8 ++++---- .../test/resources/ListSubtypeModelViewModel_.java | 8 ++++---- .../test/resources/StyleableModelViewModel_.java | 8 ++++---- .../test/resources/TextPropModelViewModel_.java | 8 ++++---- .../java/com/airbnb/epoxy/GeneratedModelWriter.kt | 8 ++++---- .../test/resources/AbstractModelWithHolder_.java | 8 ++++---- .../AutoLayoutModelViewMatchParentModel_.java | 8 ++++---- .../test/resources/AutoLayoutModelViewModel_.java | 8 ++++---- .../BaseModelFromPackageConfigViewModel_.java | 8 ++++---- .../BaseModelOverridesPackageConfigViewModel_.java | 8 ++++---- .../src/test/resources/BaseModelViewModel_.java | 8 ++++---- .../BaseModelViewWithSuperDiffBindModel_.java | 8 ++++---- .../BaseModelWithAttributeViewModel_.java | 8 ++++---- .../test/resources/BasicModelWithAttribute_.java | 8 ++++---- .../CustomPackageLayoutPatternViewModel_.java | 8 ++++---- ...BindingModelWithAllFieldTypesNoValidation_.java | 8 ++++---- .../DataBindingModelWithAllFieldTypes_.java | 8 ++++---- .../DefaultPackageLayoutPatternViewModel_.java | 8 ++++---- .../src/test/resources/DoNotHashViewModel_.java | 8 ++++---- .../resources/EpoxyModelGroupWithAnnotations_.java | 8 ++++---- ...aultLayoutMethodNextParentLayout$NoLayout_.java | 8 ++++---- ...ayoutMethodNextParentLayout$StillNoLayout_.java | 8 ++++---- ...ltLayoutMethodNextParentLayout$WithLayout_.java | 8 ++++---- ...eDefaultLayoutMethodParentLayout$NoLayout_.java | 8 ++++---- ...efaultLayoutMethodParentLayout$WithLayout_.java | 8 ++++---- .../resources/GenerateDefaultLayoutMethod_.java | 8 ++++---- .../resources/GeneratedModelSuffixViewSuffix_.java | 8 ++++---- .../test/resources/GridSpanCountViewModel_.java | 8 ++++---- .../resources/IgnoreRequireHashCodeViewModel_.java | 9 +++++---- .../test/resources/LayoutOverloadsViewModel_.java | 8 ++++---- .../src/test/resources/ModelDoNotHash_.java | 8 ++++---- .../test/resources/ModelDoNotUseInToString_.java | 8 ++++---- .../test/resources/ModelForRProcessingTest_.java | 8 ++++---- .../ModelForTestingDuplicateRValues_.java | 8 ++++---- .../src/test/resources/ModelNoValidation_.java | 8 ++++---- .../ModelReturningClassTypeWithVarargs_.java | 8 ++++---- .../test/resources/ModelReturningClassType_.java | 8 ++++---- .../ModelViewExtendingSuperClassModel_.java | 8 ++++---- .../test/resources/ModelViewSuperClassModel_.java | 8 ++++---- .../test/resources/ModelViewWithParisModel_.java | 8 ++++---- .../ModelWithAbstractClassAndAnnotation_.java | 8 ++++---- .../test/resources/ModelWithAllFieldTypes_.java | 8 ++++---- .../resources/ModelWithAllPrivateFieldTypes_.java | 8 ++++---- ...ModelWithAnnotatedClassAndSuperAttributes_.java | 8 ++++---- ...ModelWithAnnotatedClassAndSuperAttributes_.java | 8 ++++---- .../test/resources/ModelWithAnnotatedClass_.java | 8 ++++---- .../src/test/resources/ModelWithAnnotation_.java | 8 ++++---- .../src/test/resources/ModelWithConstructors_.java | 8 ++++---- .../ModelWithDataBindingBindingModel_.java | 8 ++++---- ...thDataBindingWithoutDonothashBindingModel_.java | 8 ++++---- .../test/resources/ModelWithFieldAnnotation_.java | 8 ++++---- .../src/test/resources/ModelWithFinalField_.java | 8 ++++---- .../src/test/resources/ModelWithIntDef_.java | 8 ++++---- ...teFieldWithSameAsFieldGetterAndSetterName_.java | 8 ++++---- .../ModelWithPrivateViewClickListener_.java | 8 ++++---- ...perAttributes$SubModelWithSuperAttributes_.java | 8 ++++---- .../test/resources/ModelWithSuperAttributes_.java | 8 ++++---- .../src/test/resources/ModelWithSuper_.java | 8 ++++---- .../src/test/resources/ModelWithType_.java | 8 ++++---- .../resources/ModelWithVarargsConstructors_.java | 8 ++++---- .../resources/ModelWithViewClickListener_.java | 8 ++++---- .../resources/ModelWithViewLongClickListener_.java | 8 ++++---- .../src/test/resources/ModelWithoutHash_.java | 8 ++++---- .../src/test/resources/ModelWithoutSetter_.java | 8 ++++---- .../test/resources/NullOnRecycleViewModel_.java | 8 ++++---- .../test/resources/OnViewRecycledViewModel_.java | 8 ++++---- .../src/test/resources/PropDefaultsViewModel_.java | 8 ++++---- .../src/test/resources/PropGroupsViewModel_.java | 8 ++++---- ...LayoutInViewModelAnnotationWorksViewModel_.java | 8 ++++---- .../src/test/resources/SavedStateViewModel_.java | 8 ++++---- .../resources/TestAfterBindPropsViewModel_.java | 8 ++++---- .../test/resources/TestCallbackPropViewModel_.java | 8 ++++---- .../TestFieldPropCallbackPropViewModel_.java | 8 ++++---- .../resources/TestFieldPropChildViewModel_.java | 8 ++++---- .../TestFieldPropDoNotHashOptionViewModel_.java | 8 ++++---- ...ropGenerateStringOverloadsOptionViewModel_.java | 8 ++++---- ...dPropIgnoreRequireHashCodeOptionViewModel_.java | 8 ++++---- .../TestFieldPropModelPropViewModel_.java | 9 +++++---- ...TestFieldPropNullOnRecycleOptionViewModel_.java | 8 ++++---- .../resources/TestFieldPropTextPropViewModel_.java | 9 +++++---- .../test/resources/TestManyTypesViewModel_.java | 8 ++++---- .../TestNullStringOverloadsViewModel_.java | 8 ++++---- .../resources/TestStringOverloadsViewModel_.java | 8 ++++---- .../src/test/resources/TestTextPropViewModel_.java | 8 ++++---- .../test/resources/TextPropDefaultViewModel_.java | 8 ++++---- 95 files changed, 383 insertions(+), 378 deletions(-) diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModel.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModel.java index 9b352b5589..b4f0fabd7e 100755 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModel.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModel.java @@ -157,10 +157,10 @@ public void bind(@NonNull T view, @NonNull EpoxyModel previouslyBoundModel) { public void unbind(@NonNull T view) { } - public void visibilityStateChanged(@VisibilityState int visibilityState, @NonNull T view) { + public void onVisibilityStateChanged(@VisibilityState int visibilityState, @NonNull T view) { } - public void visibilityChanged( + public void onVisibilityChanged( @FloatRange(from = 0.0f, to = 100.0f) float percentVisibleHeight, @FloatRange(from = 0.0f, to = 100.0f) float percentVisibleWidth, int visibleHeight, diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModelWithHolder.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModelWithHolder.java index 28e37a08cf..fe46eb210a 100644 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModelWithHolder.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModelWithHolder.java @@ -44,15 +44,17 @@ public void unbind(@NonNull T holder) { @Override - public void visibilityStateChanged(@VisibilityState int visibilityState, @NonNull T view) { - super.visibilityStateChanged(visibilityState, view); + public void onVisibilityStateChanged(@VisibilityState int visibilityState, @NonNull T view) { + super.onVisibilityStateChanged(visibilityState, view); } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, - int visibleHeight, - int visibleWidth, @NonNull T view) { - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, + @NonNull T view) { + super.onVisibilityChanged( + percentVisibleHeight, percentVisibleWidth, + visibleHeight, visibleWidth, view); } diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyViewHolder.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyViewHolder.java index dc67598bf5..29cfc77c1c 100755 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyViewHolder.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyViewHolder.java @@ -87,7 +87,7 @@ public void unbind() { public void visibilityStateChanged(@VisibilityState int visibilityState) { assertBound(); // noinspection unchecked - epoxyModel.visibilityStateChanged(visibilityState, objectToBind()); + epoxyModel.onVisibilityStateChanged(visibilityState, objectToBind()); } public void visibilityChanged( @@ -98,7 +98,7 @@ public void visibilityChanged( ) { assertBound(); // noinspection unchecked - epoxyModel.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, + epoxyModel.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, objectToBind()); } diff --git a/epoxy-modelfactory/src/test/resources/AllTypesModelViewModel_.java b/epoxy-modelfactory/src/test/resources/AllTypesModelViewModel_.java index 17c092318a..6e6db08c8f 100644 --- a/epoxy-modelfactory/src/test/resources/AllTypesModelViewModel_.java +++ b/epoxy-modelfactory/src/test/resources/AllTypesModelViewModel_.java @@ -278,11 +278,11 @@ public AllTypesModelViewModel_ onUnbind( } @Override - public void visibilityStateChanged(int visibilityState, final AllTypesModelView object) { + public void onVisibilityStateChanged(int visibilityState, final AllTypesModelView object) { if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); } - super.visibilityStateChanged(visibilityState, object); + super.onVisibilityStateChanged(visibilityState, object); } /** @@ -300,12 +300,12 @@ public AllTypesModelViewModel_ onVisibilityStateChanged( } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, final AllTypesModelView object) { if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); } - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); } /** diff --git a/epoxy-modelfactory/src/test/resources/BaseModelViewModel_.java b/epoxy-modelfactory/src/test/resources/BaseModelViewModel_.java index 756c34b8e8..f57b45d774 100644 --- a/epoxy-modelfactory/src/test/resources/BaseModelViewModel_.java +++ b/epoxy-modelfactory/src/test/resources/BaseModelViewModel_.java @@ -110,11 +110,11 @@ public BaseModelViewModel_ onUnbind( } @Override - public void visibilityStateChanged(int visibilityState, final BaseModelView object) { + public void onVisibilityStateChanged(int visibilityState, final BaseModelView object) { if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); } - super.visibilityStateChanged(visibilityState, object); + super.onVisibilityStateChanged(visibilityState, object); } /** @@ -132,12 +132,12 @@ public BaseModelViewModel_ onVisibilityStateChanged( } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, final BaseModelView object) { if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); } - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); } /** diff --git a/epoxy-modelfactory/src/test/resources/BasicModelWithAttribute_.java b/epoxy-modelfactory/src/test/resources/BasicModelWithAttribute_.java index b56749ba50..8bff1410f3 100755 --- a/epoxy-modelfactory/src/test/resources/BasicModelWithAttribute_.java +++ b/epoxy-modelfactory/src/test/resources/BasicModelWithAttribute_.java @@ -79,11 +79,11 @@ public BasicModelWithAttribute_ onUnbind( } @Override - public void visibilityStateChanged(int visibilityState, final Object object) { + public void onVisibilityStateChanged(int visibilityState, final Object object) { if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); } - super.visibilityStateChanged(visibilityState, object); + super.onVisibilityStateChanged(visibilityState, object); } /** @@ -101,12 +101,12 @@ public BasicModelWithAttribute_ onVisibilityStateChanged( } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, final Object object) { if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); } - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); } /** diff --git a/epoxy-modelfactory/src/test/resources/BasicModelWithFinalAttribute_.java b/epoxy-modelfactory/src/test/resources/BasicModelWithFinalAttribute_.java index cf1d1fbfb9..0a80aaa696 100755 --- a/epoxy-modelfactory/src/test/resources/BasicModelWithFinalAttribute_.java +++ b/epoxy-modelfactory/src/test/resources/BasicModelWithFinalAttribute_.java @@ -79,11 +79,11 @@ public BasicModelWithFinalAttribute_ onUnbind( } @Override - public void visibilityStateChanged(int visibilityState, final Object object) { + public void onVisibilityStateChanged(int visibilityState, final Object object) { if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); } - super.visibilityStateChanged(visibilityState, object); + super.onVisibilityStateChanged(visibilityState, object); } /** @@ -101,12 +101,12 @@ public BasicModelWithFinalAttribute_ onVisibilityStateChanged( } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, final Object object) { if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); } - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); } /** diff --git a/epoxy-modelfactory/src/test/resources/CallbackPropModelViewModel_.java b/epoxy-modelfactory/src/test/resources/CallbackPropModelViewModel_.java index 5755c06911..b23599f46c 100644 --- a/epoxy-modelfactory/src/test/resources/CallbackPropModelViewModel_.java +++ b/epoxy-modelfactory/src/test/resources/CallbackPropModelViewModel_.java @@ -106,11 +106,11 @@ public CallbackPropModelViewModel_ onUnbind( } @Override - public void visibilityStateChanged(int visibilityState, final CallbackPropModelView object) { + public void onVisibilityStateChanged(int visibilityState, final CallbackPropModelView object) { if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); } - super.visibilityStateChanged(visibilityState, object); + super.onVisibilityStateChanged(visibilityState, object); } /** @@ -128,12 +128,12 @@ public CallbackPropModelViewModel_ onVisibilityStateChanged( } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, final CallbackPropModelView object) { if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); } - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); } /** diff --git a/epoxy-modelfactory/src/test/resources/GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_.java b/epoxy-modelfactory/src/test/resources/GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_.java index fb373ddbb6..8a5087c2f1 100644 --- a/epoxy-modelfactory/src/test/resources/GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_.java +++ b/epoxy-modelfactory/src/test/resources/GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_.java @@ -131,12 +131,12 @@ public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ onUnbind( } @Override - public void visibilityStateChanged(int visibilityState, + public void onVisibilityStateChanged(int visibilityState, final GroupPropMultipleSupportedAttributeDifferentNameModelView object) { if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); } - super.visibilityStateChanged(visibilityState, object); + super.onVisibilityStateChanged(visibilityState, object); } /** @@ -154,13 +154,13 @@ public GroupPropMultipleSupportedAttributeDifferentNameModelViewModel_ onVisibil } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, final GroupPropMultipleSupportedAttributeDifferentNameModelView object) { if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); } - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); } /** diff --git a/epoxy-modelfactory/src/test/resources/GroupPropMultipleSupportedAttributeSameNameModelViewModel_.java b/epoxy-modelfactory/src/test/resources/GroupPropMultipleSupportedAttributeSameNameModelViewModel_.java index 252ea186cd..2b3f6f1206 100644 --- a/epoxy-modelfactory/src/test/resources/GroupPropMultipleSupportedAttributeSameNameModelViewModel_.java +++ b/epoxy-modelfactory/src/test/resources/GroupPropMultipleSupportedAttributeSameNameModelViewModel_.java @@ -131,12 +131,12 @@ public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ onUnbind( } @Override - public void visibilityStateChanged(int visibilityState, + public void onVisibilityStateChanged(int visibilityState, final GroupPropMultipleSupportedAttributeSameNameModelView object) { if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); } - super.visibilityStateChanged(visibilityState, object); + super.onVisibilityStateChanged(visibilityState, object); } /** @@ -154,13 +154,13 @@ public GroupPropMultipleSupportedAttributeSameNameModelViewModel_ onVisibilitySt } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, final GroupPropMultipleSupportedAttributeSameNameModelView object) { if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); } - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); } /** diff --git a/epoxy-modelfactory/src/test/resources/GroupPropSingleSupportedAttributeModelViewModel_.java b/epoxy-modelfactory/src/test/resources/GroupPropSingleSupportedAttributeModelViewModel_.java index 5db9d8da43..34d68fe4d7 100644 --- a/epoxy-modelfactory/src/test/resources/GroupPropSingleSupportedAttributeModelViewModel_.java +++ b/epoxy-modelfactory/src/test/resources/GroupPropSingleSupportedAttributeModelViewModel_.java @@ -129,12 +129,12 @@ public GroupPropSingleSupportedAttributeModelViewModel_ onUnbind( } @Override - public void visibilityStateChanged(int visibilityState, + public void onVisibilityStateChanged(int visibilityState, final GroupPropSingleSupportedAttributeModelView object) { if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); } - super.visibilityStateChanged(visibilityState, object); + super.onVisibilityStateChanged(visibilityState, object); } /** @@ -152,13 +152,13 @@ public GroupPropSingleSupportedAttributeModelViewModel_ onVisibilityStateChanged } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, final GroupPropSingleSupportedAttributeModelView object) { if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); } - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); } /** diff --git a/epoxy-modelfactory/src/test/resources/ListSubtypeModelViewModel_.java b/epoxy-modelfactory/src/test/resources/ListSubtypeModelViewModel_.java index a4ab17ba74..5845177fac 100644 --- a/epoxy-modelfactory/src/test/resources/ListSubtypeModelViewModel_.java +++ b/epoxy-modelfactory/src/test/resources/ListSubtypeModelViewModel_.java @@ -111,11 +111,11 @@ public ListSubtypeModelViewModel_ onUnbind( } @Override - public void visibilityStateChanged(int visibilityState, final ListSubtypeModelView object) { + public void onVisibilityStateChanged(int visibilityState, final ListSubtypeModelView object) { if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); } - super.visibilityStateChanged(visibilityState, object); + super.onVisibilityStateChanged(visibilityState, object); } /** @@ -133,12 +133,12 @@ public ListSubtypeModelViewModel_ onVisibilityStateChanged( } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, final ListSubtypeModelView object) { if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); } - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); } /** diff --git a/epoxy-modelfactory/src/test/resources/StyleableModelViewModel_.java b/epoxy-modelfactory/src/test/resources/StyleableModelViewModel_.java index e67b27660c..f0bcce300e 100644 --- a/epoxy-modelfactory/src/test/resources/StyleableModelViewModel_.java +++ b/epoxy-modelfactory/src/test/resources/StyleableModelViewModel_.java @@ -164,11 +164,11 @@ public StyleableModelViewModel_ onUnbind( } @Override - public void visibilityStateChanged(int visibilityState, final StyleableModelView object) { + public void onVisibilityStateChanged(int visibilityState, final StyleableModelView object) { if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); } - super.visibilityStateChanged(visibilityState, object); + super.onVisibilityStateChanged(visibilityState, object); } /** @@ -186,12 +186,12 @@ public StyleableModelViewModel_ onVisibilityStateChanged( } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, final StyleableModelView object) { if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); } - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); } /** diff --git a/epoxy-modelfactory/src/test/resources/TextPropModelViewModel_.java b/epoxy-modelfactory/src/test/resources/TextPropModelViewModel_.java index a3cc4c3599..8a253bcb7f 100644 --- a/epoxy-modelfactory/src/test/resources/TextPropModelViewModel_.java +++ b/epoxy-modelfactory/src/test/resources/TextPropModelViewModel_.java @@ -112,11 +112,11 @@ public TextPropModelViewModel_ onUnbind( } @Override - public void visibilityStateChanged(int visibilityState, final TextPropModelView object) { + public void onVisibilityStateChanged(int visibilityState, final TextPropModelView object) { if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); } - super.visibilityStateChanged(visibilityState, object); + super.onVisibilityStateChanged(visibilityState, object); } /** @@ -134,12 +134,12 @@ public TextPropModelViewModel_ onVisibilityStateChanged( } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, final TextPropModelView object) { if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); } - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); } /** diff --git a/epoxy-processor/src/main/java/com/airbnb/epoxy/GeneratedModelWriter.kt b/epoxy-processor/src/main/java/com/airbnb/epoxy/GeneratedModelWriter.kt index 5d8abf3031..77085c05c6 100644 --- a/epoxy-processor/src/main/java/com/airbnb/epoxy/GeneratedModelWriter.kt +++ b/epoxy-processor/src/main/java/com/airbnb/epoxy/GeneratedModelWriter.kt @@ -701,7 +701,7 @@ internal class GeneratedModelWriter( private fun buildVisibilityStateChangedMethod( visibilityStateParam: ParameterSpec - ) = buildMethod("visibilityStateChanged") { + ) = buildMethod("onVisibilityStateChanged") { addAnnotation(Override::class.java) addModifiers(PUBLIC) addParameter(TypeName.INT, "visibilityState") @@ -717,13 +717,13 @@ internal class GeneratedModelWriter( builderHooks?.addToVisibilityStateChangedMethod(this, visibilityStateParam.name) addStatement( - "super.visibilityStateChanged(\$L, \$L)", "visibilityState", visibilityStateParam.name + "super.onVisibilityStateChanged(\$L, \$L)", "visibilityState", visibilityStateParam.name ) } private fun buildVisibilityChangedMethod( visibilityStateParam: ParameterSpec - ) = buildMethod("visibilityChanged") { + ) = buildMethod("onVisibilityChanged") { addAnnotation(Override::class.java) addModifiers(PUBLIC) addParameter(TypeName.FLOAT, "percentVisibleHeight") @@ -743,7 +743,7 @@ internal class GeneratedModelWriter( builderHooks?.addToVisibilityChangedMethod(this, visibilityStateParam.name) addStatement( - "super.visibilityChanged(\$L, \$L, \$L, \$L, \$L)", "percentVisibleHeight", + "super.onVisibilityChanged(\$L, \$L, \$L, \$L, \$L)", "percentVisibleHeight", "percentVisibleWidth", "visibleHeight", "visibleWidth", visibilityStateParam.name ) } diff --git a/epoxy-processortest/src/test/resources/AbstractModelWithHolder_.java b/epoxy-processortest/src/test/resources/AbstractModelWithHolder_.java index 2c6b6bd95b..6a4b6b9405 100755 --- a/epoxy-processortest/src/test/resources/AbstractModelWithHolder_.java +++ b/epoxy-processortest/src/test/resources/AbstractModelWithHolder_.java @@ -80,12 +80,12 @@ public AbstractModelWithHolder_ onUnbind( } @Override - public void visibilityStateChanged(int visibilityState, + public void onVisibilityStateChanged(int visibilityState, final AbstractModelWithHolder.Holder object) { if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); } - super.visibilityStateChanged(visibilityState, object); + super.onVisibilityStateChanged(visibilityState, object); } /** @@ -103,12 +103,12 @@ public AbstractModelWithHolder_ onVisibilityStateChanged( } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, final AbstractModelWithHolder.Holder object) { if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); } - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); } /** diff --git a/epoxy-processortest/src/test/resources/AutoLayoutModelViewMatchParentModel_.java b/epoxy-processortest/src/test/resources/AutoLayoutModelViewMatchParentModel_.java index 4b1b77ccf6..8e8e432d1b 100644 --- a/epoxy-processortest/src/test/resources/AutoLayoutModelViewMatchParentModel_.java +++ b/epoxy-processortest/src/test/resources/AutoLayoutModelViewMatchParentModel_.java @@ -117,12 +117,12 @@ public AutoLayoutModelViewMatchParentModel_ onUnbind( } @Override - public void visibilityStateChanged(int visibilityState, + public void onVisibilityStateChanged(int visibilityState, final AutoLayoutModelViewMatchParent object) { if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); } - super.visibilityStateChanged(visibilityState, object); + super.onVisibilityStateChanged(visibilityState, object); } /** @@ -140,12 +140,12 @@ public AutoLayoutModelViewMatchParentModel_ onVisibilityStateChanged( } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, final AutoLayoutModelViewMatchParent object) { if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); } - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); } /** diff --git a/epoxy-processortest/src/test/resources/AutoLayoutModelViewModel_.java b/epoxy-processortest/src/test/resources/AutoLayoutModelViewModel_.java index 4e2f1340f6..af9113b15a 100644 --- a/epoxy-processortest/src/test/resources/AutoLayoutModelViewModel_.java +++ b/epoxy-processortest/src/test/resources/AutoLayoutModelViewModel_.java @@ -117,11 +117,11 @@ public AutoLayoutModelViewModel_ onUnbind( } @Override - public void visibilityStateChanged(int visibilityState, final AutoLayoutModelView object) { + public void onVisibilityStateChanged(int visibilityState, final AutoLayoutModelView object) { if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); } - super.visibilityStateChanged(visibilityState, object); + super.onVisibilityStateChanged(visibilityState, object); } /** @@ -139,12 +139,12 @@ public AutoLayoutModelViewModel_ onVisibilityStateChanged( } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, final AutoLayoutModelView object) { if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); } - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); } /** diff --git a/epoxy-processortest/src/test/resources/BaseModelFromPackageConfigViewModel_.java b/epoxy-processortest/src/test/resources/BaseModelFromPackageConfigViewModel_.java index a240efc643..0ef58cef7d 100644 --- a/epoxy-processortest/src/test/resources/BaseModelFromPackageConfigViewModel_.java +++ b/epoxy-processortest/src/test/resources/BaseModelFromPackageConfigViewModel_.java @@ -114,11 +114,11 @@ public BaseModelViewModel_ onUnbind( } @Override - public void visibilityStateChanged(int visibilityState, final BaseModelView object) { + public void onVisibilityStateChanged(int visibilityState, final BaseModelView object) { if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); } - super.visibilityStateChanged(visibilityState, object); + super.onVisibilityStateChanged(visibilityState, object); } /** @@ -136,12 +136,12 @@ public BaseModelViewModel_ onVisibilityStateChanged( } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, final BaseModelView object) { if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); } - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); } /** diff --git a/epoxy-processortest/src/test/resources/BaseModelOverridesPackageConfigViewModel_.java b/epoxy-processortest/src/test/resources/BaseModelOverridesPackageConfigViewModel_.java index 22f033a4e1..8314e7ac46 100644 --- a/epoxy-processortest/src/test/resources/BaseModelOverridesPackageConfigViewModel_.java +++ b/epoxy-processortest/src/test/resources/BaseModelOverridesPackageConfigViewModel_.java @@ -110,11 +110,11 @@ public BaseModelViewModel_ onUnbind( } @Override - public void visibilityStateChanged(int visibilityState, final BaseModelView object) { + public void onVisibilityStateChanged(int visibilityState, final BaseModelView object) { if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); } - super.visibilityStateChanged(visibilityState, object); + super.onVisibilityStateChanged(visibilityState, object); } /** @@ -132,12 +132,12 @@ public BaseModelViewModel_ onVisibilityStateChanged( } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, final BaseModelView object) { if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); } - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); } /** diff --git a/epoxy-processortest/src/test/resources/BaseModelViewModel_.java b/epoxy-processortest/src/test/resources/BaseModelViewModel_.java index 83215195f2..ef53c09da3 100644 --- a/epoxy-processortest/src/test/resources/BaseModelViewModel_.java +++ b/epoxy-processortest/src/test/resources/BaseModelViewModel_.java @@ -114,11 +114,11 @@ public BaseModelViewModel_ onUnbind( } @Override - public void visibilityStateChanged(int visibilityState, final BaseModelView object) { + public void onVisibilityStateChanged(int visibilityState, final BaseModelView object) { if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); } - super.visibilityStateChanged(visibilityState, object); + super.onVisibilityStateChanged(visibilityState, object); } /** @@ -136,12 +136,12 @@ public BaseModelViewModel_ onVisibilityStateChanged( } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, final BaseModelView object) { if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); } - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); } /** diff --git a/epoxy-processortest/src/test/resources/BaseModelViewWithSuperDiffBindModel_.java b/epoxy-processortest/src/test/resources/BaseModelViewWithSuperDiffBindModel_.java index b1386cf684..63e0ce354f 100644 --- a/epoxy-processortest/src/test/resources/BaseModelViewWithSuperDiffBindModel_.java +++ b/epoxy-processortest/src/test/resources/BaseModelViewWithSuperDiffBindModel_.java @@ -114,11 +114,11 @@ public BaseModelViewModel_ onUnbind( } @Override - public void visibilityStateChanged(int visibilityState, final BaseModelView object) { + public void onVisibilityStateChanged(int visibilityState, final BaseModelView object) { if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); } - super.visibilityStateChanged(visibilityState, object); + super.onVisibilityStateChanged(visibilityState, object); } /** @@ -136,12 +136,12 @@ public BaseModelViewModel_ onVisibilityStateChanged( } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, final BaseModelView object) { if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); } - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); } /** diff --git a/epoxy-processortest/src/test/resources/BaseModelWithAttributeViewModel_.java b/epoxy-processortest/src/test/resources/BaseModelWithAttributeViewModel_.java index 06bc894050..2057e0b7fb 100644 --- a/epoxy-processortest/src/test/resources/BaseModelWithAttributeViewModel_.java +++ b/epoxy-processortest/src/test/resources/BaseModelWithAttributeViewModel_.java @@ -114,11 +114,11 @@ public BaseModelViewModel_ onUnbind( } @Override - public void visibilityStateChanged(int visibilityState, final BaseModelView object) { + public void onVisibilityStateChanged(int visibilityState, final BaseModelView object) { if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); } - super.visibilityStateChanged(visibilityState, object); + super.onVisibilityStateChanged(visibilityState, object); } /** @@ -136,12 +136,12 @@ public BaseModelViewModel_ onVisibilityStateChanged( } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, final BaseModelView object) { if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); } - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); } /** diff --git a/epoxy-processortest/src/test/resources/BasicModelWithAttribute_.java b/epoxy-processortest/src/test/resources/BasicModelWithAttribute_.java index 376263f5b1..0026985a54 100755 --- a/epoxy-processortest/src/test/resources/BasicModelWithAttribute_.java +++ b/epoxy-processortest/src/test/resources/BasicModelWithAttribute_.java @@ -79,11 +79,11 @@ public BasicModelWithAttribute_ onUnbind( } @Override - public void visibilityStateChanged(int visibilityState, final Object object) { + public void onVisibilityStateChanged(int visibilityState, final Object object) { if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); } - super.visibilityStateChanged(visibilityState, object); + super.onVisibilityStateChanged(visibilityState, object); } /** @@ -101,12 +101,12 @@ public BasicModelWithAttribute_ onVisibilityStateChanged( } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, final Object object) { if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); } - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); } /** diff --git a/epoxy-processortest/src/test/resources/CustomPackageLayoutPatternViewModel_.java b/epoxy-processortest/src/test/resources/CustomPackageLayoutPatternViewModel_.java index c404040622..91a86ab3a1 100644 --- a/epoxy-processortest/src/test/resources/CustomPackageLayoutPatternViewModel_.java +++ b/epoxy-processortest/src/test/resources/CustomPackageLayoutPatternViewModel_.java @@ -94,12 +94,12 @@ public CustomPackageLayoutPatternViewModel_ onUnbind( } @Override - public void visibilityStateChanged(int visibilityState, + public void onVisibilityStateChanged(int visibilityState, final CustomPackageLayoutPatternView object) { if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); } - super.visibilityStateChanged(visibilityState, object); + super.onVisibilityStateChanged(visibilityState, object); } /** @@ -117,12 +117,12 @@ public CustomPackageLayoutPatternViewModel_ onVisibilityStateChanged( } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, final CustomPackageLayoutPatternView object) { if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); } - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); } /** diff --git a/epoxy-processortest/src/test/resources/DataBindingModelWithAllFieldTypesNoValidation_.java b/epoxy-processortest/src/test/resources/DataBindingModelWithAllFieldTypesNoValidation_.java index c6fa9145ae..35d5e6b0f7 100644 --- a/epoxy-processortest/src/test/resources/DataBindingModelWithAllFieldTypesNoValidation_.java +++ b/epoxy-processortest/src/test/resources/DataBindingModelWithAllFieldTypesNoValidation_.java @@ -83,12 +83,12 @@ public DataBindingModelWithAllFieldTypesNoValidation_ onUnbind( } @Override - public void visibilityStateChanged(int visibilityState, + public void onVisibilityStateChanged(int visibilityState, final DataBindingEpoxyModel.DataBindingHolder object) { if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); } - super.visibilityStateChanged(visibilityState, object); + super.onVisibilityStateChanged(visibilityState, object); } /** @@ -106,12 +106,12 @@ public DataBindingModelWithAllFieldTypesNoValidation_ onVisibilityStateChanged( } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, final DataBindingEpoxyModel.DataBindingHolder object) { if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); } - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); } /** diff --git a/epoxy-processortest/src/test/resources/DataBindingModelWithAllFieldTypes_.java b/epoxy-processortest/src/test/resources/DataBindingModelWithAllFieldTypes_.java index a2f6807df3..00f677d8dd 100644 --- a/epoxy-processortest/src/test/resources/DataBindingModelWithAllFieldTypes_.java +++ b/epoxy-processortest/src/test/resources/DataBindingModelWithAllFieldTypes_.java @@ -92,12 +92,12 @@ public DataBindingModelWithAllFieldTypes_ onUnbind( } @Override - public void visibilityStateChanged(int visibilityState, + public void onVisibilityStateChanged(int visibilityState, final DataBindingEpoxyModel.DataBindingHolder object) { if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); } - super.visibilityStateChanged(visibilityState, object); + super.onVisibilityStateChanged(visibilityState, object); } /** @@ -115,12 +115,12 @@ public DataBindingModelWithAllFieldTypes_ onVisibilityStateChanged( } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, final DataBindingEpoxyModel.DataBindingHolder object) { if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); } - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); } /** diff --git a/epoxy-processortest/src/test/resources/DefaultPackageLayoutPatternViewModel_.java b/epoxy-processortest/src/test/resources/DefaultPackageLayoutPatternViewModel_.java index 953ee1deb9..7053889001 100644 --- a/epoxy-processortest/src/test/resources/DefaultPackageLayoutPatternViewModel_.java +++ b/epoxy-processortest/src/test/resources/DefaultPackageLayoutPatternViewModel_.java @@ -94,12 +94,12 @@ public DefaultPackageLayoutPatternViewModel_ onUnbind( } @Override - public void visibilityStateChanged(int visibilityState, + public void onVisibilityStateChanged(int visibilityState, final DefaultPackageLayoutPatternView object) { if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); } - super.visibilityStateChanged(visibilityState, object); + super.onVisibilityStateChanged(visibilityState, object); } /** @@ -117,12 +117,12 @@ public DefaultPackageLayoutPatternViewModel_ onVisibilityStateChanged( } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, final DefaultPackageLayoutPatternView object) { if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); } - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); } /** diff --git a/epoxy-processortest/src/test/resources/DoNotHashViewModel_.java b/epoxy-processortest/src/test/resources/DoNotHashViewModel_.java index dc9d4653a2..9a2f002c0f 100644 --- a/epoxy-processortest/src/test/resources/DoNotHashViewModel_.java +++ b/epoxy-processortest/src/test/resources/DoNotHashViewModel_.java @@ -137,11 +137,11 @@ public DoNotHashViewModel_ onUnbind( } @Override - public void visibilityStateChanged(int visibilityState, final DoNotHashView object) { + public void onVisibilityStateChanged(int visibilityState, final DoNotHashView object) { if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); } - super.visibilityStateChanged(visibilityState, object); + super.onVisibilityStateChanged(visibilityState, object); } /** @@ -159,12 +159,12 @@ public DoNotHashViewModel_ onVisibilityStateChanged( } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, final DoNotHashView object) { if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); } - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); } /** diff --git a/epoxy-processortest/src/test/resources/EpoxyModelGroupWithAnnotations_.java b/epoxy-processortest/src/test/resources/EpoxyModelGroupWithAnnotations_.java index 771cd6bcbe..b7ae0b165d 100644 --- a/epoxy-processortest/src/test/resources/EpoxyModelGroupWithAnnotations_.java +++ b/epoxy-processortest/src/test/resources/EpoxyModelGroupWithAnnotations_.java @@ -84,11 +84,11 @@ public EpoxyModelGroupWithAnnotations_ onUnbind( } @Override - public void visibilityStateChanged(int visibilityState, final EpoxyModelGroup.Holder object) { + public void onVisibilityStateChanged(int visibilityState, final EpoxyModelGroup.Holder object) { if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); } - super.visibilityStateChanged(visibilityState, object); + super.onVisibilityStateChanged(visibilityState, object); } /** @@ -106,12 +106,12 @@ public EpoxyModelGroupWithAnnotations_ onVisibilityStateChanged( } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, final EpoxyModelGroup.Holder object) { if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); } - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); } /** diff --git a/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethodNextParentLayout$NoLayout_.java b/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethodNextParentLayout$NoLayout_.java index f9bdd45cc8..21ed38ca3d 100755 --- a/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethodNextParentLayout$NoLayout_.java +++ b/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethodNextParentLayout$NoLayout_.java @@ -79,11 +79,11 @@ public void unbind(Object object) { } @Override - public void visibilityStateChanged(int visibilityState, final Object object) { + public void onVisibilityStateChanged(int visibilityState, final Object object) { if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); } - super.visibilityStateChanged(visibilityState, object); + super.onVisibilityStateChanged(visibilityState, object); } /** @@ -101,12 +101,12 @@ public void visibilityStateChanged(int visibilityState, final Object object) { } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, final Object object) { if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); } - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); } /** diff --git a/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethodNextParentLayout$StillNoLayout_.java b/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethodNextParentLayout$StillNoLayout_.java index b874a89c32..5a575b00a9 100755 --- a/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethodNextParentLayout$StillNoLayout_.java +++ b/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethodNextParentLayout$StillNoLayout_.java @@ -79,11 +79,11 @@ public void unbind(Object object) { } @Override - public void visibilityStateChanged(int visibilityState, final Object object) { + public void onVisibilityStateChanged(int visibilityState, final Object object) { if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); } - super.visibilityStateChanged(visibilityState, object); + super.onVisibilityStateChanged(visibilityState, object); } /** @@ -101,12 +101,12 @@ public void visibilityStateChanged(int visibilityState, final Object object) { } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, final Object object) { if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); } - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); } /** diff --git a/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethodNextParentLayout$WithLayout_.java b/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethodNextParentLayout$WithLayout_.java index 2242448a4b..62b3661c18 100755 --- a/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethodNextParentLayout$WithLayout_.java +++ b/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethodNextParentLayout$WithLayout_.java @@ -79,11 +79,11 @@ public void unbind(Object object) { } @Override - public void visibilityStateChanged(int visibilityState, final Object object) { + public void onVisibilityStateChanged(int visibilityState, final Object object) { if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); } - super.visibilityStateChanged(visibilityState, object); + super.onVisibilityStateChanged(visibilityState, object); } /** @@ -101,12 +101,12 @@ public void visibilityStateChanged(int visibilityState, final Object object) { } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, final Object object) { if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); } - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); } /** diff --git a/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethodParentLayout$NoLayout_.java b/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethodParentLayout$NoLayout_.java index 9c4d9d04e6..725aeaf46f 100755 --- a/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethodParentLayout$NoLayout_.java +++ b/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethodParentLayout$NoLayout_.java @@ -79,11 +79,11 @@ public void unbind(Object object) { } @Override - public void visibilityStateChanged(int visibilityState, final Object object) { + public void onVisibilityStateChanged(int visibilityState, final Object object) { if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); } - super.visibilityStateChanged(visibilityState, object); + super.onVisibilityStateChanged(visibilityState, object); } /** @@ -101,12 +101,12 @@ public void visibilityStateChanged(int visibilityState, final Object object) { } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, final Object object) { if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); } - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); } /** diff --git a/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethodParentLayout$WithLayout_.java b/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethodParentLayout$WithLayout_.java index 83fe9ceec7..b6167019ee 100755 --- a/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethodParentLayout$WithLayout_.java +++ b/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethodParentLayout$WithLayout_.java @@ -79,11 +79,11 @@ public void unbind(Object object) { } @Override - public void visibilityStateChanged(int visibilityState, final Object object) { + public void onVisibilityStateChanged(int visibilityState, final Object object) { if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); } - super.visibilityStateChanged(visibilityState, object); + super.onVisibilityStateChanged(visibilityState, object); } /** @@ -101,12 +101,12 @@ public void visibilityStateChanged(int visibilityState, final Object object) { } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, final Object object) { if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); } - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); } /** diff --git a/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethod_.java b/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethod_.java index 4ae47d590c..4282df1dd6 100755 --- a/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethod_.java +++ b/epoxy-processortest/src/test/resources/GenerateDefaultLayoutMethod_.java @@ -79,11 +79,11 @@ public GenerateDefaultLayoutMethod_ onUnbind( } @Override - public void visibilityStateChanged(int visibilityState, final Object object) { + public void onVisibilityStateChanged(int visibilityState, final Object object) { if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); } - super.visibilityStateChanged(visibilityState, object); + super.onVisibilityStateChanged(visibilityState, object); } /** @@ -101,12 +101,12 @@ public GenerateDefaultLayoutMethod_ onVisibilityStateChanged( } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, final Object object) { if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); } - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); } /** diff --git a/epoxy-processortest/src/test/resources/GeneratedModelSuffixViewSuffix_.java b/epoxy-processortest/src/test/resources/GeneratedModelSuffixViewSuffix_.java index a02ebbaaea..e16392e2fd 100644 --- a/epoxy-processortest/src/test/resources/GeneratedModelSuffixViewSuffix_.java +++ b/epoxy-processortest/src/test/resources/GeneratedModelSuffixViewSuffix_.java @@ -94,11 +94,11 @@ public GeneratedModelSuffixViewSuffix_ onUnbind( } @Override - public void visibilityStateChanged(int visibilityState, final GeneratedModelSuffixView object) { + public void onVisibilityStateChanged(int visibilityState, final GeneratedModelSuffixView object) { if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); } - super.visibilityStateChanged(visibilityState, object); + super.onVisibilityStateChanged(visibilityState, object); } /** @@ -116,12 +116,12 @@ public GeneratedModelSuffixViewSuffix_ onVisibilityStateChanged( } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, final GeneratedModelSuffixView object) { if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); } - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); } /** diff --git a/epoxy-processortest/src/test/resources/GridSpanCountViewModel_.java b/epoxy-processortest/src/test/resources/GridSpanCountViewModel_.java index 44f5b747e5..f36028119d 100644 --- a/epoxy-processortest/src/test/resources/GridSpanCountViewModel_.java +++ b/epoxy-processortest/src/test/resources/GridSpanCountViewModel_.java @@ -110,11 +110,11 @@ public GridSpanCountViewModel_ onUnbind( } @Override - public void visibilityStateChanged(int visibilityState, final GridSpanCountView object) { + public void onVisibilityStateChanged(int visibilityState, final GridSpanCountView object) { if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); } - super.visibilityStateChanged(visibilityState, object); + super.onVisibilityStateChanged(visibilityState, object); } /** @@ -132,12 +132,12 @@ public GridSpanCountViewModel_ onVisibilityStateChanged( } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, final GridSpanCountView object) { if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); } - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); } /** diff --git a/epoxy-processortest/src/test/resources/IgnoreRequireHashCodeViewModel_.java b/epoxy-processortest/src/test/resources/IgnoreRequireHashCodeViewModel_.java index a6f63bf08c..5322a6e79f 100644 --- a/epoxy-processortest/src/test/resources/IgnoreRequireHashCodeViewModel_.java +++ b/epoxy-processortest/src/test/resources/IgnoreRequireHashCodeViewModel_.java @@ -111,11 +111,12 @@ public IgnoreRequireHashCodeViewModel_ onUnbind( } @Override - public void visibilityStateChanged(int visibilityState, final IgnoreRequireHashCodeView object) { + public void onVisibilityStateChanged(int visibilityState, + final IgnoreRequireHashCodeView object) { if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); } - super.visibilityStateChanged(visibilityState, object); + super.onVisibilityStateChanged(visibilityState, object); } /** @@ -133,12 +134,12 @@ public IgnoreRequireHashCodeViewModel_ onVisibilityStateChanged( } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, final IgnoreRequireHashCodeView object) { if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); } - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); } /** diff --git a/epoxy-processortest/src/test/resources/LayoutOverloadsViewModel_.java b/epoxy-processortest/src/test/resources/LayoutOverloadsViewModel_.java index 7ed092baaf..c23d4dcced 100644 --- a/epoxy-processortest/src/test/resources/LayoutOverloadsViewModel_.java +++ b/epoxy-processortest/src/test/resources/LayoutOverloadsViewModel_.java @@ -94,11 +94,11 @@ public LayoutOverloadsViewModel_ onUnbind( } @Override - public void visibilityStateChanged(int visibilityState, final LayoutOverloadsView object) { + public void onVisibilityStateChanged(int visibilityState, final LayoutOverloadsView object) { if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); } - super.visibilityStateChanged(visibilityState, object); + super.onVisibilityStateChanged(visibilityState, object); } /** @@ -116,12 +116,12 @@ public LayoutOverloadsViewModel_ onVisibilityStateChanged( } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, final LayoutOverloadsView object) { if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); } - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); } /** diff --git a/epoxy-processortest/src/test/resources/ModelDoNotHash_.java b/epoxy-processortest/src/test/resources/ModelDoNotHash_.java index 8039b70cf8..733eb56fc2 100644 --- a/epoxy-processortest/src/test/resources/ModelDoNotHash_.java +++ b/epoxy-processortest/src/test/resources/ModelDoNotHash_.java @@ -77,11 +77,11 @@ public ModelDoNotHash_ onUnbind(OnModelUnboundListener } @Override - public void visibilityStateChanged(int visibilityState, final Object object) { + public void onVisibilityStateChanged(int visibilityState, final Object object) { if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); } - super.visibilityStateChanged(visibilityState, object); + super.onVisibilityStateChanged(visibilityState, object); } /** @@ -99,12 +99,12 @@ public ModelDoNotHash_ onVisibilityStateChanged( } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, final Object object) { if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); } - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); } /** diff --git a/epoxy-processortest/src/test/resources/ModelDoNotUseInToString_.java b/epoxy-processortest/src/test/resources/ModelDoNotUseInToString_.java index d753420b6c..7188378896 100644 --- a/epoxy-processortest/src/test/resources/ModelDoNotUseInToString_.java +++ b/epoxy-processortest/src/test/resources/ModelDoNotUseInToString_.java @@ -79,11 +79,11 @@ public ModelDoNotUseInToString_ onUnbind( } @Override - public void visibilityStateChanged(int visibilityState, final Object object) { + public void onVisibilityStateChanged(int visibilityState, final Object object) { if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); } - super.visibilityStateChanged(visibilityState, object); + super.onVisibilityStateChanged(visibilityState, object); } /** @@ -101,12 +101,12 @@ public ModelDoNotUseInToString_ onVisibilityStateChanged( } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, final Object object) { if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); } - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); } /** diff --git a/epoxy-processortest/src/test/resources/ModelForRProcessingTest_.java b/epoxy-processortest/src/test/resources/ModelForRProcessingTest_.java index 7fdbe00d2a..8f92f45086 100755 --- a/epoxy-processortest/src/test/resources/ModelForRProcessingTest_.java +++ b/epoxy-processortest/src/test/resources/ModelForRProcessingTest_.java @@ -79,11 +79,11 @@ public ModelForRProcessingTest_ onUnbind( } @Override - public void visibilityStateChanged(int visibilityState, final Object object) { + public void onVisibilityStateChanged(int visibilityState, final Object object) { if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); } - super.visibilityStateChanged(visibilityState, object); + super.onVisibilityStateChanged(visibilityState, object); } /** @@ -101,12 +101,12 @@ public ModelForRProcessingTest_ onVisibilityStateChanged( } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, final Object object) { if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); } - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); } /** diff --git a/epoxy-processortest/src/test/resources/ModelForTestingDuplicateRValues_.java b/epoxy-processortest/src/test/resources/ModelForTestingDuplicateRValues_.java index cad25caf15..6ff4b45c77 100644 --- a/epoxy-processortest/src/test/resources/ModelForTestingDuplicateRValues_.java +++ b/epoxy-processortest/src/test/resources/ModelForTestingDuplicateRValues_.java @@ -80,11 +80,11 @@ public ModelForTestingDuplicateRValues_ onUnbind( } @Override - public void visibilityStateChanged(int visibilityState, final Object object) { + public void onVisibilityStateChanged(int visibilityState, final Object object) { if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); } - super.visibilityStateChanged(visibilityState, object); + super.onVisibilityStateChanged(visibilityState, object); } /** @@ -102,12 +102,12 @@ public ModelForTestingDuplicateRValues_ onVisibilityStateChanged( } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, final Object object) { if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); } - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); } /** diff --git a/epoxy-processortest/src/test/resources/ModelNoValidation_.java b/epoxy-processortest/src/test/resources/ModelNoValidation_.java index d790f11807..c2d8cf3286 100644 --- a/epoxy-processortest/src/test/resources/ModelNoValidation_.java +++ b/epoxy-processortest/src/test/resources/ModelNoValidation_.java @@ -69,11 +69,11 @@ public ModelNoValidation_ onUnbind(OnModelUnboundListener } @Override - public void visibilityStateChanged(int visibilityState, final Object object) { + public void onVisibilityStateChanged(int visibilityState, final Object object) { if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); } - super.visibilityStateChanged(visibilityState, object); + super.onVisibilityStateChanged(visibilityState, object); } /** @@ -99,12 +99,12 @@ public ModelWithSuper_ onVisibilityStateChanged( } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, final Object object) { if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); } - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); } /** diff --git a/epoxy-processortest/src/test/resources/ModelWithType_.java b/epoxy-processortest/src/test/resources/ModelWithType_.java index 57b65b3220..02cd55884d 100755 --- a/epoxy-processortest/src/test/resources/ModelWithType_.java +++ b/epoxy-processortest/src/test/resources/ModelWithType_.java @@ -77,11 +77,11 @@ public ModelWithType_ onUnbind(OnModelUnboundListener, Obje } @Override - public void visibilityStateChanged(int visibilityState, final Object object) { + public void onVisibilityStateChanged(int visibilityState, final Object object) { if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); } - super.visibilityStateChanged(visibilityState, object); + super.onVisibilityStateChanged(visibilityState, object); } /** @@ -99,12 +99,12 @@ public ModelWithType_ onVisibilityStateChanged( } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, final Object object) { if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); } - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); } /** diff --git a/epoxy-processortest/src/test/resources/ModelWithVarargsConstructors_.java b/epoxy-processortest/src/test/resources/ModelWithVarargsConstructors_.java index a1a22c9d67..a5c2c09289 100755 --- a/epoxy-processortest/src/test/resources/ModelWithVarargsConstructors_.java +++ b/epoxy-processortest/src/test/resources/ModelWithVarargsConstructors_.java @@ -84,11 +84,11 @@ public ModelWithVarargsConstructors_ onUnbind( } @Override - public void visibilityStateChanged(int visibilityState, final Object object) { + public void onVisibilityStateChanged(int visibilityState, final Object object) { if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); } - super.visibilityStateChanged(visibilityState, object); + super.onVisibilityStateChanged(visibilityState, object); } /** @@ -106,12 +106,12 @@ public ModelWithVarargsConstructors_ onVisibilityStateChanged( } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, final Object object) { if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); } - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); } /** diff --git a/epoxy-processortest/src/test/resources/ModelWithViewClickListener_.java b/epoxy-processortest/src/test/resources/ModelWithViewClickListener_.java index 550c45db83..16df05e5ec 100644 --- a/epoxy-processortest/src/test/resources/ModelWithViewClickListener_.java +++ b/epoxy-processortest/src/test/resources/ModelWithViewClickListener_.java @@ -80,11 +80,11 @@ public ModelWithViewClickListener_ onUnbind( } @Override - public void visibilityStateChanged(int visibilityState, final Object object) { + public void onVisibilityStateChanged(int visibilityState, final Object object) { if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); } - super.visibilityStateChanged(visibilityState, object); + super.onVisibilityStateChanged(visibilityState, object); } /** @@ -102,12 +102,12 @@ public ModelWithViewClickListener_ onVisibilityStateChanged( } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, final Object object) { if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); } - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); } /** diff --git a/epoxy-processortest/src/test/resources/ModelWithViewLongClickListener_.java b/epoxy-processortest/src/test/resources/ModelWithViewLongClickListener_.java index a4b01b3d73..4a60258653 100644 --- a/epoxy-processortest/src/test/resources/ModelWithViewLongClickListener_.java +++ b/epoxy-processortest/src/test/resources/ModelWithViewLongClickListener_.java @@ -80,11 +80,11 @@ public ModelWithViewLongClickListener_ onUnbind( } @Override - public void visibilityStateChanged(int visibilityState, final Object object) { + public void onVisibilityStateChanged(int visibilityState, final Object object) { if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); } - super.visibilityStateChanged(visibilityState, object); + super.onVisibilityStateChanged(visibilityState, object); } /** @@ -102,12 +102,12 @@ public ModelWithViewLongClickListener_ onVisibilityStateChanged( } @Override - public void visibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, int visibleHeight, int visibleWidth, final Object object) { if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); } - super.visibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); } /** diff --git a/epoxy-processortest/src/test/resources/ModelWithoutHash_.java b/epoxy-processortest/src/test/resources/ModelWithoutHash_.java index 0353a968f8..23ad51bb82 100644 --- a/epoxy-processortest/src/test/resources/ModelWithoutHash_.java +++ b/epoxy-processortest/src/test/resources/ModelWithoutHash_.java @@ -77,11 +77,11 @@ public ModelWithoutHash_ onUnbind(OnModelUnboundListener Date: Wed, 10 Oct 2018 11:17:44 -0700 Subject: [PATCH 20/38] visibilityStateParam -> visibilityObjectParam --- .../com/airbnb/epoxy/GeneratedModelWriter.kt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/epoxy-processor/src/main/java/com/airbnb/epoxy/GeneratedModelWriter.kt b/epoxy-processor/src/main/java/com/airbnb/epoxy/GeneratedModelWriter.kt index 77085c05c6..5ea507c906 100644 --- a/epoxy-processor/src/main/java/com/airbnb/epoxy/GeneratedModelWriter.kt +++ b/epoxy-processor/src/main/java/com/airbnb/epoxy/GeneratedModelWriter.kt @@ -700,12 +700,12 @@ internal class GeneratedModelWriter( private fun buildVisibilityStateChangedMethod( - visibilityStateParam: ParameterSpec + visibilityObjectParam: ParameterSpec ) = buildMethod("onVisibilityStateChanged") { addAnnotation(Override::class.java) addModifiers(PUBLIC) addParameter(TypeName.INT, "visibilityState") - addParameter(visibilityStateParam) + addParameter(visibilityObjectParam) beginControlFlow("if (\$L != null)", modelVisibilityStateChangedListenerFieldName()) addStatement( @@ -714,15 +714,15 @@ internal class GeneratedModelWriter( ) endControlFlow() - builderHooks?.addToVisibilityStateChangedMethod(this, visibilityStateParam.name) + builderHooks?.addToVisibilityStateChangedMethod(this, visibilityObjectParam.name) addStatement( - "super.onVisibilityStateChanged(\$L, \$L)", "visibilityState", visibilityStateParam.name + "super.onVisibilityStateChanged(\$L, \$L)", "visibilityState", visibilityObjectParam.name ) } private fun buildVisibilityChangedMethod( - visibilityStateParam: ParameterSpec + visibilityObjectParam: ParameterSpec ) = buildMethod("onVisibilityChanged") { addAnnotation(Override::class.java) addModifiers(PUBLIC) @@ -730,7 +730,7 @@ internal class GeneratedModelWriter( addParameter(TypeName.FLOAT, "percentVisibleWidth") addParameter(TypeName.INT, "visibleHeight") addParameter(TypeName.INT, "visibleWidth") - addParameter(visibilityStateParam) + addParameter(visibilityObjectParam) beginControlFlow("if (\$L != null)", modelVisibilityChangedListenerFieldName()) addStatement( @@ -740,11 +740,11 @@ internal class GeneratedModelWriter( ) endControlFlow() - builderHooks?.addToVisibilityChangedMethod(this, visibilityStateParam.name) + builderHooks?.addToVisibilityChangedMethod(this, visibilityObjectParam.name) addStatement( "super.onVisibilityChanged(\$L, \$L, \$L, \$L, \$L)", "percentVisibleHeight", - "percentVisibleWidth", "visibleHeight", "visibleWidth", visibilityStateParam.name + "percentVisibleWidth", "visibleHeight", "visibleWidth", visibilityObjectParam.name ) } From a965ab1b34c6dad2b71601bfbe7c5dd6776be814 Mon Sep 17 00:00:00 2001 From: Emmanuel Boudrant Date: Wed, 10 Oct 2018 11:18:31 -0700 Subject: [PATCH 21/38] Add optional checkTypeParameters in validateExecutableElement, use it for visibility annotations checking. --- .../com/airbnb/epoxy/ModelViewProcessor.kt | 34 ++++++++++++++++--- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/epoxy-processor/src/main/java/com/airbnb/epoxy/ModelViewProcessor.kt b/epoxy-processor/src/main/java/com/airbnb/epoxy/ModelViewProcessor.kt index 3dec1ce797..a6a381f075 100644 --- a/epoxy-processor/src/main/java/com/airbnb/epoxy/ModelViewProcessor.kt +++ b/epoxy-processor/src/main/java/com/airbnb/epoxy/ModelViewProcessor.kt @@ -13,6 +13,7 @@ import javax.lang.model.element.Modifier.PRIVATE import javax.lang.model.element.Modifier.STATIC import javax.lang.model.element.TypeElement import javax.lang.model.element.VariableElement +import javax.lang.model.type.TypeKind import javax.lang.model.util.Elements import javax.lang.model.util.Types @@ -215,9 +216,10 @@ internal class ModelViewProcessor( } private fun validateExecutableElement( - element: Element, - annotationClass: Class<*>, - paramCount: Int + element: Element, + annotationClass: Class<*>, + paramCount: Int, + checkTypeParameters: List? = null ): Boolean { if (element !is ExecutableElement) { errorLogger.logError("%s annotations can only be on a method (element: %s)", @@ -233,6 +235,22 @@ internal class ModelViewProcessor( return false } + checkTypeParameters?.let { expectedTypeParameters -> + // Check also the parameter types + var hasErrors = false + element.parameters.forEachIndexed { i, parameter -> + hasErrors = hasErrors || parameter.asType().kind != expectedTypeParameters[i] + } + if (hasErrors) { + errorLogger.logError( + "Methods annotated with %s must have parameter types %s, found: %s (method: %s)", + annotationClass, expectedTypeParameters, + element.parameters.map { it.asType().kind }, + element.simpleName + ) + } + } + val modifiers = element.getModifiers() if (modifiers.contains(STATIC) || modifiers.contains(PRIVATE)) { errorLogger.logError( @@ -411,10 +429,16 @@ internal class ModelViewProcessor( validateExecutableElement(resetMethod, OnViewRecycled::class.java, 0) private fun validateVisibilityStateChangedElement(visibilityMethod: Element): Boolean = - validateExecutableElement(visibilityMethod, OnVisibilityStateChanged::class.java, 1) + validateExecutableElement( + visibilityMethod, OnVisibilityStateChanged::class.java, 1, + checkTypeParameters = listOf(TypeKind.INT) + ) private fun validateVisibilityChangedElement(visibilityMethod: Element): Boolean = - validateExecutableElement(visibilityMethod, OnVisibilityChanged::class.java, 4) + validateExecutableElement( + visibilityMethod, OnVisibilityChanged::class.java, 4, + checkTypeParameters = listOf(TypeKind.FLOAT, TypeKind.FLOAT, TypeKind.INT, TypeKind.INT) + ) private fun writeJava() { val modelsToWrite = mutableListOf() From ecc85c2bcc9fbce38aefb6e4b33c1c81487c6ec4 Mon Sep 17 00:00:00 2001 From: Emmanuel Boudrant Date: Wed, 10 Oct 2018 15:54:38 -0700 Subject: [PATCH 22/38] throws if not instanceof EpoxyViewHolder --- .../main/java/com/airbnb/epoxy/EpoxyVisibilityTracker.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityTracker.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityTracker.java index 232c7518d0..ddb0344132 100644 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityTracker.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityTracker.java @@ -74,7 +74,9 @@ private void processChild(@NonNull View child, boolean detachEvent) { if (holder instanceof EpoxyViewHolder) { processVisibilityEvents(recyclerView, (EpoxyViewHolder) holder, recyclerView.getLayoutManager().canScrollVertically(), detachEvent); - } + } else throw new IllegalEpoxyUsage( + "`EpoxyVisibilityTracker` cannot be used with non-epoxy view holders." + ); } } From f3f44404eaa927005a4dc853d18fc5b0f93e773e Mon Sep 17 00:00:00 2001 From: Emmanuel Boudrant Date: Wed, 10 Oct 2018 16:30:54 -0700 Subject: [PATCH 23/38] javadoc + renaming on EpoxyVisibilityItem --- .../com/airbnb/epoxy/EpoxyVisibilityItem.java | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java index 486ff47ff6..1b5b3fd1d0 100644 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java @@ -6,6 +6,17 @@ import android.support.v7.widget.RecyclerView; import android.view.View; +/** + * This class represent an item in the {@link android.support.v7.widget.RecyclerView} and it is + * being reused with multiple model via the update method. There is 1:1 relationship between an + * EpoxyVisibilityItem and a child within the {@link android.support.v7.widget.RecyclerView}. + * + * It contains the logic to compute the visibility state of an item. It will also invoke the + * visibility callbacks on {@link com.airbnb.epoxy.EpoxyViewHolder} + * + * This class should remain non-public and is intended to be used by {@link EpoxyVisibilityTracker} + * only. + */ class EpoxyVisibilityItem { private final Rect localVisibleRect = new Rect(); @@ -15,9 +26,9 @@ class EpoxyVisibilityItem { @Px private int sizeInScrollingDirection; - private int otherSize; + private int sizeNotInScrollingDirection; - private boolean vertical; + private boolean verticalScrolling; private float percentVisibleSize = 0.f; @@ -42,14 +53,14 @@ class EpoxyVisibilityItem { */ boolean update(@NonNull View view, @NonNull RecyclerView parent, boolean vertical) { view.getLocalVisibleRect(localVisibleRect); - this.vertical = vertical; + this.verticalScrolling = vertical; if (vertical) { sizeInScrollingDirection = view.getMeasuredHeight(); - otherSize = view.getMeasuredWidth(); + sizeNotInScrollingDirection = view.getMeasuredWidth(); viewportSize = parent.getMeasuredHeight(); visibleSize = localVisibleRect.height(); } else { - otherSize = view.getMeasuredHeight(); + sizeNotInScrollingDirection = view.getMeasuredHeight(); sizeInScrollingDirection = view.getMeasuredWidth(); viewportSize = parent.getMeasuredWidth(); visibleSize = localVisibleRect.width(); @@ -106,10 +117,12 @@ void handleFullImpressionVisible(EpoxyViewHolder epoxyHolder) { void handleChanged(EpoxyViewHolder epoxyHolder) { if (visibleSize != lastVisibleSizeNotified) { - if (vertical) { - epoxyHolder.visibilityChanged(percentVisibleSize, 100.f, visibleSize, otherSize); + if (verticalScrolling) { + epoxyHolder.visibilityChanged(percentVisibleSize, 100.f, visibleSize, + sizeNotInScrollingDirection); } else { - epoxyHolder.visibilityChanged(100.f, percentVisibleSize, otherSize, visibleSize); + epoxyHolder.visibilityChanged(100.f, percentVisibleSize, + sizeNotInScrollingDirection, visibleSize); } lastVisibleSizeNotified = visibleSize; } From 0f81812025bb00ebeacbe8f7160234f0eae1ad37 Mon Sep 17 00:00:00 2001 From: Emmanuel Boudrant Date: Wed, 10 Oct 2018 16:31:02 -0700 Subject: [PATCH 24/38] EpoxyModel -> EpoxyModel --- .../java/com/airbnb/epoxy/OnModelVisibilityChangedListener.java | 2 +- .../com/airbnb/epoxy/OnModelVisibilityStateChangedListener.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/OnModelVisibilityChangedListener.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/OnModelVisibilityChangedListener.java index 88d870325e..777a53c654 100644 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/OnModelVisibilityChangedListener.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/OnModelVisibilityChangedListener.java @@ -3,7 +3,7 @@ import android.support.annotation.Px; /** Used to register an onVisibilityChanged callback with a generated model. */ -public interface OnModelVisibilityChangedListener, V> { +public interface OnModelVisibilityChangedListener, V> { /** * This will be called once the view port changed. diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/OnModelVisibilityStateChangedListener.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/OnModelVisibilityStateChangedListener.java index 91cfa54516..9aae250025 100644 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/OnModelVisibilityStateChangedListener.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/OnModelVisibilityStateChangedListener.java @@ -6,7 +6,7 @@ import java.lang.annotation.RetentionPolicy; /** Used to register an onVisibilityChanged callback with a generated model. */ -public interface OnModelVisibilityStateChangedListener, V> { +public interface OnModelVisibilityStateChangedListener, V> { @Retention(RetentionPolicy.SOURCE) @IntDef({VISIBLE, INVISIBLE, FOCUSED_VISIBLE, UNFOCUSED_VISIBLE, FULL_IMPRESSION_VISIBLE}) From 323dc6978dfa212e19f24a0ef4f55201912d25e6 Mon Sep 17 00:00:00 2001 From: Emmanuel Boudrant Date: Wed, 10 Oct 2018 16:31:38 -0700 Subject: [PATCH 25/38] Javadoc, links to the epoxy model methods --- .../src/main/java/com/airbnb/epoxy/OnVisibilityChanged.java | 5 +++-- .../main/java/com/airbnb/epoxy/OnVisibilityStateChanged.java | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/epoxy-annotations/src/main/java/com/airbnb/epoxy/OnVisibilityChanged.java b/epoxy-annotations/src/main/java/com/airbnb/epoxy/OnVisibilityChanged.java index 2789982ad1..2e7d67187c 100644 --- a/epoxy-annotations/src/main/java/com/airbnb/epoxy/OnVisibilityChanged.java +++ b/epoxy-annotations/src/main/java/com/airbnb/epoxy/OnVisibilityChanged.java @@ -7,8 +7,9 @@ /** * This can be used to annotate methods inside classes with a {@link ModelView} annotation. Methods - * with this annotation will be called when the viewport is - * changed. + * with this annotation will be called when visibility part of the view change. + * + * The equivalent methods on the model is {@link com.airbnb.epoxy.EpoxyModel#onVisibilityChanged} * * Inspired from Litho : https://fblitho.com/docs/visibility-handling */ diff --git a/epoxy-annotations/src/main/java/com/airbnb/epoxy/OnVisibilityStateChanged.java b/epoxy-annotations/src/main/java/com/airbnb/epoxy/OnVisibilityStateChanged.java index 47ba058bce..7b9045fe84 100644 --- a/epoxy-annotations/src/main/java/com/airbnb/epoxy/OnVisibilityStateChanged.java +++ b/epoxy-annotations/src/main/java/com/airbnb/epoxy/OnVisibilityStateChanged.java @@ -11,6 +11,9 @@ * * Possible States are declared in {@link com.airbnb.epoxy.OnModelVisibilityStateChangedListener}. * + * The equivalent methods on the model is + * {@link com.airbnb.epoxy.EpoxyModel#onVisibilityStateChanged} + * * Inspired from Litho: https://fblitho.com/docs/visibility-handling */ @SuppressWarnings("JavadocReference") From 2d26aafa7c00132faa9a791af3359a78a3cd1fdf Mon Sep 17 00:00:00 2001 From: Emmanuel Boudrant Date: Wed, 10 Oct 2018 16:59:50 -0700 Subject: [PATCH 26/38] Remove mention to "You may clear the listener by..." in javadoc --- .../src/main/java/com/airbnb/epoxy/GeneratedModelWriter.kt | 6 ------ 1 file changed, 6 deletions(-) diff --git a/epoxy-processor/src/main/java/com/airbnb/epoxy/GeneratedModelWriter.kt b/epoxy-processor/src/main/java/com/airbnb/epoxy/GeneratedModelWriter.kt index 5ea507c906..8aa60a0e8b 100644 --- a/epoxy-processor/src/main/java/com/airbnb/epoxy/GeneratedModelWriter.kt +++ b/epoxy-processor/src/main/java/com/airbnb/epoxy/GeneratedModelWriter.kt @@ -505,9 +505,6 @@ internal class GeneratedModelWriter( + "

\n" + "The listener will contribute to this model's hashCode state per the {@link\n" + "com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.\n" - + "

\n" - + "You may clear the listener by setting a null value, or by calling " - + "{@link #reset()}" ) .addModifiers(PUBLIC) .returns(modelInfo.parameterizedGeneratedName) @@ -535,9 +532,6 @@ internal class GeneratedModelWriter( + "

\n" + "The listener will contribute to this model's hashCode state per the {@link\n" + "com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules.\n" - + "

\n" - + "You may clear the listener by setting a null value, or by calling " - + "{@link #reset()}" ) .addModifiers(PUBLIC) .returns(modelInfo.parameterizedGeneratedName) From e780c0a8a048cc3a56af95c1e5fb374e42b605ae Mon Sep 17 00:00:00 2001 From: Emmanuel Boudrant Date: Wed, 10 Oct 2018 20:07:40 -0700 Subject: [PATCH 27/38] More javadoc --- .../airbnb/epoxy/EpoxyVisibilityTracker.java | 19 ++++++++++++++----- .../OnModelVisibilityChangedListener.java | 12 ++++++------ ...OnModelVisibilityStateChangedListener.java | 2 +- .../com/airbnb/epoxy/OnVisibilityChanged.java | 11 +++++++---- .../epoxy/OnVisibilityStateChanged.java | 15 +++++++++++---- 5 files changed, 39 insertions(+), 20 deletions(-) diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityTracker.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityTracker.java index ddb0344132..5efef704cb 100644 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityTracker.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityTracker.java @@ -11,9 +11,18 @@ import android.view.View.OnLayoutChangeListener; /** - * Helper class to handle visibility event from a {@link android.support.v7.widget.RecyclerView}. - * - * TODO: The visibility event tracking is not working well with nested list (ex: carousel). + * A simple way to track visibility events on {@link com.airbnb.epoxy.EpoxyModel} within a {@link + * android.support.v7.widget.RecyclerView}. + *

+ * {@link EpoxyVisibilityTracker} works with any {@link android.support.v7.widget.RecyclerView} + * backed by an Epoxy controller. Once attached the events will be forwarded to the Epoxy model (or + * to the Epoxy view when using annotations). + *

+ * Note regarding nested lists: The visibility event tracking is not properly handled yet. This is + * on the todo. + *

+ * @see OnVisibilityChanged (annotation) + * @see OnVisibilityStateChanged (annotation) */ public class EpoxyVisibilityTracker { @@ -29,7 +38,7 @@ public class EpoxyVisibilityTracker { /** * Attach the tracker. * - * @param recyclerView The RecyclerView. + * @param recyclerView The recyclerview that the EpoxyController has its adapter added to. */ public void attach(@NonNull RecyclerView recyclerView) { attachedRecyclerView = recyclerView; @@ -41,7 +50,7 @@ public void attach(@NonNull RecyclerView recyclerView) { /** * Detach the tracker * - * @param recyclerView The RecyclerView. + * @param recyclerView The recyclerview that the EpoxyController has its adapter added to. */ public void detach(@NonNull RecyclerView recyclerView) { recyclerView.removeOnScrollListener(this.listener); diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/OnModelVisibilityChangedListener.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/OnModelVisibilityChangedListener.java index 777a53c654..e9e8cb6e05 100644 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/OnModelVisibilityChangedListener.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/OnModelVisibilityChangedListener.java @@ -6,19 +6,19 @@ public interface OnModelVisibilityChangedListener, V> { /** - * This will be called once the view port changed. - * + * This will be called once the view visible part changes. + *

* OnModelVisibilityChangedListener should be used with particular care since they will be * dispatched on every frame while scrolling. No heavy work should be done inside the * implementation. Using {@link OnModelVisibilityStateChangedListener} is recommended whenever * possible. - * + *

* @param model The model being bound * @param view The view that is being bound to the model - * @param percentHeightVisible The percentage of height visible - * @param percentWidthVisible The percentage of width visible + * @param percentHeightVisible The percentage of height visible (0-100) + * @param percentWidthVisible The percentage of width visible (0-100) * @param heightVisible The visible height in pixel - * @param widthVisible The visible width in pixel + * @param widthVisible The visible width in pixel */ void onVisibilityChanged(T model, V view, float percentHeightVisible, float percentWidthVisible, @Px int heightVisible, @Px int widthVisible); diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/OnModelVisibilityStateChangedListener.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/OnModelVisibilityStateChangedListener.java index 9aae250025..158b41465d 100644 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/OnModelVisibilityStateChangedListener.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/OnModelVisibilityStateChangedListener.java @@ -49,7 +49,7 @@ public interface OnModelVisibilityStateChangedListener, /** * This will be called once the visibility changed. - * + *

* @param model The model being bound * @param view The view that is being bound to the model * @param visibilityState The new visibility diff --git a/epoxy-annotations/src/main/java/com/airbnb/epoxy/OnVisibilityChanged.java b/epoxy-annotations/src/main/java/com/airbnb/epoxy/OnVisibilityChanged.java index 2e7d67187c..f11cde12eb 100644 --- a/epoxy-annotations/src/main/java/com/airbnb/epoxy/OnVisibilityChanged.java +++ b/epoxy-annotations/src/main/java/com/airbnb/epoxy/OnVisibilityChanged.java @@ -8,10 +8,13 @@ /** * This can be used to annotate methods inside classes with a {@link ModelView} annotation. Methods * with this annotation will be called when visibility part of the view change. - * - * The equivalent methods on the model is {@link com.airbnb.epoxy.EpoxyModel#onVisibilityChanged} - * - * Inspired from Litho : https://fblitho.com/docs/visibility-handling + *

+ * Annotated methods should follow this signature : + * `@OnVisibilityStateChange + * public void method(@VisibilityState int state)` + *

+ * The equivalent methods on the model is {@link EpoxyModel#onVisibilityChanged} + * @see OnModelVisibilityChangedListener */ @Target(ElementType.METHOD) @Retention(RetentionPolicy.CLASS) diff --git a/epoxy-annotations/src/main/java/com/airbnb/epoxy/OnVisibilityStateChanged.java b/epoxy-annotations/src/main/java/com/airbnb/epoxy/OnVisibilityStateChanged.java index 7b9045fe84..3bec2b5661 100644 --- a/epoxy-annotations/src/main/java/com/airbnb/epoxy/OnVisibilityStateChanged.java +++ b/epoxy-annotations/src/main/java/com/airbnb/epoxy/OnVisibilityStateChanged.java @@ -8,13 +8,20 @@ /** * This can be used to annotate methods inside classes with a {@link ModelView} annotation. Methods * with this annotation will be called when the visibility state is changed. - * + *

+ * Annotated methods should follow this signature : + * `@OnVisibilityStateChanged + * public void method( + * float percentVisibleHeight, float percentVisibleWidth: Float, + * int visibleHeight, int visibleWidth + * )` + *

* Possible States are declared in {@link com.airbnb.epoxy.OnModelVisibilityStateChangedListener}. - * + *

* The equivalent methods on the model is * {@link com.airbnb.epoxy.EpoxyModel#onVisibilityStateChanged} - * - * Inspired from Litho: https://fblitho.com/docs/visibility-handling + *

+ * @see OnModelVisibilityStateChangedListener */ @SuppressWarnings("JavadocReference") @Target(ElementType.METHOD) From e2d675e92f21970c01e77a5812612988078e3a75 Mon Sep 17 00:00:00 2001 From: Emmanuel Boudrant Date: Wed, 10 Oct 2018 20:17:12 -0700 Subject: [PATCH 28/38] Move state constants to top level class VisibilityState --- .../java/com/airbnb/epoxy/EpoxyModel.java | 4 +- .../airbnb/epoxy/EpoxyModelWithHolder.java | 4 +- .../com/airbnb/epoxy/EpoxyViewHolder.java | 4 +- .../com/airbnb/epoxy/EpoxyVisibilityItem.java | 10 ++-- ...OnModelVisibilityStateChangedListener.java | 48 ++----------------- .../com/airbnb/epoxy/VisibilityState.java | 48 +++++++++++++++++++ .../kotlinsample/models/ItemCustomView.kt | 13 ++--- 7 files changed, 70 insertions(+), 61 deletions(-) create mode 100644 epoxy-adapter/src/main/java/com/airbnb/epoxy/VisibilityState.java diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModel.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModel.java index b4f0fabd7e..faf02935e9 100755 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModel.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModel.java @@ -9,7 +9,7 @@ import android.view.ViewGroup; import com.airbnb.epoxy.EpoxyController.ModelInterceptorCallback; -import com.airbnb.epoxy.OnModelVisibilityStateChangedListener.VisibilityState; +import com.airbnb.epoxy.VisibilityState.Visibility; import java.util.List; @@ -157,7 +157,7 @@ public void bind(@NonNull T view, @NonNull EpoxyModel previouslyBoundModel) { public void unbind(@NonNull T view) { } - public void onVisibilityStateChanged(@VisibilityState int visibilityState, @NonNull T view) { + public void onVisibilityStateChanged(@Visibility int visibilityState, @NonNull T view) { } public void onVisibilityChanged( diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModelWithHolder.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModelWithHolder.java index fe46eb210a..c10966dbef 100644 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModelWithHolder.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModelWithHolder.java @@ -2,7 +2,7 @@ import android.support.annotation.NonNull; -import com.airbnb.epoxy.OnModelVisibilityStateChangedListener.VisibilityState; +import com.airbnb.epoxy.VisibilityState.Visibility; import java.util.List; @@ -44,7 +44,7 @@ public void unbind(@NonNull T holder) { @Override - public void onVisibilityStateChanged(@VisibilityState int visibilityState, @NonNull T view) { + public void onVisibilityStateChanged(@Visibility int visibilityState, @NonNull T view) { super.onVisibilityStateChanged(visibilityState, view); } diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyViewHolder.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyViewHolder.java index 29cfc77c1c..adfca6b3aa 100755 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyViewHolder.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyViewHolder.java @@ -6,8 +6,8 @@ import android.support.v7.widget.RecyclerView; import android.view.View; -import com.airbnb.epoxy.OnModelVisibilityStateChangedListener.VisibilityState; import com.airbnb.epoxy.ViewHolderState.ViewState; +import com.airbnb.epoxy.VisibilityState.Visibility; import java.util.List; @@ -84,7 +84,7 @@ public void unbind() { payloads = null; } - public void visibilityStateChanged(@VisibilityState int visibilityState) { + public void visibilityStateChanged(@Visibility int visibilityState) { assertBound(); // noinspection unchecked epoxyModel.onVisibilityStateChanged(visibilityState, objectToBind()); diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java index 1b5b3fd1d0..123bc2067b 100644 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java @@ -86,32 +86,32 @@ void reset(int newAdapterPosition) { void handleVisible(@NonNull EpoxyViewHolder epoxyHolder) { if (!visible && isVisible()) { - epoxyHolder.visibilityStateChanged(OnModelVisibilityStateChangedListener.VISIBLE); + epoxyHolder.visibilityStateChanged(VisibilityState.VISIBLE); } } void handleInvisible(EpoxyViewHolder epoxyHolder, boolean detachEvent) { if (visible && isInvisible(detachEvent)) { - epoxyHolder.visibilityStateChanged(OnModelVisibilityStateChangedListener.INVISIBLE); + epoxyHolder.visibilityStateChanged(VisibilityState.INVISIBLE); } } void handleFocusedVisible(EpoxyViewHolder epoxyHolder) { if (!focusedVisible && isFocusedVisible()) { - epoxyHolder.visibilityStateChanged(OnModelVisibilityStateChangedListener.FOCUSED_VISIBLE); + epoxyHolder.visibilityStateChanged(VisibilityState.FOCUSED_VISIBLE); } } void handleUnfocusedVisible(EpoxyViewHolder epoxyHolder, boolean detachEvent) { if (focusedVisible && isUnfocusedVisible(detachEvent)) { - epoxyHolder.visibilityStateChanged(OnModelVisibilityStateChangedListener.UNFOCUSED_VISIBLE); + epoxyHolder.visibilityStateChanged(VisibilityState.UNFOCUSED_VISIBLE); } } void handleFullImpressionVisible(EpoxyViewHolder epoxyHolder) { if (!fullyVisible && isFullImpressionVisible()) { epoxyHolder - .visibilityStateChanged(OnModelVisibilityStateChangedListener.FULL_IMPRESSION_VISIBLE); + .visibilityStateChanged(VisibilityState.FULL_IMPRESSION_VISIBLE); } } diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/OnModelVisibilityStateChangedListener.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/OnModelVisibilityStateChangedListener.java index 158b41465d..ffa2d3c1e2 100644 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/OnModelVisibilityStateChangedListener.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/OnModelVisibilityStateChangedListener.java @@ -1,58 +1,18 @@ package com.airbnb.epoxy; -import android.support.annotation.IntDef; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; +import com.airbnb.epoxy.VisibilityState.Visibility; /** Used to register an onVisibilityChanged callback with a generated model. */ public interface OnModelVisibilityStateChangedListener, V> { - @Retention(RetentionPolicy.SOURCE) - @IntDef({VISIBLE, INVISIBLE, FOCUSED_VISIBLE, UNFOCUSED_VISIBLE, FULL_IMPRESSION_VISIBLE}) - @interface VisibilityState { - } - - /** - * Event triggered when a Component enters the Visible Range. This happens when at least a pixel - * of the Component is visible. - */ - int VISIBLE = 0; - - /** - * Event triggered when a Component becomes invisible. This is the same with exiting the Visible - * Range, the Focused Range and the Full Impression Range. All the code that needs to be executed - * when a component leaves any of these ranges should be written in the handler for this event. - */ - int INVISIBLE = 1; - - /** - * Event triggered when a Component enters the Focused Range. This happens when either the - * Component occupies at least half of the viewport or, if the Component is smaller than half of - * the viewport, when the it is fully visible. - */ - int FOCUSED_VISIBLE = 2; - - /** - * Event triggered when a Component exits the Focused Range. The Focused Range is defined as at - * least half of the viewport or, if the Component is smaller than half of the viewport, when the - * it is fully visible. - */ - int UNFOCUSED_VISIBLE = 3; - - /** - * Event triggered when a Component enters the Full Impression Range. This happens, for instance - * in the case of a vertical RecyclerView, when both the top and bottom edges of the component - * become visible. - */ - int FULL_IMPRESSION_VISIBLE = 4; - /** * This will be called once the visibility changed. *

* @param model The model being bound * @param view The view that is being bound to the model * @param visibilityState The new visibility + *

+ * @see VisibilityState */ - void onVisibilityStateChanged(T model, V view, @VisibilityState int visibilityState); + void onVisibilityStateChanged(T model, V view, @Visibility int visibilityState); } diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/VisibilityState.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/VisibilityState.java new file mode 100644 index 0000000000..2b1c236077 --- /dev/null +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/VisibilityState.java @@ -0,0 +1,48 @@ +package com.airbnb.epoxy; + +import android.support.annotation.IntDef; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +public final class VisibilityState { + + @Retention(RetentionPolicy.SOURCE) + @IntDef({VISIBLE, INVISIBLE, FOCUSED_VISIBLE, UNFOCUSED_VISIBLE, FULL_IMPRESSION_VISIBLE}) + public @interface Visibility { + } + + /** + * Event triggered when a Component enters the Visible Range. This happens when at least a pixel + * of the Component is visible. + */ + public static final int VISIBLE = 0; + + /** + * Event triggered when a Component becomes invisible. This is the same with exiting the Visible + * Range, the Focused Range and the Full Impression Range. All the code that needs to be executed + * when a component leaves any of these ranges should be written in the handler for this event. + */ + public static final int INVISIBLE = 1; + + /** + * Event triggered when a Component enters the Focused Range. This happens when either the + * Component occupies at least half of the viewport or, if the Component is smaller than half of + * the viewport, when the it is fully visible. + */ + public static final int FOCUSED_VISIBLE = 2; + + /** + * Event triggered when a Component exits the Focused Range. The Focused Range is defined as at + * least half of the viewport or, if the Component is smaller than half of the viewport, when the + * it is fully visible. + */ + public static final int UNFOCUSED_VISIBLE = 3; + + /** + * Event triggered when a Component enters the Full Impression Range. This happens, for instance + * in the case of a vertical RecyclerView, when both the top and bottom edges of the component + * become visible. + */ + public static final int FULL_IMPRESSION_VISIBLE = 4; +} diff --git a/kotlinsample/src/main/java/com/airbnb/epoxy/kotlinsample/models/ItemCustomView.kt b/kotlinsample/src/main/java/com/airbnb/epoxy/kotlinsample/models/ItemCustomView.kt index 69addb9280..ada03e751c 100644 --- a/kotlinsample/src/main/java/com/airbnb/epoxy/kotlinsample/models/ItemCustomView.kt +++ b/kotlinsample/src/main/java/com/airbnb/epoxy/kotlinsample/models/ItemCustomView.kt @@ -16,6 +16,7 @@ import com.airbnb.epoxy.OnViewRecycled import com.airbnb.epoxy.OnVisibilityChanged import com.airbnb.epoxy.OnVisibilityStateChanged import com.airbnb.epoxy.TextProp +import com.airbnb.epoxy.VisibilityState import com.airbnb.epoxy.kotlinsample.R // The ModelView annotation is used on Views to have models generated from those views. @@ -64,26 +65,26 @@ class ItemCustomView @JvmOverloads constructor( @OnVisibilityStateChanged fun onVisibilityStateChanged( - @OnModelVisibilityStateChangedListener.VisibilityState visibilityState: Int + @VisibilityState.Visibility visibilityState: Int ) { when (visibilityState) { - OnModelVisibilityStateChangedListener.VISIBLE -> { + VisibilityState.VISIBLE -> { Log.d(TAG, "$title Visible") onVisibilityEventDrawable.visible = true } - OnModelVisibilityStateChangedListener.INVISIBLE -> { + VisibilityState.INVISIBLE -> { Log.d(TAG, "$title Invisible") onVisibilityEventDrawable.visible = false } - OnModelVisibilityStateChangedListener.FOCUSED_VISIBLE -> { + VisibilityState.FOCUSED_VISIBLE -> { Log.d(TAG, "$title FocusedVisible") onVisibilityEventDrawable.focusedVisible = true } - OnModelVisibilityStateChangedListener.UNFOCUSED_VISIBLE -> { + VisibilityState.UNFOCUSED_VISIBLE -> { Log.d(TAG, "$title UnfocusedVisible") onVisibilityEventDrawable.focusedVisible = false } - OnModelVisibilityStateChangedListener.FULL_IMPRESSION_VISIBLE -> { + VisibilityState.FULL_IMPRESSION_VISIBLE -> { Log.d(TAG, "$title FullImpressionVisible") onVisibilityEventDrawable.fullImpression = true } From 0ca9771d3619329121badb2ca0e9de849d3a2041 Mon Sep 17 00:00:00 2001 From: Emmanuel Boudrant Date: Thu, 11 Oct 2018 15:35:45 -0700 Subject: [PATCH 29/38] Unused import --- .../java/com/airbnb/epoxy/kotlinsample/models/ItemCustomView.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/kotlinsample/src/main/java/com/airbnb/epoxy/kotlinsample/models/ItemCustomView.kt b/kotlinsample/src/main/java/com/airbnb/epoxy/kotlinsample/models/ItemCustomView.kt index ada03e751c..23d91e5f22 100644 --- a/kotlinsample/src/main/java/com/airbnb/epoxy/kotlinsample/models/ItemCustomView.kt +++ b/kotlinsample/src/main/java/com/airbnb/epoxy/kotlinsample/models/ItemCustomView.kt @@ -11,7 +11,6 @@ import com.airbnb.epoxy.AfterPropsSet import com.airbnb.epoxy.CallbackProp import com.airbnb.epoxy.ModelProp import com.airbnb.epoxy.ModelView -import com.airbnb.epoxy.OnModelVisibilityStateChangedListener import com.airbnb.epoxy.OnViewRecycled import com.airbnb.epoxy.OnVisibilityChanged import com.airbnb.epoxy.OnVisibilityStateChanged From ad083de8281c79fb05d2ff7356f63f131109e9a6 Mon Sep 17 00:00:00 2001 From: Emmanuel Boudrant Date: Thu, 11 Oct 2018 15:37:07 -0700 Subject: [PATCH 30/38] Add 3 tests : load RV, scroll to, scroll by. --- epoxy-adapter/build.gradle | 2 + .../epoxy/EpoxyVisibilityTrackerTest.kt | 535 ++++++++++++++++++ 2 files changed, 537 insertions(+) create mode 100644 epoxy-adapter/src/test/java/com/airbnb/epoxy/EpoxyVisibilityTrackerTest.kt diff --git a/epoxy-adapter/build.gradle b/epoxy-adapter/build.gradle index 5b84815afd..79f89b384c 100755 --- a/epoxy-adapter/build.gradle +++ b/epoxy-adapter/build.gradle @@ -1,4 +1,5 @@ apply plugin: 'com.android.library' +apply plugin: 'kotlin-android' android { compileSdkVersion rootProject.COMPILE_SDK_VERSION @@ -25,6 +26,7 @@ dependencies { annotationProcessor project(':epoxy-processor') + testImplementation rootProject.deps.kotlin testCompile rootProject.deps.junit testCompile rootProject.deps.robolectric testCompile rootProject.deps.mockito diff --git a/epoxy-adapter/src/test/java/com/airbnb/epoxy/EpoxyVisibilityTrackerTest.kt b/epoxy-adapter/src/test/java/com/airbnb/epoxy/EpoxyVisibilityTrackerTest.kt new file mode 100644 index 0000000000..09d8f26661 --- /dev/null +++ b/epoxy-adapter/src/test/java/com/airbnb/epoxy/EpoxyVisibilityTrackerTest.kt @@ -0,0 +1,535 @@ +package com.airbnb.epoxy + +import android.app.Activity +import android.support.v7.widget.LinearLayoutManager +import android.support.v7.widget.RecyclerView +import android.view.View +import android.view.ViewGroup +import android.widget.FrameLayout +import android.widget.TextView +import com.airbnb.epoxy.VisibilityState.FOCUSED_VISIBLE +import com.airbnb.epoxy.VisibilityState.FULL_IMPRESSION_VISIBLE +import com.airbnb.epoxy.VisibilityState.INVISIBLE +import com.airbnb.epoxy.VisibilityState.UNFOCUSED_VISIBLE +import com.airbnb.epoxy.VisibilityState.VISIBLE +import org.junit.After +import org.junit.Assert +import org.junit.Before +import org.junit.Test +import org.junit.runner.RunWith +import org.robolectric.Robolectric +import org.robolectric.annotation.Config +import java.lang.StringBuilder + +/** + * This class test the EpoxyVisibilityTracker by using a RecyclerView that scroll vertically. The + * view port height is provided by Robolectric. + * + * We are just controlling how many items are displayed with VISIBLE_ITEMS constant. + */ +@Config(sdk = [21], manifest = TestRunner.MANIFEST_PATH) +@RunWith(TestRunner::class) +class EpoxyVisibilityTrackerTest { + + companion object { + + /** + * Make sure the RecyclerView display: + * - 2 full items + * - 50% of the next item. + */ + private const val VISIBLE_ITEMS = 2.5 + private val FULLY_VISIBLE_ITEMS = Math.floor(VISIBLE_ITEMS).toInt() + private val ALL_STATES = intArrayOf( + VISIBLE, + INVISIBLE, + FOCUSED_VISIBLE, + UNFOCUSED_VISIBLE, + FULL_IMPRESSION_VISIBLE + ) + + private const val DEBUG_LOG = true + private fun log(message: String) { + if (DEBUG_LOG) System.out.println(message) + } + } + + private lateinit var activity: Activity + private lateinit var recyclerView: RecyclerView + private var viewportHeight: Int = 0 + private var itemHeight: Int = 0 + + private val epoxyVisibilityTracker = EpoxyVisibilityTracker() + + /** + * Test visibility events when loading a recycler view + */ + @Test + fun testDataAttachedToRecyclerView() { + val testHelper = buildTestData(10) + + val firstHalfVisibleItem = FULLY_VISIBLE_ITEMS + val firstInvisibleItem = firstHalfVisibleItem + 1 + + // Verify visibility event + testHelper.forEachIndexed { index, helper -> + when { + + index in 0 until firstHalfVisibleItem -> { + + // Item expected to be 100% visible + + with(helper) { + assert( + visibleHeight = itemHeight, + percentVisibleHeight = 100.0f, + visible = true, + fullImpression = true, + visitedStates = intArrayOf( + VISIBLE, + FOCUSED_VISIBLE, + FULL_IMPRESSION_VISIBLE + ) + ) + } + } + + index == firstHalfVisibleItem -> { + + // Item expected to be 50% visible + + with(helper) { + assert( + visibleHeight = itemHeight / 2, + percentVisibleHeight = 50.0f, + visible = true, + fullImpression = false, + visitedStates = intArrayOf(VISIBLE) + ) + } + } + + index in firstInvisibleItem..9 -> { + + // Item expected not to be visible + + with(helper) { + assert( + visibleHeight = 0, + percentVisibleHeight = 0.0f, + visible = false, + fullImpression = false, + visitedStates = intArrayOf() + ) + } + } + + else -> throw IllegalStateException("index should not be bigger than 9") + } + + log("$index valid") + } + } + + + + /** + * Test visibility events using scrollToPosition on the recycler view + */ + @Test + fun testScrollBy() { + val testHelper = buildTestData(10) + + // At this point we have the 1st and 2nd item visible + // The 3rd item is 50% visible + + // Now scroll to the end + for(to in 0..testHelper.size) { + (recyclerView.layoutManager as LinearLayoutManager).scrollToPositionWithOffset(to, 10) + } + + // Verify visibility event + testHelper.forEachIndexed { index, helper -> + when { + + index in 0..1 -> { + + // Item expected not to be visible but should have visited all states + + with(helper) { + assert( + visibleHeight = 0, + percentVisibleHeight = 0.0f, + visible = false, + fullImpression = false, + visitedStates = ALL_STATES + ) + } + } + + index == 2 -> { + + // This item was only half visible, it was never fully visible + + with(helper) { + assert( + visibleHeight = 0, + percentVisibleHeight = 0.0f, + visible = false, + fullImpression = false, + visitedStates = ALL_STATES + ) + } + + } + + index in 3..6 -> { + + // Theses items were never rendered + + with(helper) { + assert( + visibleHeight = 0, + percentVisibleHeight = 0.0f, + visible = false, + fullImpression = false, + visitedStates = ALL_STATES + ) + } + + } + + index == 7 -> { + + // Item expected to be 50% visible + + with(helper) { + assert( + visibleHeight = itemHeight / 2, + percentVisibleHeight = 50.0f, + visible = true, + fullImpression = false, + visitedStates = intArrayOf( + VISIBLE, + FOCUSED_VISIBLE, + FULL_IMPRESSION_VISIBLE, + UNFOCUSED_VISIBLE + ) + ) + } + } + + index in 8..9 -> { + + // Item expected to be 100% visible + + with(helper) { + assert( + visibleHeight = itemHeight, + percentVisibleHeight = 100.0f, + visible = true, + fullImpression = true, + visitedStates = intArrayOf( + VISIBLE, + FOCUSED_VISIBLE, + FULL_IMPRESSION_VISIBLE + ) + ) + } + } + else -> throw IllegalStateException("index should not be bigger than 9") + } + + log("$index valid") + } + } + + /** + * Test visibility events using scrollToPosition on the recycler view + */ + @Test + fun testScrollToPosition() { + val testHelper = buildTestData(10) + + // At this point we have the 1st and 2nd item visible + // The 3rd item is 50% visible + + // Now scroll to the end + val scrollToPosition = testHelper.size - 1 + log("scrollToPosition=$scrollToPosition") + recyclerView.scrollToPosition(scrollToPosition) + + // Verify visibility event + testHelper.forEachIndexed { index, helper -> + when { + + index in 0..1 -> { + + // Item expected not to be visible but should have visited all states + + with(helper) { + assert( + visibleHeight = 0, + percentVisibleHeight = 0.0f, + visible = false, + fullImpression = false, + visitedStates = intArrayOf( + VISIBLE, + FOCUSED_VISIBLE, + FULL_IMPRESSION_VISIBLE, + UNFOCUSED_VISIBLE, + INVISIBLE + ) + ) + } + } + + index == 2 -> { + + // This item was only half visible, it was never fully visible + + with(helper) { + assert( + visibleHeight = 0, + percentVisibleHeight = 0.0f, + visible = false, + fullImpression = false, + visitedStates = intArrayOf(VISIBLE, INVISIBLE) + ) + } + + } + + index in 3..6 -> { + + // Theses items were never rendered + + with(helper) { + assert( + visibleHeight = 0, + percentVisibleHeight = 0.0f, + visible = false, + fullImpression = false, + visitedStates = intArrayOf() + ) + } + + } + + index == 7 -> { + + // Item expected to be 50% visible + + with(helper) { + assert( + visibleHeight = itemHeight / 2, + percentVisibleHeight = 50.0f, + visible = true, + fullImpression = false, + visitedStates = intArrayOf(VISIBLE) + ) + } + } + + index in 8..9 -> { + + // Item expected to be 100% visible + + with(helper) { + assert( + visibleHeight = itemHeight, + percentVisibleHeight = 100.0f, + visible = true, + fullImpression = true, + visitedStates = intArrayOf( + VISIBLE, + FOCUSED_VISIBLE, + FULL_IMPRESSION_VISIBLE + ) + ) + } + } + else -> throw IllegalStateException("index should not be bigger than 9") + } + + log("$index valid") + } + } + + /** + * Attach an EpoxyController on the RecyclerView + */ + private fun buildTestData(sampleSize: Int): MutableList { + // Build a test sample of 0 items + val testHelper = mutableListOf().apply { + for (index in 0 until sampleSize) add(AssertHelper()) + } + + // Plug an epoxy controller + val controller = object : TypedEpoxyController() { + override fun buildModels(data: Int?) { + data?.let { size -> + for (index in 0 until size) { + add(TestModel(index, itemHeight, testHelper[index]).id(index)) + } + } + } + } + recyclerView.adapter = controller.adapter + controller.setData(testHelper.size) + return testHelper + } + + /** + * Setup a RecyclerView and compute item height so we have 3.5 items on screen + */ + @Before + fun setup() { + Robolectric.setupActivity(Activity::class.java).apply { + setContentView(EpoxyRecyclerView(this).apply { + epoxyVisibilityTracker.attach(this) + recyclerView = this + }) + viewportHeight = recyclerView.measuredHeight + itemHeight = (recyclerView.measuredHeight / VISIBLE_ITEMS).toInt() + activity = this + } + } + + @After + fun tearDown() { + epoxyVisibilityTracker.detach(recyclerView) + } + + /** + * Epoxy model used for test + */ + internal class TestModel( + private val itemPosition: Int, + private val itemHeight: Int, + private val helper: AssertHelper + ) : EpoxyModelWithView() { + + override fun buildView(parent: ViewGroup): View { + log("buildView[$itemPosition]") + return TextView(parent.context).apply { + // Force height + layoutParams = RecyclerView.LayoutParams( + FrameLayout.LayoutParams.MATCH_PARENT, + itemHeight + ) + } + } + + override fun onVisibilityChanged(ph: Float, pw: Float, vh: Int, vw: Int, view: View) { + helper.percentVisibleHeight = ph + helper.visibleHeight = vh + if (ph.toInt() != 100) helper.fullImpression = false + } + + override fun onVisibilityStateChanged(state: Int, view: View) { + log("onVisibilityStateChanged[$itemPosition]=${state.description()}") + helper.visitedStates.add(state) + when (state) { + VISIBLE, INVISIBLE -> helper.visible = state == VISIBLE + FOCUSED_VISIBLE, UNFOCUSED_VISIBLE -> helper.focused = state == FOCUSED_VISIBLE + FULL_IMPRESSION_VISIBLE -> helper.fullImpression = state == + FULL_IMPRESSION_VISIBLE + } + } + } + + /** + * Helper for asserting visibility + */ + internal class AssertHelper { + + var created = false + var visitedStates = mutableListOf() + var visibleHeight = 0 + var percentVisibleHeight = 0.0f + var visible = false + var focused = false + var fullImpression = false + + fun assert( + visibleHeight: Int? = null, + percentVisibleHeight: Float? = null, + visible: Boolean? = null, + fullImpression: Boolean? = null, + visitedStates: IntArray? = null + ) { + visibleHeight?.let { + // assert with 1px precision + Assert.assertTrue( + "visibleHeight expected $it got ${this.visibleHeight}", + Math.abs(it - this.visibleHeight) < 1 + ) + } + percentVisibleHeight?.let { + Assert.assertEquals( + "percentVisibleHeight expected $it got ${this.percentVisibleHeight}", + it, + this.percentVisibleHeight + ) + } + visible?.let { + Assert.assertEquals( + "visible expected $it got ${this.visible}", + it, + this.visible + ) + } + fullImpression?.let { + Assert.assertEquals( + "fullImpression expected $it got ${this.fullImpression}", + it, + this.fullImpression + ) + } + visitedStates?.let { assertVisited(it) } + } + + private fun assertVisited(states: IntArray) { + val expectedStates = mutableListOf() + states.forEach { expectedStates.add(it) } + for (state in expectedStates) { + if (!visitedStates.contains(state)) { + Assert.fail("Expected visited ${expectedStates.description()}, got ${visitedStates.description()}") + } + } + for (state in ALL_STATES) { + if (!expectedStates.contains(state) && visitedStates.contains(state)) { + Assert.fail("Expected ${state.description()} not visited, got ${visitedStates.description()}") + } + } + } + } + +} + +/** + * List of Int to VisibilityState constant names. + */ +private fun List.description(): String { + val builder = StringBuilder("[") + forEachIndexed { index, state -> + builder.append(state.description()) + builder.append(if (index < size - 1) "," else "]") + } + return builder.toString() +} + +/** + * Int to VisibilityState constant name. + */ +private fun Int.description(): String { + return when (this) { + VISIBLE -> "VISIBLE" + INVISIBLE -> "INVISIBLE" + FOCUSED_VISIBLE -> "FOCUSED_VISIBLE" + UNFOCUSED_VISIBLE -> "UNFOCUSED_VISIBLE" + FULL_IMPRESSION_VISIBLE -> "FULL_IMPRESSION_VISIBLE" + else -> throw IllegalStateException("Please declare new state here") + } +} From 7a1b97e5929b714ba9cb162f1f42cfe3301d8421 Mon Sep 17 00:00:00 2001 From: Emmanuel Boudrant Date: Thu, 11 Oct 2018 15:37:38 -0700 Subject: [PATCH 31/38] Fix bugs (thanks to unit tests) --- .../com/airbnb/epoxy/EpoxyVisibilityItem.java | 31 +++++++---------- .../airbnb/epoxy/EpoxyVisibilityTracker.java | 33 ++++++++++++++----- 2 files changed, 36 insertions(+), 28 deletions(-) diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java index 123bc2067b..89150ddd35 100644 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java @@ -51,21 +51,22 @@ class EpoxyVisibilityItem { * @param vertical true if it scroll vertically * @return true if the view has been measured */ - boolean update(@NonNull View view, @NonNull RecyclerView parent, boolean vertical) { + boolean update(@NonNull View view, @NonNull RecyclerView parent, + boolean vertical, boolean detachEvent) { view.getLocalVisibleRect(localVisibleRect); this.verticalScrolling = vertical; if (vertical) { sizeInScrollingDirection = view.getMeasuredHeight(); sizeNotInScrollingDirection = view.getMeasuredWidth(); viewportSize = parent.getMeasuredHeight(); - visibleSize = localVisibleRect.height(); + visibleSize = detachEvent ? 0 : localVisibleRect.height(); } else { sizeNotInScrollingDirection = view.getMeasuredHeight(); sizeInScrollingDirection = view.getMeasuredWidth(); viewportSize = parent.getMeasuredWidth(); - visibleSize = localVisibleRect.width(); + visibleSize = detachEvent ? 0 : localVisibleRect.width(); } - percentVisibleSize = 100.f / sizeInScrollingDirection * visibleSize; + percentVisibleSize = detachEvent ? 0 : 100.f / sizeInScrollingDirection * visibleSize; if (visibleSize != sizeInScrollingDirection) { fullyVisible = false; } @@ -84,31 +85,23 @@ void reset(int newAdapterPosition) { lastVisibleSizeNotified = -1; } - void handleVisible(@NonNull EpoxyViewHolder epoxyHolder) { - if (!visible && isVisible()) { - epoxyHolder.visibilityStateChanged(VisibilityState.VISIBLE); - } - } - - void handleInvisible(EpoxyViewHolder epoxyHolder, boolean detachEvent) { + void handleVisible(@NonNull EpoxyViewHolder epoxyHolder, boolean detachEvent) { if (visible && isInvisible(detachEvent)) { epoxyHolder.visibilityStateChanged(VisibilityState.INVISIBLE); + } else if (!visible && isVisible()) { + epoxyHolder.visibilityStateChanged(VisibilityState.VISIBLE); } } - void handleFocusedVisible(EpoxyViewHolder epoxyHolder) { - if (!focusedVisible && isFocusedVisible()) { - epoxyHolder.visibilityStateChanged(VisibilityState.FOCUSED_VISIBLE); - } - } - - void handleUnfocusedVisible(EpoxyViewHolder epoxyHolder, boolean detachEvent) { + void handleFocus(EpoxyViewHolder epoxyHolder, boolean detachEvent) { if (focusedVisible && isUnfocusedVisible(detachEvent)) { epoxyHolder.visibilityStateChanged(VisibilityState.UNFOCUSED_VISIBLE); + } else if (!focusedVisible && isFocusedVisible()) { + epoxyHolder.visibilityStateChanged(VisibilityState.FOCUSED_VISIBLE); } } - void handleFullImpressionVisible(EpoxyViewHolder epoxyHolder) { + void handleFullImpressionVisible(EpoxyViewHolder epoxyHolder, boolean detachEvent) { if (!fullyVisible && isFullImpressionVisible()) { epoxyHolder .visibilityStateChanged(VisibilityState.FULL_IMPRESSION_VISIBLE); diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityTracker.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityTracker.java index 5efef704cb..c8a505e78c 100644 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityTracker.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityTracker.java @@ -21,8 +21,10 @@ * Note regarding nested lists: The visibility event tracking is not properly handled yet. This is * on the todo. *

- * @see OnVisibilityChanged (annotation) - * @see OnVisibilityStateChanged (annotation) + * @see OnVisibilityChanged + * @see OnVisibilityStateChanged + * @see OnModelVisibilityChangedListener + * @see OnModelVisibilityStateChangedListener */ public class EpoxyVisibilityTracker { @@ -35,6 +37,19 @@ public class EpoxyVisibilityTracker { @Nullable private RecyclerView attachedRecyclerView = null; + private boolean onChangedEnabled = true; + + /** + * Enable or disable visibility changed event. Default is `true`, disable it if you don't need + * (triggered by every pixel scrolled). + * + * @see OnVisibilityChanged + * @see OnModelVisibilityChangedListener + */ + public void setOnChangedEnabled(boolean enabled) { + onChangedEnabled = enabled; + } + /** * Attach the tracker. * @@ -112,14 +127,14 @@ private void processVisibilityEvents( vi.reset(epoxyHolder.getAdapterPosition()); } - if (vi.update(itemView, recyclerView, vertical)) { + if (vi.update(itemView, recyclerView, vertical, detachEvent)) { // View is measured, process events - vi.handleVisible(epoxyHolder); - vi.handleInvisible(epoxyHolder, detachEvent); - vi.handleFocusedVisible(epoxyHolder); - vi.handleUnfocusedVisible(epoxyHolder, detachEvent); - vi.handleFullImpressionVisible(epoxyHolder); - vi.handleChanged(epoxyHolder); + vi.handleVisible(epoxyHolder, detachEvent); + vi.handleFocus(epoxyHolder, detachEvent); + vi.handleFullImpressionVisible(epoxyHolder, detachEvent); + if (onChangedEnabled) { + vi.handleChanged(epoxyHolder); + } } } From 7db96a9715441c9150b18cc441f1e97c4a0ebc01 Mon Sep 17 00:00:00 2001 From: Emmanuel Boudrant Date: Thu, 11 Oct 2018 22:17:42 -0700 Subject: [PATCH 32/38] Missing annotations (FloatRange, Px) --- .../src/main/java/com/airbnb/epoxy/EpoxyModel.java | 5 +++-- .../main/java/com/airbnb/epoxy/EpoxyModelWithHolder.java | 8 ++++++-- .../src/main/java/com/airbnb/epoxy/EpoxyViewHolder.java | 5 +++-- .../airbnb/epoxy/OnModelVisibilityChangedListener.java | 9 ++++++--- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModel.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModel.java index faf02935e9..e3d39774ac 100755 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModel.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModel.java @@ -4,6 +4,7 @@ import android.support.annotation.LayoutRes; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.support.annotation.Px; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -163,8 +164,8 @@ public void onVisibilityStateChanged(@Visibility int visibilityState, @NonNull T public void onVisibilityChanged( @FloatRange(from = 0.0f, to = 100.0f) float percentVisibleHeight, @FloatRange(from = 0.0f, to = 100.0f) float percentVisibleWidth, - int visibleHeight, - int visibleWidth, + @Px int visibleHeight, + @Px int visibleWidth, @NonNull T view ) { } diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModelWithHolder.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModelWithHolder.java index c10966dbef..a6f88eeddf 100644 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModelWithHolder.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModelWithHolder.java @@ -1,6 +1,8 @@ package com.airbnb.epoxy; +import android.support.annotation.FloatRange; import android.support.annotation.NonNull; +import android.support.annotation.Px; import com.airbnb.epoxy.VisibilityState.Visibility; @@ -49,8 +51,10 @@ public void onVisibilityStateChanged(@Visibility int visibilityState, @NonNull T } @Override - public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, - int visibleHeight, int visibleWidth, + public void onVisibilityChanged( + @FloatRange(from = 0, to = 100) float percentVisibleHeight, + @FloatRange(from = 0, to = 100) float percentVisibleWidth, + @Px int visibleHeight, @Px int visibleWidth, @NonNull T view) { super.onVisibilityChanged( percentVisibleHeight, percentVisibleWidth, diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyViewHolder.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyViewHolder.java index adfca6b3aa..b03815ce72 100755 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyViewHolder.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyViewHolder.java @@ -3,6 +3,7 @@ import android.support.annotation.FloatRange; import android.support.annotation.Nullable; +import android.support.annotation.Px; import android.support.v7.widget.RecyclerView; import android.view.View; @@ -93,8 +94,8 @@ public void visibilityStateChanged(@Visibility int visibilityState) { public void visibilityChanged( @FloatRange(from = 0.0f, to = 100.0f) float percentVisibleHeight, @FloatRange(from = 0.0f, to = 100.0f) float percentVisibleWidth, - int visibleHeight, - int visibleWidth + @Px int visibleHeight, + @Px int visibleWidth ) { assertBound(); // noinspection unchecked diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/OnModelVisibilityChangedListener.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/OnModelVisibilityChangedListener.java index e9e8cb6e05..2f16566e01 100644 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/OnModelVisibilityChangedListener.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/OnModelVisibilityChangedListener.java @@ -1,5 +1,6 @@ package com.airbnb.epoxy; +import android.support.annotation.FloatRange; import android.support.annotation.Px; /** Used to register an onVisibilityChanged callback with a generated model. */ @@ -15,11 +16,13 @@ public interface OnModelVisibilityChangedListener, V> { *

* @param model The model being bound * @param view The view that is being bound to the model - * @param percentHeightVisible The percentage of height visible (0-100) - * @param percentWidthVisible The percentage of width visible (0-100) + * @param percentVisibleHeight The percentage of height visible (0-100) + * @param percentVisibleWidth The percentage of width visible (0-100) * @param heightVisible The visible height in pixel * @param widthVisible The visible width in pixel */ - void onVisibilityChanged(T model, V view, float percentHeightVisible, float percentWidthVisible, + void onVisibilityChanged(T model, V view, + @FloatRange(from = 0, to = 100) float percentVisibleHeight, + @FloatRange(from = 0, to = 100) float percentVisibleWidth, @Px int heightVisible, @Px int widthVisible); } From e150b9d10061d9c01fa54e98492e81a541be0f27 Mon Sep 17 00:00:00 2001 From: Emmanuel Boudrant Date: Fri, 12 Oct 2018 01:24:58 -0700 Subject: [PATCH 33/38] Tests for @ModelView's @OnVisibilityChanged @OnVisibilityStateChanged codegen --- .../com/airbnb/epoxy/ViewProcessorTest.kt | 70 ++++ .../resources/OnVisibilityChangedView.java | 27 ++ .../OnVisibilityChangedViewModel_.java | 315 ++++++++++++++++++ ...lityChangedView_throwsIfInvalidParams.java | 22 ++ ...isibilityChangedView_throwsIfNoParams.java | 22 ++ ...VisibilityChangedView_throwsIfPrivate.java | 22 ++ ...nVisibilityChangedView_throwsIfStatic.java | 22 ++ .../OnVisibilityStateChangedView.java | 27 ++ .../OnVisibilityStateChangedViewModel_.java | 315 ++++++++++++++++++ ...tateChangedView_throwsIfInvalidParams.java | 22 ++ ...lityStateChangedView_throwsIfNoParams.java | 22 ++ ...ilityStateChangedView_throwsIfPrivate.java | 22 ++ ...bilityStateChangedView_throwsIfStatic.java | 22 ++ 13 files changed, 930 insertions(+) create mode 100644 epoxy-processortest/src/test/resources/OnVisibilityChangedView.java create mode 100644 epoxy-processortest/src/test/resources/OnVisibilityChangedViewModel_.java create mode 100644 epoxy-processortest/src/test/resources/OnVisibilityChangedView_throwsIfInvalidParams.java create mode 100644 epoxy-processortest/src/test/resources/OnVisibilityChangedView_throwsIfNoParams.java create mode 100644 epoxy-processortest/src/test/resources/OnVisibilityChangedView_throwsIfPrivate.java create mode 100644 epoxy-processortest/src/test/resources/OnVisibilityChangedView_throwsIfStatic.java create mode 100644 epoxy-processortest/src/test/resources/OnVisibilityStateChangedView.java create mode 100644 epoxy-processortest/src/test/resources/OnVisibilityStateChangedViewModel_.java create mode 100644 epoxy-processortest/src/test/resources/OnVisibilityStateChangedView_throwsIfInvalidParams.java create mode 100644 epoxy-processortest/src/test/resources/OnVisibilityStateChangedView_throwsIfNoParams.java create mode 100644 epoxy-processortest/src/test/resources/OnVisibilityStateChangedView_throwsIfPrivate.java create mode 100644 epoxy-processortest/src/test/resources/OnVisibilityStateChangedView_throwsIfStatic.java diff --git a/epoxy-processortest/src/test/java/com/airbnb/epoxy/ViewProcessorTest.kt b/epoxy-processortest/src/test/java/com/airbnb/epoxy/ViewProcessorTest.kt index cb359c62cd..b2d2290b79 100644 --- a/epoxy-processortest/src/test/java/com/airbnb/epoxy/ViewProcessorTest.kt +++ b/epoxy-processortest/src/test/java/com/airbnb/epoxy/ViewProcessorTest.kt @@ -109,6 +109,76 @@ class ViewProcessorTest { "must have exactly 0 parameter") } + @Test + fun onVisibilityChanged() { + assertGeneration( + "OnVisibilityChangedView.java", + "OnVisibilityChangedViewModel_.java") + } + + @Test + fun onVisibilityChanged_throwsIfPrivate() { + assertGenerationError( + "OnVisibilityChangedView_throwsIfPrivate.java", + "private") + } + + @Test + fun onVisibilityChanged_throwsIfStatic() { + assertGenerationError( + "OnVisibilityChangedView_throwsIfStatic.java", + "static") + } + + @Test + fun onVisibilityChanged_throwsIfInvalidParams() { + assertGenerationError( + "OnVisibilityChangedView_throwsIfInvalidParams.java", + "must have parameter types [FLOAT, FLOAT, INT, INT], found: [BOOLEAN, BOOLEAN, INT, INT] (method: onVisibilityChanged)") + } + + @Test + fun onVisibilityChanged_throwsIfNoParams() { + assertGenerationError( + "OnVisibilityChangedView_throwsIfNoParams.java", + "must have exactly 4 parameter (method: onVisibilityChanged)") + } + + @Test + fun onVisibilityStateChanged() { + assertGeneration( + "OnVisibilityStateChangedView.java", + "OnVisibilityStateChangedViewModel_.java") + } + + @Test + fun onVisibilityStateChanged_throwsIfPrivate() { + assertGenerationError( + "OnVisibilityStateChangedView_throwsIfPrivate.java", + "private") + } + + @Test + fun onVisibilityStateChanged_throwsIfStatic() { + assertGenerationError( + "OnVisibilityStateChangedView_throwsIfStatic.java", + "static") + } + + @Test + fun onVisibilityStateChanged_throwsIfInvalidParams() { + assertGenerationError( + "OnVisibilityStateChangedView_throwsIfInvalidParams.java", + "must have parameter types [INT], found: [BOOLEAN] (method: onVisibilityStateChanged)") + } + + @Test + fun onVisibilityStateChanged_throwsIfNoParams() { + assertGenerationError( + "OnVisibilityStateChangedView_throwsIfNoParams.java", + "must have exactly 1 parameter (method: onVisibilityStateChanged)") + } + @Test fun nullOnRecycle() { assertGeneration("NullOnRecycleView.java", "NullOnRecycleViewModel_.java") diff --git a/epoxy-processortest/src/test/resources/OnVisibilityChangedView.java b/epoxy-processortest/src/test/resources/OnVisibilityChangedView.java new file mode 100644 index 0000000000..4070c22f95 --- /dev/null +++ b/epoxy-processortest/src/test/resources/OnVisibilityChangedView.java @@ -0,0 +1,27 @@ +package com.airbnb.epoxy; + +import android.content.Context; +import android.view.View; + +@ModelView(defaultLayout = 1) +public class OnVisibilityChangedView extends View { + + public OnVisibilityChangedView(Context context) { + super(context); + } + + @ModelProp + public void setTitle(CharSequence title) { + + } + + @OnVisibilityChanged + void onVisibilityChanged1(float ph, float pw, int vh, int vw) { + // also testing package private works + } + + @OnVisibilityChanged + public void onVisibilityChanged2(float ph, float pw, int vh, int vw) { + + } +} \ No newline at end of file diff --git a/epoxy-processortest/src/test/resources/OnVisibilityChangedViewModel_.java b/epoxy-processortest/src/test/resources/OnVisibilityChangedViewModel_.java new file mode 100644 index 0000000000..9c199b60a0 --- /dev/null +++ b/epoxy-processortest/src/test/resources/OnVisibilityChangedViewModel_.java @@ -0,0 +1,315 @@ +package com.airbnb.epoxy; + +import android.support.annotation.LayoutRes; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import java.lang.CharSequence; +import java.lang.IllegalArgumentException; +import java.lang.IllegalStateException; +import java.lang.Number; +import java.lang.Object; +import java.lang.Override; +import java.lang.String; +import java.util.BitSet; + +/** + * Generated file. Do not modify! */ +public class OnVisibilityChangedViewModel_ extends EpoxyModel implements GeneratedModel, OnVisibilityChangedViewModelBuilder { + private final BitSet assignedAttributes_epoxyGeneratedModel = new BitSet(1); + + private OnModelBoundListener onModelBoundListener_epoxyGeneratedModel; + + private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + + /** + * Bitset index: 0 */ + @NonNull + private CharSequence title_CharSequence; + + @Override + public void addTo(EpoxyController controller) { + super.addTo(controller); + addWithDebugValidation(controller); + if (!assignedAttributes_epoxyGeneratedModel.get(0)) { + throw new IllegalStateException("A value is required for setTitle"); + } + } + + @Override + public void handlePreBind(final EpoxyViewHolder holder, final OnVisibilityChangedView object, + final int position) { + validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position); + } + + @Override + public void bind(final OnVisibilityChangedView object) { + super.bind(object); + object.setTitle(title_CharSequence); + } + + @Override + public void bind(final OnVisibilityChangedView object, EpoxyModel previousModel) { + if (!(previousModel instanceof OnVisibilityChangedViewModel_)) { + bind(object); + return; + } + OnVisibilityChangedViewModel_ that = (OnVisibilityChangedViewModel_) previousModel; + super.bind(object); + + if ((title_CharSequence != null ? !title_CharSequence.equals(that.title_CharSequence) : that.title_CharSequence != null)) { + object.setTitle(title_CharSequence); + } + } + + @Override + public void handlePostBind(final OnVisibilityChangedView object, int position) { + if (onModelBoundListener_epoxyGeneratedModel != null) { + onModelBoundListener_epoxyGeneratedModel.onModelBound(this, object, position); + } + validateStateHasNotChangedSinceAdded("The model was changed during the bind call.", position); + } + + /** + * Register a listener that will be called when this model is bound to a view. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public OnVisibilityChangedViewModel_ onBind( + OnModelBoundListener listener) { + onMutation(); + this.onModelBoundListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void unbind(OnVisibilityChangedView object) { + super.unbind(object); + if (onModelUnboundListener_epoxyGeneratedModel != null) { + onModelUnboundListener_epoxyGeneratedModel.onModelUnbound(this, object); + } + } + + /** + * Register a listener that will be called when this model is unbound from a view. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public OnVisibilityChangedViewModel_ onUnbind( + OnModelUnboundListener listener) { + onMutation(); + this.onModelUnboundListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void onVisibilityStateChanged(int visibilityState, final OnVisibilityChangedView object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + super.onVisibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + */ + public OnVisibilityChangedViewModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final OnVisibilityChangedView object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + object.onVisibilityChanged1(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + object.onVisibilityChanged2(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + */ + public OnVisibilityChangedViewModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + + /** + * Required. + * + * @see OnVisibilityChangedView#setTitle(CharSequence) + */ + public OnVisibilityChangedViewModel_ title(@NonNull CharSequence title) { + if (title == null) { + throw new IllegalArgumentException("title cannot be null"); + } + assignedAttributes_epoxyGeneratedModel.set(0); + onMutation(); + this.title_CharSequence = title; + return this; + } + + @NonNull + public CharSequence title() { + return title_CharSequence; + } + + @Override + public OnVisibilityChangedViewModel_ id(long id) { + super.id(id); + return this; + } + + @Override + public OnVisibilityChangedViewModel_ id(@Nullable Number... arg0) { + super.id(arg0); + return this; + } + + @Override + public OnVisibilityChangedViewModel_ id(long id1, long id2) { + super.id(id1, id2); + return this; + } + + @Override + public OnVisibilityChangedViewModel_ id(@Nullable CharSequence arg0) { + super.id(arg0); + return this; + } + + @Override + public OnVisibilityChangedViewModel_ id(@Nullable CharSequence arg0, + @Nullable CharSequence... arg1) { + super.id(arg0, arg1); + return this; + } + + @Override + public OnVisibilityChangedViewModel_ id(@Nullable CharSequence arg0, long arg1) { + super.id(arg0, arg1); + return this; + } + + @Override + public OnVisibilityChangedViewModel_ layout(@LayoutRes int arg0) { + super.layout(arg0); + return this; + } + + @Override + public OnVisibilityChangedViewModel_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + super.spanSizeOverride(arg0); + return this; + } + + @Override + public OnVisibilityChangedViewModel_ show() { + super.show(); + return this; + } + + @Override + public OnVisibilityChangedViewModel_ show(boolean show) { + super.show(show); + return this; + } + + @Override + public OnVisibilityChangedViewModel_ hide() { + super.hide(); + return this; + } + + @Override + @LayoutRes + protected int getDefaultLayout() { + return 1; + } + + @Override + public OnVisibilityChangedViewModel_ reset() { + onModelBoundListener_epoxyGeneratedModel = null; + onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; + assignedAttributes_epoxyGeneratedModel.clear(); + this.title_CharSequence = null; + super.reset(); + return this; + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (!(o instanceof OnVisibilityChangedViewModel_)) { + return false; + } + if (!super.equals(o)) { + return false; + } + OnVisibilityChangedViewModel_ that = (OnVisibilityChangedViewModel_) o; + if (((onModelBoundListener_epoxyGeneratedModel == null) != (that.onModelBoundListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if ((title_CharSequence != null ? !title_CharSequence.equals(that.title_CharSequence) : that.title_CharSequence != null)) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int result = super.hashCode(); + result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (title_CharSequence != null ? title_CharSequence.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "OnVisibilityChangedViewModel_{" + + "title_CharSequence=" + title_CharSequence + + "}" + super.toString(); + } + + @Override + public int getSpanSize(int totalSpanCount, int position, int itemCount) { + return totalSpanCount; + } +} \ No newline at end of file diff --git a/epoxy-processortest/src/test/resources/OnVisibilityChangedView_throwsIfInvalidParams.java b/epoxy-processortest/src/test/resources/OnVisibilityChangedView_throwsIfInvalidParams.java new file mode 100644 index 0000000000..04c8d24922 --- /dev/null +++ b/epoxy-processortest/src/test/resources/OnVisibilityChangedView_throwsIfInvalidParams.java @@ -0,0 +1,22 @@ +package com.airbnb.epoxy; + +import android.content.Context; +import android.view.View; + +@ModelView(defaultLayout = 1) +public class OnVisibilityChangedView_throwsIfInvalidParams extends View { + + public OnVisibilityChangedView_throwsIfInvalidParams(Context context) { + super(context); + } + + @ModelProp + public void setTitle(CharSequence title) { + + } + + @OnVisibilityChanged + public void onVisibilityChanged(boolean ph, boolean pw, int vh, int vw) { + + } +} \ No newline at end of file diff --git a/epoxy-processortest/src/test/resources/OnVisibilityChangedView_throwsIfNoParams.java b/epoxy-processortest/src/test/resources/OnVisibilityChangedView_throwsIfNoParams.java new file mode 100644 index 0000000000..a593925900 --- /dev/null +++ b/epoxy-processortest/src/test/resources/OnVisibilityChangedView_throwsIfNoParams.java @@ -0,0 +1,22 @@ +package com.airbnb.epoxy; + +import android.content.Context; +import android.view.View; + +@ModelView(defaultLayout = 1) +public class OnVisibilityChangedView_throwsIfNoParams extends View { + + public OnVisibilityChangedView_throwsIfNoParams(Context context) { + super(context); + } + + @ModelProp + public void setTitle(CharSequence title) { + + } + + @OnVisibilityChanged + void onVisibilityChanged() { + + } +} \ No newline at end of file diff --git a/epoxy-processortest/src/test/resources/OnVisibilityChangedView_throwsIfPrivate.java b/epoxy-processortest/src/test/resources/OnVisibilityChangedView_throwsIfPrivate.java new file mode 100644 index 0000000000..36e6d45ee5 --- /dev/null +++ b/epoxy-processortest/src/test/resources/OnVisibilityChangedView_throwsIfPrivate.java @@ -0,0 +1,22 @@ +package com.airbnb.epoxy; + +import android.content.Context; +import android.view.View; + +@ModelView(defaultLayout = 1) +public class OnVisibilityChangedView_throwsIfPrivate extends View { + + public OnVisibilityChangedView_throwsIfPrivate(Context context) { + super(context); + } + + @ModelProp + public void setTitle(CharSequence title) { + + } + + @OnVisibilityChanged + private void onVisibilityChanged(float ph, float pw, int vh, int vw) { + + } +} \ No newline at end of file diff --git a/epoxy-processortest/src/test/resources/OnVisibilityChangedView_throwsIfStatic.java b/epoxy-processortest/src/test/resources/OnVisibilityChangedView_throwsIfStatic.java new file mode 100644 index 0000000000..d55d4e1753 --- /dev/null +++ b/epoxy-processortest/src/test/resources/OnVisibilityChangedView_throwsIfStatic.java @@ -0,0 +1,22 @@ +package com.airbnb.epoxy; + +import android.content.Context; +import android.view.View; + +@ModelView(defaultLayout = 1) +public class OnVisibilityChangedView_throwsIfStatic extends View { + + public OnVisibilityChangedView_throwsIfStatic(Context context) { + super(context); + } + + @ModelProp + public void setTitle(CharSequence title) { + + } + + @OnVisibilityChanged + static void onVisibilityChanged(float ph, float pw, int vh, int vw) { + + } +} \ No newline at end of file diff --git a/epoxy-processortest/src/test/resources/OnVisibilityStateChangedView.java b/epoxy-processortest/src/test/resources/OnVisibilityStateChangedView.java new file mode 100644 index 0000000000..1acd80369b --- /dev/null +++ b/epoxy-processortest/src/test/resources/OnVisibilityStateChangedView.java @@ -0,0 +1,27 @@ +package com.airbnb.epoxy; + +import android.content.Context; +import android.view.View; + +@ModelView(defaultLayout = 1) +public class OnVisibilityStateChangedView extends View { + + public OnVisibilityStateChangedView(Context context) { + super(context); + } + + @ModelProp + public void setTitle(CharSequence title) { + + } + + @OnVisibilityStateChanged + void onVisibilityStateChanged1(int s) { + // also testing package private works + } + + @OnVisibilityStateChanged + public void onVisibilityStateChanged2(int s) { + + } +} \ No newline at end of file diff --git a/epoxy-processortest/src/test/resources/OnVisibilityStateChangedViewModel_.java b/epoxy-processortest/src/test/resources/OnVisibilityStateChangedViewModel_.java new file mode 100644 index 0000000000..75a8fb5392 --- /dev/null +++ b/epoxy-processortest/src/test/resources/OnVisibilityStateChangedViewModel_.java @@ -0,0 +1,315 @@ +package com.airbnb.epoxy; + +import android.support.annotation.LayoutRes; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import java.lang.CharSequence; +import java.lang.IllegalArgumentException; +import java.lang.IllegalStateException; +import java.lang.Number; +import java.lang.Object; +import java.lang.Override; +import java.lang.String; +import java.util.BitSet; + +/** + * Generated file. Do not modify! */ +public class OnVisibilityStateChangedViewModel_ extends EpoxyModel implements GeneratedModel, OnVisibilityStateChangedViewModelBuilder { + private final BitSet assignedAttributes_epoxyGeneratedModel = new BitSet(1); + + private OnModelBoundListener onModelBoundListener_epoxyGeneratedModel; + + private OnModelUnboundListener onModelUnboundListener_epoxyGeneratedModel; + + private OnModelVisibilityStateChangedListener onModelVisibilityStateChangedListener_epoxyGeneratedModel; + + private OnModelVisibilityChangedListener onModelVisibilityChangedListener_epoxyGeneratedModel; + + /** + * Bitset index: 0 */ + @NonNull + private CharSequence title_CharSequence; + + @Override + public void addTo(EpoxyController controller) { + super.addTo(controller); + addWithDebugValidation(controller); + if (!assignedAttributes_epoxyGeneratedModel.get(0)) { + throw new IllegalStateException("A value is required for setTitle"); + } + } + + @Override + public void handlePreBind(final EpoxyViewHolder holder, final OnVisibilityStateChangedView object, + final int position) { + validateStateHasNotChangedSinceAdded("The model was changed between being added to the controller and being bound.", position); + } + + @Override + public void bind(final OnVisibilityStateChangedView object) { + super.bind(object); + object.setTitle(title_CharSequence); + } + + @Override + public void bind(final OnVisibilityStateChangedView object, EpoxyModel previousModel) { + if (!(previousModel instanceof OnVisibilityStateChangedViewModel_)) { + bind(object); + return; + } + OnVisibilityStateChangedViewModel_ that = (OnVisibilityStateChangedViewModel_) previousModel; + super.bind(object); + + if ((title_CharSequence != null ? !title_CharSequence.equals(that.title_CharSequence) : that.title_CharSequence != null)) { + object.setTitle(title_CharSequence); + } + } + + @Override + public void handlePostBind(final OnVisibilityStateChangedView object, int position) { + if (onModelBoundListener_epoxyGeneratedModel != null) { + onModelBoundListener_epoxyGeneratedModel.onModelBound(this, object, position); + } + validateStateHasNotChangedSinceAdded("The model was changed during the bind call.", position); + } + + /** + * Register a listener that will be called when this model is bound to a view. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public OnVisibilityStateChangedViewModel_ onBind( + OnModelBoundListener listener) { + onMutation(); + this.onModelBoundListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void unbind(OnVisibilityStateChangedView object) { + super.unbind(object); + if (onModelUnboundListener_epoxyGeneratedModel != null) { + onModelUnboundListener_epoxyGeneratedModel.onModelUnbound(this, object); + } + } + + /** + * Register a listener that will be called when this model is unbound from a view. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + *

+ * You may clear the listener by setting a null value, or by calling {@link #reset()} */ + public OnVisibilityStateChangedViewModel_ onUnbind( + OnModelUnboundListener listener) { + onMutation(); + this.onModelUnboundListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void onVisibilityStateChanged(int visibilityState, final OnVisibilityStateChangedView object) { + if (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityStateChangedListener_epoxyGeneratedModel.onVisibilityStateChanged(this, object, visibilityState); + } + object.onVisibilityStateChanged1(visibilityState); + object.onVisibilityStateChanged2(visibilityState); + super.onVisibilityStateChanged(visibilityState, object); + } + + /** + * Register a listener that will be called when this model visibility state has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + */ + public OnVisibilityStateChangedViewModel_ onVisibilityStateChanged( + OnModelVisibilityStateChangedListener listener) { + onMutation(); + this.onModelVisibilityStateChangedListener_epoxyGeneratedModel = listener; + return this; + } + + @Override + public void onVisibilityChanged(float percentVisibleHeight, float percentVisibleWidth, + int visibleHeight, int visibleWidth, final OnVisibilityStateChangedView object) { + if (onModelVisibilityChangedListener_epoxyGeneratedModel != null) { + onModelVisibilityChangedListener_epoxyGeneratedModel.onVisibilityChanged(this, object, percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth); + } + super.onVisibilityChanged(percentVisibleHeight, percentVisibleWidth, visibleHeight, visibleWidth, object); + } + + /** + * Register a listener that will be called when this model visibility has changed. + *

+ * The listener will contribute to this model's hashCode state per the {@link + * com.airbnb.epoxy.EpoxyAttribute.Option#DoNotHash} rules. + */ + public OnVisibilityStateChangedViewModel_ onVisibilityChanged( + OnModelVisibilityChangedListener listener) { + onMutation(); + this.onModelVisibilityChangedListener_epoxyGeneratedModel = listener; + return this; + } + + /** + * Required. + * + * @see OnVisibilityStateChangedView#setTitle(CharSequence) + */ + public OnVisibilityStateChangedViewModel_ title(@NonNull CharSequence title) { + if (title == null) { + throw new IllegalArgumentException("title cannot be null"); + } + assignedAttributes_epoxyGeneratedModel.set(0); + onMutation(); + this.title_CharSequence = title; + return this; + } + + @NonNull + public CharSequence title() { + return title_CharSequence; + } + + @Override + public OnVisibilityStateChangedViewModel_ id(long id) { + super.id(id); + return this; + } + + @Override + public OnVisibilityStateChangedViewModel_ id(@Nullable Number... arg0) { + super.id(arg0); + return this; + } + + @Override + public OnVisibilityStateChangedViewModel_ id(long id1, long id2) { + super.id(id1, id2); + return this; + } + + @Override + public OnVisibilityStateChangedViewModel_ id(@Nullable CharSequence arg0) { + super.id(arg0); + return this; + } + + @Override + public OnVisibilityStateChangedViewModel_ id(@Nullable CharSequence arg0, + @Nullable CharSequence... arg1) { + super.id(arg0, arg1); + return this; + } + + @Override + public OnVisibilityStateChangedViewModel_ id(@Nullable CharSequence arg0, long arg1) { + super.id(arg0, arg1); + return this; + } + + @Override + public OnVisibilityStateChangedViewModel_ layout(@LayoutRes int arg0) { + super.layout(arg0); + return this; + } + + @Override + public OnVisibilityStateChangedViewModel_ spanSizeOverride( + @Nullable EpoxyModel.SpanSizeOverrideCallback arg0) { + super.spanSizeOverride(arg0); + return this; + } + + @Override + public OnVisibilityStateChangedViewModel_ show() { + super.show(); + return this; + } + + @Override + public OnVisibilityStateChangedViewModel_ show(boolean show) { + super.show(show); + return this; + } + + @Override + public OnVisibilityStateChangedViewModel_ hide() { + super.hide(); + return this; + } + + @Override + @LayoutRes + protected int getDefaultLayout() { + return 1; + } + + @Override + public OnVisibilityStateChangedViewModel_ reset() { + onModelBoundListener_epoxyGeneratedModel = null; + onModelUnboundListener_epoxyGeneratedModel = null; + onModelVisibilityStateChangedListener_epoxyGeneratedModel = null; + onModelVisibilityChangedListener_epoxyGeneratedModel = null; + assignedAttributes_epoxyGeneratedModel.clear(); + this.title_CharSequence = null; + super.reset(); + return this; + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (!(o instanceof OnVisibilityStateChangedViewModel_)) { + return false; + } + if (!super.equals(o)) { + return false; + } + OnVisibilityStateChangedViewModel_ that = (OnVisibilityStateChangedViewModel_) o; + if (((onModelBoundListener_epoxyGeneratedModel == null) != (that.onModelBoundListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelUnboundListener_epoxyGeneratedModel == null) != (that.onModelUnboundListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityStateChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityStateChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if (((onModelVisibilityChangedListener_epoxyGeneratedModel == null) != (that.onModelVisibilityChangedListener_epoxyGeneratedModel == null))) { + return false; + } + if ((title_CharSequence != null ? !title_CharSequence.equals(that.title_CharSequence) : that.title_CharSequence != null)) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int result = super.hashCode(); + result = 31 * result + (onModelBoundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelUnboundListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityStateChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (onModelVisibilityChangedListener_epoxyGeneratedModel != null ? 1 : 0); + result = 31 * result + (title_CharSequence != null ? title_CharSequence.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "OnVisibilityStateChangedViewModel_{" + + "title_CharSequence=" + title_CharSequence + + "}" + super.toString(); + } + + @Override + public int getSpanSize(int totalSpanCount, int position, int itemCount) { + return totalSpanCount; + } +} \ No newline at end of file diff --git a/epoxy-processortest/src/test/resources/OnVisibilityStateChangedView_throwsIfInvalidParams.java b/epoxy-processortest/src/test/resources/OnVisibilityStateChangedView_throwsIfInvalidParams.java new file mode 100644 index 0000000000..7e548cb030 --- /dev/null +++ b/epoxy-processortest/src/test/resources/OnVisibilityStateChangedView_throwsIfInvalidParams.java @@ -0,0 +1,22 @@ +package com.airbnb.epoxy; + +import android.content.Context; +import android.view.View; + +@ModelView(defaultLayout = 1) +public class OnVisibilityStateChangedView_throwsIfInvalidParams extends View { + + public OnVisibilityStateChangedView_throwsIfInvalidParams(Context context) { + super(context); + } + + @ModelProp + public void setTitle(CharSequence title) { + + } + + @OnVisibilityStateChanged + public void onVisibilityStateChanged(boolean s) { + + } +} \ No newline at end of file diff --git a/epoxy-processortest/src/test/resources/OnVisibilityStateChangedView_throwsIfNoParams.java b/epoxy-processortest/src/test/resources/OnVisibilityStateChangedView_throwsIfNoParams.java new file mode 100644 index 0000000000..5178c8c533 --- /dev/null +++ b/epoxy-processortest/src/test/resources/OnVisibilityStateChangedView_throwsIfNoParams.java @@ -0,0 +1,22 @@ +package com.airbnb.epoxy; + +import android.content.Context; +import android.view.View; + +@ModelView(defaultLayout = 1) +public class OnVisibilityStateChangedView_throwsIfNoParams extends View { + + public OnVisibilityStateChangedView_throwsIfNoParams(Context context) { + super(context); + } + + @ModelProp + public void setTitle(CharSequence title) { + + } + + @OnVisibilityStateChanged + void onVisibilityStateChanged() { + + } +} \ No newline at end of file diff --git a/epoxy-processortest/src/test/resources/OnVisibilityStateChangedView_throwsIfPrivate.java b/epoxy-processortest/src/test/resources/OnVisibilityStateChangedView_throwsIfPrivate.java new file mode 100644 index 0000000000..423f35ed51 --- /dev/null +++ b/epoxy-processortest/src/test/resources/OnVisibilityStateChangedView_throwsIfPrivate.java @@ -0,0 +1,22 @@ +package com.airbnb.epoxy; + +import android.content.Context; +import android.view.View; + +@ModelView(defaultLayout = 1) +public class OnVisibilityStateChangedView_throwsIfPrivate extends View { + + public OnVisibilityStateChangedView_throwsIfPrivate(Context context) { + super(context); + } + + @ModelProp + public void setTitle(CharSequence title) { + + } + + @OnVisibilityStateChanged + private void onVisibilityStateChanged(int s) { + + } +} \ No newline at end of file diff --git a/epoxy-processortest/src/test/resources/OnVisibilityStateChangedView_throwsIfStatic.java b/epoxy-processortest/src/test/resources/OnVisibilityStateChangedView_throwsIfStatic.java new file mode 100644 index 0000000000..f778b35536 --- /dev/null +++ b/epoxy-processortest/src/test/resources/OnVisibilityStateChangedView_throwsIfStatic.java @@ -0,0 +1,22 @@ +package com.airbnb.epoxy; + +import android.content.Context; +import android.view.View; + +@ModelView(defaultLayout = 1) +public class OnVisibilityStateChangedView_throwsIfStatic extends View { + + public OnVisibilityStateChangedView_throwsIfStatic(Context context) { + super(context); + } + + @ModelProp + public void setTitle(CharSequence title) { + + } + + @OnVisibilityStateChanged + static void onVisibilityStateChanged(int s) { + + } +} \ No newline at end of file From bae5693094ceb8df6d539fec2024dc8deb77cf50 Mon Sep 17 00:00:00 2001 From: Emmanuel Boudrant Date: Fri, 12 Oct 2018 01:35:54 -0700 Subject: [PATCH 34/38] Rename `is...()` to `checkAndUpdate...()` --- .../com/airbnb/epoxy/EpoxyVisibilityItem.java | 46 ++++++++++++------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java index 89150ddd35..addcaf1558 100644 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java @@ -86,23 +86,23 @@ void reset(int newAdapterPosition) { } void handleVisible(@NonNull EpoxyViewHolder epoxyHolder, boolean detachEvent) { - if (visible && isInvisible(detachEvent)) { + if (visible && checkAndUpdateInvisible(detachEvent)) { epoxyHolder.visibilityStateChanged(VisibilityState.INVISIBLE); - } else if (!visible && isVisible()) { + } else if (!visible && checkAndUpdateVisible()) { epoxyHolder.visibilityStateChanged(VisibilityState.VISIBLE); } } void handleFocus(EpoxyViewHolder epoxyHolder, boolean detachEvent) { - if (focusedVisible && isUnfocusedVisible(detachEvent)) { + if (focusedVisible && checkAndUpdateUnfocusedVisible(detachEvent)) { epoxyHolder.visibilityStateChanged(VisibilityState.UNFOCUSED_VISIBLE); - } else if (!focusedVisible && isFocusedVisible()) { + } else if (!focusedVisible && checkAndUpdateFocusedVisible()) { epoxyHolder.visibilityStateChanged(VisibilityState.FOCUSED_VISIBLE); } } void handleFullImpressionVisible(EpoxyViewHolder epoxyHolder, boolean detachEvent) { - if (!fullyVisible && isFullImpressionVisible()) { + if (!fullyVisible && checkAndUpdateFullImpressionVisible()) { epoxyHolder .visibilityStateChanged(VisibilityState.FULL_IMPRESSION_VISIBLE); } @@ -121,12 +121,18 @@ void handleChanged(EpoxyViewHolder epoxyHolder) { } } - private boolean isVisible() { - // true when at least one pixel of the Component is visible + /** + * @return true when at least one pixel of the Component is visible + */ + private boolean checkAndUpdateVisible() { return visible = visibleSize > 0; } - private boolean isInvisible(boolean detachEvent) { + /** + * @param detachEvent true if initiated from detach event + * @return true when when the Component no longer has any pixels on the screen + */ + private boolean checkAndUpdateInvisible(boolean detachEvent) { // true when when the Component no longer has any pixels on the screen boolean invisible = visibleSize <= 0 || detachEvent; if (invisible) { @@ -135,17 +141,23 @@ private boolean isInvisible(boolean detachEvent) { return !visible; } - private boolean isFocusedVisible() { - // true when either the Component occupies at least half of the viewport, or, if the Component - // is smaller than half the viewport, when it is fully visible. + /** + * @return true when either the Component occupies at least half of the viewport, or, if the + * component is smaller than half the viewport, when it is fully visible. + */ + private boolean checkAndUpdateFocusedVisible() { return focusedVisible = sizeInScrollingDirection >= viewportSize / 2 || (visibleSize == sizeInScrollingDirection && sizeInScrollingDirection < viewportSize / 2); } - private boolean isUnfocusedVisible(boolean detachEvent) { - // true when the Component is no longer focused, i.e. it is not fully visible and does not - // occupy at least half the viewport. + /** + * + * @param detachEvent true if initiated from detach event + * @return true when the Component is no longer focused, i.e. it is not fully visible and does + * not occupy at least half the viewport. + */ + private boolean checkAndUpdateUnfocusedVisible(boolean detachEvent) { boolean unfocusedVisible = detachEvent || !(sizeInScrollingDirection >= viewportSize / 2 || ( visibleSize == sizeInScrollingDirection && sizeInScrollingDirection < viewportSize / 2)); @@ -155,8 +167,10 @@ private boolean isUnfocusedVisible(boolean detachEvent) { return !focusedVisible; } - private boolean isFullImpressionVisible() { - // true when the entire Component has passed through the viewport at some point. + /** + * @return true when the entire Component has passed through the viewport at some point. + */ + private boolean checkAndUpdateFullImpressionVisible() { return fullyVisible = visibleSize == sizeInScrollingDirection; } } From 4eda5c972ca690081dc1a971cca1fcb524a05480 Mon Sep 17 00:00:00 2001 From: Emmanuel Boudrant Date: Fri, 12 Oct 2018 01:36:07 -0700 Subject: [PATCH 35/38] Use constant --- .../com/airbnb/epoxy/EpoxyVisibilityItem.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java index addcaf1558..e52c79d1f0 100644 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java @@ -19,6 +19,8 @@ */ class EpoxyVisibilityItem { + private static final int NOT_NOTIFIED = -1; + private final Rect localVisibleRect = new Rect(); private int adapterPosition = RecyclerView.NO_POSITION; @@ -41,7 +43,7 @@ class EpoxyVisibilityItem { private boolean focusedVisible = false; /** Store last value for de-duping */ - private int lastVisibleSizeNotified = -1; + private int lastVisibleSizeNotified = NOT_NOTIFIED; /** * Update the visibility item according the current layout. @@ -82,7 +84,7 @@ void reset(int newAdapterPosition) { visible = false; focusedVisible = false; adapterPosition = newAdapterPosition; - lastVisibleSizeNotified = -1; + lastVisibleSizeNotified = NOT_NOTIFIED; } void handleVisible(@NonNull EpoxyViewHolder epoxyHolder, boolean detachEvent) { @@ -122,7 +124,7 @@ void handleChanged(EpoxyViewHolder epoxyHolder) { } /** - * @return true when at least one pixel of the Component is visible + * @return true when at least one pixel of the component is visible */ private boolean checkAndUpdateVisible() { return visible = visibleSize > 0; @@ -130,7 +132,7 @@ private boolean checkAndUpdateVisible() { /** * @param detachEvent true if initiated from detach event - * @return true when when the Component no longer has any pixels on the screen + * @return true when when the component no longer has any pixels on the screen */ private boolean checkAndUpdateInvisible(boolean detachEvent) { // true when when the Component no longer has any pixels on the screen @@ -142,7 +144,7 @@ private boolean checkAndUpdateInvisible(boolean detachEvent) { } /** - * @return true when either the Component occupies at least half of the viewport, or, if the + * @return true when either the component occupies at least half of the viewport, or, if the * component is smaller than half the viewport, when it is fully visible. */ private boolean checkAndUpdateFocusedVisible() { @@ -152,9 +154,8 @@ private boolean checkAndUpdateFocusedVisible() { } /** - * * @param detachEvent true if initiated from detach event - * @return true when the Component is no longer focused, i.e. it is not fully visible and does + * @return true when the component is no longer focused, i.e. it is not fully visible and does * not occupy at least half the viewport. */ private boolean checkAndUpdateUnfocusedVisible(boolean detachEvent) { @@ -168,7 +169,7 @@ private boolean checkAndUpdateUnfocusedVisible(boolean detachEvent) { } /** - * @return true when the entire Component has passed through the viewport at some point. + * @return true when the entire component has passed through the viewport at some point. */ private boolean checkAndUpdateFullImpressionVisible() { return fullyVisible = visibleSize == sizeInScrollingDirection; From 44ed7e5e73d6c74f47d26d083197649b2c694d93 Mon Sep 17 00:00:00 2001 From: Emmanuel Boudrant Date: Fri, 12 Oct 2018 01:42:26 -0700 Subject: [PATCH 36/38] Add basic javadoc to EpoxyModel + todo --- .../src/main/java/com/airbnb/epoxy/EpoxyModel.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModel.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModel.java index e3d39774ac..9ec8230c60 100755 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModel.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyModel.java @@ -158,9 +158,17 @@ public void bind(@NonNull T view, @NonNull EpoxyModel previouslyBoundModel) { public void unbind(@NonNull T view) { } + /** + * TODO link to the wiki + * @see OnVisibilityStateChanged annotation + */ public void onVisibilityStateChanged(@Visibility int visibilityState, @NonNull T view) { } + /** + * TODO link to the wiki + * @see OnVisibilityChanged annotation + */ public void onVisibilityChanged( @FloatRange(from = 0.0f, to = 100.0f) float percentVisibleHeight, @FloatRange(from = 0.0f, to = 100.0f) float percentVisibleWidth, From d042c68899cad131b4721665de45b3b9d749eaa6 Mon Sep 17 00:00:00 2001 From: Emmanuel Boudrant Date: Fri, 12 Oct 2018 08:44:22 -0700 Subject: [PATCH 37/38] Prepare unit test for insert/delete case (disabled as failing) --- .../airbnb/epoxy/EpoxyVisibilityTracker.java | 4 + .../epoxy/EpoxyVisibilityTrackerTest.kt | 165 ++++++++++++++++-- 2 files changed, 151 insertions(+), 18 deletions(-) diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityTracker.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityTracker.java index c8a505e78c..f2d325e322 100644 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityTracker.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityTracker.java @@ -109,6 +109,10 @@ private void processVisibilityEvents( @NonNull EpoxyViewHolder epoxyHolder, boolean vertical, boolean detachEvent ) { + + // TODO EpoxyVisibilityTrackerTest testInsertData / testInsertData are disabled as they fail as + // insert/delete not properly handled in the tracker + if (epoxyHolder.getAdapterPosition() == RecyclerView.NO_POSITION) { return; } diff --git a/epoxy-adapter/src/test/java/com/airbnb/epoxy/EpoxyVisibilityTrackerTest.kt b/epoxy-adapter/src/test/java/com/airbnb/epoxy/EpoxyVisibilityTrackerTest.kt index 09d8f26661..8db083b28e 100644 --- a/epoxy-adapter/src/test/java/com/airbnb/epoxy/EpoxyVisibilityTrackerTest.kt +++ b/epoxy-adapter/src/test/java/com/airbnb/epoxy/EpoxyVisibilityTrackerTest.kt @@ -52,10 +52,13 @@ class EpoxyVisibilityTrackerTest { private fun log(message: String) { if (DEBUG_LOG) System.out.println(message) } + + private var ids = 0 } private lateinit var activity: Activity private lateinit var recyclerView: RecyclerView + private lateinit var epoxyController: TypedEpoxyController> private var viewportHeight: Int = 0 private var itemHeight: Int = 0 @@ -131,7 +134,113 @@ class EpoxyVisibilityTrackerTest { } } + /** + * Test visibility events when loading a recycler view + */ + // @Test TODO make insert works + fun testInsertData() { + + // Build initial list + val testHelper = buildTestData(10) + val secondFullyVisibleItemBeforeInsert = testHelper[1] + val halfVisibleItemBeforeInsert = testHelper[2] + + // Insert in visible area + val position = 1 + val inserted = insertAt(testHelper, position) + + with(testHelper[position]) { + assert( + id = inserted.id, + visibleHeight = itemHeight, + percentVisibleHeight = 100.0f, + visible = true, + fullImpression = true, + visitedStates = intArrayOf( + VISIBLE, + FOCUSED_VISIBLE, + FULL_IMPRESSION_VISIBLE + ) + ) + } + + with(secondFullyVisibleItemBeforeInsert) { + assert( + visibleHeight = itemHeight / 2, + percentVisibleHeight = 50.0f, + visible = true, + fullImpression = false, + visitedStates = intArrayOf( + VISIBLE, + FOCUSED_VISIBLE, + FULL_IMPRESSION_VISIBLE + ) + ) + } + + with(halfVisibleItemBeforeInsert) { + assert( + visibleHeight = 0, + percentVisibleHeight = 0.0f, + visible = false, + fullImpression = false, + visitedStates = intArrayOf( + VISIBLE, + INVISIBLE + ) + ) + } + } + + /** + * Test visibility events when loading a recycler view + */ + // @Test TODO make delete works + fun testDeleteData() { + + // Build initial list + val testHelper = buildTestData(10) + val halfVisibleItemBeforeDelete = testHelper[2] + val firstNonVisibleItemBeforeDelete = testHelper[3] + + // Delete from visible area + val position = 1 + val deleted = deleteAt(testHelper, position) + + with(deleted) { + assert( + visibleHeight = 0, + percentVisibleHeight = 0.0f, + visible = false, + fullImpression = false, + visitedStates = ALL_STATES + ) + } + + with(halfVisibleItemBeforeDelete) { + assert( + visibleHeight = itemHeight, + percentVisibleHeight = 100.0f, + visible = true, + fullImpression = true, + visitedStates = intArrayOf( + VISIBLE, + FOCUSED_VISIBLE, + FULL_IMPRESSION_VISIBLE + ) + ) + } + with(firstNonVisibleItemBeforeDelete) { + assert( + visibleHeight = itemHeight / 2, + percentVisibleHeight = 50.0f, + visible = true, + fullImpression = false, + visitedStates = intArrayOf(VISIBLE) + ) + } + } /** * Test visibility events using scrollToPosition on the recycler view @@ -361,23 +470,26 @@ class EpoxyVisibilityTrackerTest { */ private fun buildTestData(sampleSize: Int): MutableList { // Build a test sample of 0 items - val testHelper = mutableListOf().apply { - for (index in 0 until sampleSize) add(AssertHelper()) + val helpers = mutableListOf().apply { + for (index in 0 until sampleSize) add(AssertHelper(ids++)) } + epoxyController.setData(helpers) + return helpers + } - // Plug an epoxy controller - val controller = object : TypedEpoxyController() { - override fun buildModels(data: Int?) { - data?.let { size -> - for (index in 0 until size) { - add(TestModel(index, itemHeight, testHelper[index]).id(index)) - } - } - } - } - recyclerView.adapter = controller.adapter - controller.setData(testHelper.size) - return testHelper + private fun insertAt(helpers: MutableList, position: Int): AssertHelper { + log("insert at $position") + val helper = AssertHelper(ids++) + helpers.add(position, helper) + epoxyController.setData(helpers) + return helper + } + + private fun deleteAt(helpers: MutableList, position: Int): AssertHelper { + log("delete at $position") + val helper = helpers.removeAt(position) + epoxyController.setData(helpers) + return helper } /** @@ -389,6 +501,15 @@ class EpoxyVisibilityTrackerTest { setContentView(EpoxyRecyclerView(this).apply { epoxyVisibilityTracker.attach(this) recyclerView = this + // Plug an epoxy controller + epoxyController = object : TypedEpoxyController>() { + override fun buildModels(data: List?) { + data?.forEachIndexed { index, helper -> + add(TestModel(index, itemHeight, helper).id(helper.id)) + } + } + } + recyclerView.adapter = epoxyController.adapter }) viewportHeight = recyclerView.measuredHeight itemHeight = (recyclerView.measuredHeight / VISIBLE_ITEMS).toInt() @@ -411,7 +532,7 @@ class EpoxyVisibilityTrackerTest { ) : EpoxyModelWithView() { override fun buildView(parent: ViewGroup): View { - log("buildView[$itemPosition]") + log("buildView[$itemPosition](id=${helper.id})") return TextView(parent.context).apply { // Force height layoutParams = RecyclerView.LayoutParams( @@ -428,7 +549,7 @@ class EpoxyVisibilityTrackerTest { } override fun onVisibilityStateChanged(state: Int, view: View) { - log("onVisibilityStateChanged[$itemPosition]=${state.description()}") + log("onVisibilityStateChanged[$itemPosition](id=${helper.id})=${state.description()}") helper.visitedStates.add(state) when (state) { VISIBLE, INVISIBLE -> helper.visible = state == VISIBLE @@ -442,7 +563,7 @@ class EpoxyVisibilityTrackerTest { /** * Helper for asserting visibility */ - internal class AssertHelper { + internal class AssertHelper(val id: Int) { var created = false var visitedStates = mutableListOf() @@ -453,12 +574,20 @@ class EpoxyVisibilityTrackerTest { var fullImpression = false fun assert( + id: Int? = null, visibleHeight: Int? = null, percentVisibleHeight: Float? = null, visible: Boolean? = null, fullImpression: Boolean? = null, visitedStates: IntArray? = null ) { + id?.let { + Assert.assertEquals( + "id expected $it got ${this.id}", + it, + this.id + ) + } visibleHeight?.let { // assert with 1px precision Assert.assertTrue( From e97533721724ce85275e9fc17193c95c4b17e255 Mon Sep 17 00:00:00 2001 From: Emmanuel Boudrant Date: Fri, 12 Oct 2018 08:48:53 -0700 Subject: [PATCH 38/38] remove dup comment --- .../src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java | 1 - 1 file changed, 1 deletion(-) diff --git a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java index e52c79d1f0..0bcb101ebf 100644 --- a/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java +++ b/epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityItem.java @@ -135,7 +135,6 @@ private boolean checkAndUpdateVisible() { * @return true when when the component no longer has any pixels on the screen */ private boolean checkAndUpdateInvisible(boolean detachEvent) { - // true when when the Component no longer has any pixels on the screen boolean invisible = visibleSize <= 0 || detachEvent; if (invisible) { visible = false;