@@ -108,8 +108,12 @@ public void onBindViewHolder(EpoxyViewHolder holder, int position) {
108108
109109 @ Override
110110 public void onBindViewHolder (EpoxyViewHolder holder , int position , List <Object > payloads ) {
111- executeWhenInflated (holder ,
112- () -> onBindViewHolderInternal (holder , holder .getBindingAdapterPosition (), payloads ));
111+ if (holder .itemView instanceof AsyncInflatedView ) {
112+ ((AsyncInflatedView )holder .itemView ).executeWhenInflated (() ->
113+ onBindViewHolderInternal (holder , holder .getBindingAdapterPosition (), payloads ));
114+ } else {
115+ onBindViewHolderInternal (holder , holder .getBindingAdapterPosition (), payloads );
116+ }
113117 }
114118
115119 private void onBindViewHolderInternal (EpoxyViewHolder holder , int position , List <Object > payloads ) {
@@ -214,19 +218,27 @@ public boolean onFailedToRecycleView(EpoxyViewHolder holder) {
214218 @ CallSuper
215219 @ Override
216220 public void onViewAttachedToWindow (EpoxyViewHolder holder ) {
217- executeWhenInflated (holder ,
218- () ->
219- //noinspection unchecked,rawtypes
220- ((EpoxyModel ) holder .getModel ()).onViewAttachedToWindow (holder .objectToBind ()));
221+ if (holder .itemView instanceof AsyncInflatedView ) {
222+ ((AsyncInflatedView )holder .itemView ).executeWhenInflated (() ->
223+ //noinspection unchecked,rawtypes
224+ ((EpoxyModel ) holder .getModel ()).onViewAttachedToWindow (holder .objectToBind ()));
225+ } else {
226+ //noinspection unchecked,rawtypes
227+ ((EpoxyModel ) holder .getModel ()).onViewAttachedToWindow (holder .objectToBind ());
228+ }
221229 }
222230
223231 @ CallSuper
224232 @ Override
225233 public void onViewDetachedFromWindow (EpoxyViewHolder holder ) {
226- executeWhenInflated (holder ,
227- () ->
228- //noinspection unchecked,rawtypes
229- ((EpoxyModel ) holder .getModel ()).onViewDetachedFromWindow (holder .objectToBind ()));
234+ if (holder .itemView instanceof AsyncInflatedView ) {
235+ ((AsyncInflatedView )holder .itemView ).executeWhenInflated (() ->
236+ //noinspection unchecked,rawtypes
237+ ((EpoxyModel ) holder .getModel ()).onViewDetachedFromWindow (holder .objectToBind ()));
238+ } else {
239+ //noinspection unchecked,rawtypes
240+ ((EpoxyModel ) holder .getModel ()).onViewDetachedFromWindow (holder .objectToBind ());
241+ }
230242 }
231243
232244 public void onSaveInstanceState (Bundle outState ) {
@@ -348,12 +360,4 @@ public boolean isStickyHeader(int position) {
348360 }
349361
350362 //endregion
351-
352- protected void executeWhenInflated (EpoxyViewHolder holder , Runnable runnable ) {
353- if (holder .itemView instanceof AsyncInflatedView ) {
354- ((AsyncInflatedView )holder .itemView ).executeWhenInflated (runnable );
355- } else {
356- runnable .run ();
357- }
358- }
359363}
0 commit comments