I have 2 fragments in a tab layout, switching between them quickly causes the views to be returned as null, using ViewBinding. Is this because of the delay to build the FragmentXBinding class?
Usage Example:
chatadapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
@Override
public void onItemRangeInserted(int positionStart, int itemCount) {
binding.chatRecyclerView.smoothScrollToPosition(0);
}
});
Error:
java.lang.NullPointerException: Attempt to read from field 'androidx.recyclerview.widget.RecyclerView com.iku.databinding.FragmentChatBinding.chatRecyclerView' on a null object reference