vejei / ViewPagerIndicator

The indicator for Android ViewPager2 and ViewPager.
MIT License
12 stars 4 forks source link

null pointer exceptions when the view is not visiable on screen #4

Open michaelsam94 opened 4 years ago

michaelsam94 commented 4 years ago

there is null point exception thrown when fragment which contain the viewpager and indicator not visible on screen. Here is stacktrace. java.lang.NullPointerException: Attempt to invoke virtual method 'int io.github.vejei.viewpagerindicator.animation.AnimationValue$SlideAnimationValue.getCoordinateX()' on a null object reference at io.github.vejei.viewpagerindicator.painter.RectPainter$SlideAnimationPainter.draw(RectPainter.java:101) at io.github.vejei.viewpagerindicator.indicator.RectIndicator.onDraw(RectIndicator.java:175) at android.view.View.draw(View.java:16270) at android.view.View.updateDisplayListIfDirty(View.java:15267) at android.view.View.draw(View.java:16040) at android.view.ViewGroup.drawChild(ViewGroup.java:3610) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3400) at androidx.constraintlayout.widget.ConstraintLayout.dispatchDraw(ConstraintLayout.java:1882) at android.view.View.updateDisplayListIfDirty(View.java:15262) at android.view.View.draw(View.java:16040) at android.view.ViewGroup.drawChild(ViewGroup.java:3610) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3400) at androidx.constraintlayout.widget.ConstraintLayout.dispatchDraw(ConstraintLayout.java:1882) at android.view.View.updateDisplayListIfDirty(View.java:15262) at android.view.View.draw(View.java:16040) at android.view.ViewGroup.drawChild(ViewGroup.java:3610) at androidx.fragment.app.FragmentContainerView.drawChild(FragmentContainerView.java:235) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3400) at androidx.fragment.app.FragmentContainerView.dispatchDraw(FragmentContainerView.java:223) at android.view.View.updateDisplayListIfDirty(View.java:15262) at android.view.View.draw(View.java:16040) at android.view.ViewGroup.drawChild(ViewGroup.java:3610) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3400) at androidx.constraintlayout.widget.ConstraintLayout.dispatchDraw(ConstraintLayout.java:1882) at android.view.View.updateDisplayListIfDirty(View.java:15262) at android.view.View.draw(View.java:16040) at android.view.ViewGroup.drawChild(ViewGroup.java:3610) at androidx.drawerlayout.widget.DrawerLayout.drawChild(DrawerLayout.java:1478) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3400) at android.view.View.updateDisplayListIfDirty(View.java:15262) at android.view.View.draw(View.java:16040) at android.view.ViewGroup.drawChild(ViewGroup.java:3610) at androidx.fragment.app.FragmentContainerView.drawChild(FragmentContainerView.java:235) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3400) at androidx.fragment.app.FragmentContainerView.dispatchDraw(FragmentContainerView.java:223) at android.view.View.updateDisplayListIfDirty(View.java:15262) at android.view.View.draw(View.java:16040) at android.view.ViewGroup.drawChild(ViewGroup.java:3610) at androidx.fragment.app.FragmentContainerView.drawChild(FragmentContainerView.java:235) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3400) at androidx.fragment.app.FragmentContainerView.dispatchDraw(FragmentContainerView.java:223) at android.view.View.updateDisplayListIfDirty(View.java:15262) at android.view.View.draw(View.java:16040) at android.view.ViewGroup.drawChild(ViewGroup.java:3610) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3400) at androidx.constraintlayout.widget.ConstraintLayout.dispatchDraw(ConstraintLayout.java:1882) at android.view.View.updateDisplayListIfDirty(View.java:15262) at android.view.View.draw(View.java:16040) at android.view.ViewGroup.drawChild(ViewGroup.java:3610) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3400) at android.view.View.updateDisplayListIfDirty(View.java:15262) at android.view.View.draw(View.java:16040) at android.view.ViewGroup.drawChild(ViewGroup.java:3610) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3400) at android.view.View.updateDisplayListIfDirty(View.java:15262) at android.view.View.draw(View.java:16040) at android.view.ViewGroup.drawChild(ViewGroup.java:3610) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3400) at android.view.View.updateDisplayListIfDirty(View.

michaelsam94 commented 4 years ago

also there is error in rendering layout on layout editor tell that is there is null pointer exception in draw method of SlideAnimationPainter class in line 101 which is drawing the rectangle on screen canvas.drawRoundRect(value.getCoordinateX(), coordinateY, value.getCoordinateX() + width, coordinateY + height, cornerRadius, cornerRadius, paint ); the value object which throw nullpointer exception when calling getCoordinateX() method

michaelsam94 commented 4 years ago

this issue happens when I put the same layout which contain indicator and viewpager in two fragments and try to add and remove those two fragment the first fragment is behave normal and when I remove the first fragment and add the second fragment the issue appears