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

滑动右侧索引出现异常int android.view.View.getTop() #71

Closed
bengyuan25 opened this issue Jun 8, 2017 · 2 comments
Closed

滑动右侧索引出现异常int android.view.View.getTop() #71

bengyuan25 opened this issue Jun 8, 2017 · 2 comments

Comments

@bengyuan25
Copy link

java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getTop()' on a null object reference

@bengyuan25
Copy link
Author

bengyuan25 commented Jul 3, 2017

自己找到了原因, 因为linearlayoutmanager中没有找到指定的索引, 所以导致view获取到的是null.是一个bug, 自己修改了源码非空验证一下就可以了.
贴上修改的源码, fork功能不会用,,, 修改完成后直接导入到项目的lib中, 给大家少走一些弯路吧.
在IndexableLayout.class下
// LinearLayoutManager
if (mLinearLayoutManager != null) {
if (firstItemPosition + 1 < list.size()) {
EntityWrapper nextWrapper = list.get(firstItemPosition + 1);
View nextTitleView = mLinearLayoutManager.findViewByPosition(firstItemPosition + 1);
# if (nextTitleView == null) return;
if (nextWrapper.getItemType() == EntityWrapper.TYPE_TITLE) {
if (nextTitleView.getTop() <= mStickyViewHolder.itemView.getHeight() && wrapperTitle != null) {
mStickyViewHolder.itemView.setTranslationY(nextTitleView.getTop() - mStickyViewHolder.itemView.getHeight());
}
if (INVISIBLE == nextTitleView.getVisibility()) {
//特殊情况:手指向下滑动的时候,需要及时把成为第二个可见View的TitleView设置Visible,
// 这样才能配合StickyView制造两个TitleView切换的动画。
nextTitleView.setVisibility(VISIBLE);
}
} else if (mStickyViewHolder.itemView.getTranslationY() != 0) {
mStickyViewHolder.itemView.setTranslationY(0);
}
}
}

@YoKeyword
Copy link
Owner

感谢哈, v1.2.4已经添加,下次可以直接提PR 🍺 :)

YoKeyword added a commit that referenced this issue Jul 5, 2017
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

2 participants