0

How this crash is possible? It works 99% of the time and sometimes there is this crash...

Caused by java.lang.NullPointerException
Attempt to invoke virtual method 'void android.view.View.clearAnimation()' on a null object reference
com.XXX.VerticalPagerFragment.onViewPagerTouchDown

private void onViewPagerTouchDown() {
        if (isAdded()) {
            mPageIndicatorLayout.clearAnimation(); <<< CRASH
            ...
        }
    }

Object mPageIndicatorLayout is mapped with butterknife:

@BindView(R2.id.page_indicator_layout)
    View mPageIndicatorLayout;

This above method is called from this viewpager listener:

@Override
                public void onPageScrollStateChanged(int state) {
                    super.onPageScrollStateChanged(state);
                    if (isAdded()) {
                        if (state != ViewPager2.SCROLL_STATE_IDLE) {
                            onViewPagerTouchDown(); <<< HERE

                        } else {
                            onViewPagerTouchUp();
                        }
                    }
                }

I can't absolutely understand how this crash can occur in this context? Have you got an ideas?

Thank you very much!

theduck
  • 2,589
  • 13
  • 17
  • 23
anthony
  • 7,653
  • 8
  • 49
  • 101

0 Answers0