Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MultiTypeAdapter line 98-122 onBindViewHolder() #4

Open
longalei opened this issue May 29, 2019 · 0 comments
Open

MultiTypeAdapter line 98-122 onBindViewHolder() #4

longalei opened this issue May 29, 2019 · 0 comments

Comments

@longalei
Copy link

longalei commented May 29, 2019

    public final void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        onBindViewHolder(holder, position, Collections.emptyList());
    }

    @Override
    public final void onBindViewHolder(@NonNull ViewHolder holder, int position, @NonNull List<Object> payloads) {
        viewBinder.onBindViewHolder(holder, items.get(position), payloads);

        if (onItemClickListener != null) {
            holder.itemView.setOnClickListener(v -> {
                if (onItemClickListener != null) {
                    onItemClickListener.onItemClick(items.get(position));
                }
            });
        }

        if (onItemLongClickListener != null) {
            holder.itemView.setOnLongClickListener(v -> {
                if (onItemLongClickListener != null) {
                    return onItemLongClickListener.onItemLongClick(items.get(position));
                }
                return false;
            });
        }
    }

onBindViewHolder(@nonnull ViewHolder holder, int position, @nonnull List payloads)内才会调用 onBindViewHolder(@nonnull ViewHolder holder, int position)。现在重写onBindViewHolder(@nonnull ViewHolder holder, int position, @nonnull List payloads),那么MultiTypeAdapter onBindViewHolder(@nonnull ViewHolder holder, int position)的意思是?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant