使用 RowsFragment 时,ObjectAdapter.setPresenterSelector 有什么作用吗?

When using RowsFragment, does ObjectAdapter.setPresenterSelector do anything?

我正在使用 RowsFragment with an ObjectAdapter and I spotted the method ObjectAdapter.setPresenterSelector. However, I've already set my PresenterSelector using RowsFragment.setPresenterSelector,所以我不确定 ObjectAdapter.setPresenterSelector 的作用。它有什么作用吗?

好的,我查了一下,答案在ItemBridgeAdapter的源代码中。查找项目类型的方法包含以下行:

PresenterSelector presenterSelector = mPresenterSelector != null ? mPresenterSelector : mAdapter.getPresenterSelector();

其中 mPresenterSelector 是由 RowsFragment.setPresenterSelector 设置的,mAdapter 是由 ObjectAdapter 设置的。所以看起来他们首先查看你所谓的 RowsFragment.setPresenterSelector ,如果那是空的,他们然后尝试使用 ObjectAdapterPresenterSelector.