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

一个在API 19中因addOnRebindCallback出现的BUG #209

Open
lx5288 opened this issue Dec 4, 2020 · 0 comments
Open

一个在API 19中因addOnRebindCallback出现的BUG #209

lx5288 opened this issue Dec 4, 2020 · 0 comments

Comments

@lx5288
Copy link

lx5288 commented Dec 4, 2020

使用BindingRecyclerViewAdapter
当Item 的TextView 设置以下属性时,在API 19的系统中,会出现TextView文字不显示的问题(在比较新的API设备中显示正常)

android:ellipsize="marquee"
android:singleLine="true"

首屏内容正常,滑动后部分Item不显示文字(如每屏展示3个Item,每间隔3个Item就会有1-2个Item不显示文字)
注释addOnRebindCallback后正常

    public final ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int layoutId) {
        if (inflater == null) {
            inflater = LayoutInflater.from(viewGroup.getContext());
        }
        ViewDataBinding binding = onCreateBinding(inflater, layoutId, viewGroup);
        final ViewHolder holder = onCreateViewHolder(binding);
        //注释后正常
       /* binding.addOnRebindCallback(new OnRebindCallback() {
            @Override
            public boolean onPreBind(ViewDataBinding binding) {
                return recyclerView != null && recyclerView.isComputingLayout();
            }

            @Override
            public void onCanceled(ViewDataBinding binding) {
            if (recyclerView == null || recyclerView.isComputingLayout()) {
                    MyLog.i("onCanceled recyclerView is null or isComputingLayout");
                    return;
                }
                int position = holder.getAdapterPosition();
                if (position != RecyclerView.NO_POSITION) {
                    try {
                        notifyItemChanged(position, DATA_INVALIDATION);
                    } catch (IllegalStateException e) {
                        // noop - this shouldn't be happening
                    }
                }
            }
        });*/
        return holder;
    }

是否有其他更好的处理方式呢?

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