Skip to content

Commit

Permalink
Merge pull request #157 from evant/lifecycle-fix
Browse files Browse the repository at this point in the history
Fix issues with setting the lifecycle owner before a bind.
  • Loading branch information
evant authored Feb 21, 2019
2 parents 9d54ebc + b17f13a commit 1657869
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ public ViewDataBinding onCreateBinding(@NonNull LayoutInflater inflater, @Layout

@Override
public void onBindBinding(@NonNull ViewDataBinding binding, int variableId, @LayoutRes int layoutRes, int position, T item) {
if (itemBinding.bind(binding, item)) {
boolean bound = itemBinding.bind(binding, item);
binding.setLifecycleOwner(lifecycleOwner);
if (bound) {
binding.executePendingBindings();
}
}
Expand Down Expand Up @@ -166,7 +168,6 @@ public final View getView(int position, @Nullable View convertView, @NonNull Vie
}

View view = binding.getRoot();
binding.setLifecycleOwner(lifecycleOwner);

T item = items.get(position);
onBindBinding(binding, itemBinding.variableId(), layoutRes, position, item);
Expand Down Expand Up @@ -194,7 +195,6 @@ public final View getDropDownView(int position, @Nullable View convertView, @Non
}

View view = binding.getRoot();
binding.setLifecycleOwner(lifecycleOwner);

T item = items.get(position);
onBindBinding(binding, itemBinding.variableId(), layoutRes, position, item);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ public ViewDataBinding onCreateBinding(@NonNull LayoutInflater inflater, @Layout

@Override
public void onBindBinding(@NonNull ViewDataBinding binding, int variableId, @LayoutRes int layoutRes, int position, T item) {
if (itemBinding.bind(binding, item)) {
boolean bound = itemBinding.bind(binding, item);
binding.setLifecycleOwner(lifecycleOwner);
if (bound) {
binding.executePendingBindings();
}
}
Expand Down

0 comments on commit 1657869

Please sign in to comment.