由于滚动smoothScrollToPositionFromTop和adapter的notifyDataSetChanged冲突,需要加 handler 延迟刷新,否则会导致滚动位置不准
/**
* 列表滚动置顶
* @param currPage 实际下标
* @param pos 用于上一条 翻上一页置顶的假下标,实际下标另外高亮
* @param isClearOffset 是否置顶
*/
private void rightScrollTop(int pos, boolean isClearOffset) {
mListPageTv.setText((currPage + 1) + "/" + fullPages);
mPresenter.getMainHandle().postDelayed(new Runnable() {
@Override
public void run() {
if (isClearOffset) {
int index = pos >= 0 ? pos : currPos;
mGridView.smoothScrollToPositionFromTop(index, 200);
mGridView.setSelection(index);
} else {
mGridView.smoothScrollToPosition(currPos);
}
}
}, mDelayTime - 300);
mPresenter.getMainHandle().postDelayed(new Runnable() {
@Override
public void run() {
mGridAdapter.setCurrPos(currPos);
}
}, mDelayTime);
}
public Handler getMainHandle() {
if (mMainHandler == null) {
mMainHandler = new Handler(Looper.getMainLooper());
}
return mMainHandler;
}

