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

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

Open
michaelsam94 opened this issue Sep 21, 2020 · 2 comments
Open
Labels
bug Something isn't working

Comments

@michaelsam94
Copy link

michaelsam94 commented Sep 21, 2020

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
Copy link
Author

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
Copy link
Author

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

@vejei vejei added the bug Something isn't working label Sep 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants