florent37 / DiagonalLayout

With Diagonal Layout explore new styles and approaches on material design
Apache License 2.0
2.56k stars 321 forks source link

NullpointerException on dispatchDraw() #25

Closed xbeebx closed 6 years ago

xbeebx commented 6 years ago

Hi there, im getting a NPE on dispatchDraw:

java.lang.NullPointerException: Attempt to read from field 'boolean android.graphics.Path.isSimplePath' on a null object reference
    at android.view.GLES20Canvas.drawPath(GLES20Canvas.java:796)
    at com.github.florent37.diagonallayout.DiagonalLayout.dispatchDraw(DiagonalLayout.java:293)
    at android.view.View.draw(View.java:15234)
    at android.widget.FrameLayout.draw(FrameLayout.java:598)
    at android.view.View.updateDisplayListIfDirty(View.java:14167)
    at android.view.View.getDisplayList(View.java:14189)
    at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3389)
    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3368)
    at android.view.View.updateDisplayListIfDirty(View.java:14127)
    at android.view.View.getDisplayList(View.java:14189)
    at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3389)
    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3368)
    at android.view.View.updateDisplayListIfDirty(View.java:14127)
    at android.view.View.getDisplayList(View.java:14189)
    at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3389)
    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3368)
    at android.view.View.updateDisplayListIfDirty(View.java:14127)
    at android.view.View.getDisplayList(View.java:14189)
    at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3389)
    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3368)
    at android.view.View.updateDisplayListIfDirty(View.java:14127)
    at android.view.View.getDisplayList(View.java:14189)
    at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3389)
    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3368)
    at android.view.View.updateDisplayListIfDirty(View.java:14127)
    at android.view.View.getDisplayList(View.java:14189)
    at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3389)
    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3368)
    at android.view.View.updateDisplayListIfDirty(View.java:14127)
    at android.view.View.getDisplayList(View.java:14189)
    at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3389)
    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3368)
    at android.view.View.updateDisplayListIfDirty(View.java:14127)
    at android.view.View.getDisplayList(View.java:14189)
    at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3389)
    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3368)
    at android.view.View.updateDisplayListIfDirty(View.java:14127)
    at android.view.View.getDisplayList(View.java:14189)
    at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:289)
    at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:318)
    at android.view.ViewRootImpl.draw(ViewRootImpl.java:2530)
    at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2352)
    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1982)
    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1061)
    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5885)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
    at android.view.Choreographer.doCallbacks(Choreographer.java:580)
    at android.view.Choreographer.doFrame(Choreographer.java:550)
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:135)
    at android.app.ActivityThread.main(ActivityThread.java:5254)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

Android Version: API 22 Lib Version: 1.0.7

It does not happen always.

Here's the way I include the diagonal layout:

        <com.github.florent37.diagonallayout.DiagonalLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:diagonal_angle="10"
            app:diagonal_direction="left"
            app:diagonal_position="bottom">

            <ImageView
                android:id="@+id/movie_details_poster_header"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:adjustViewBounds="true"
                android:scaleType="centerCrop" />
        </com.github.florent37.diagonallayout.DiagonalLayout>

I'm loading an image from an API via AsyncTask (Size is very often 1920x1080).

Please tell my why is this Exception thrown sometimes? How can I fix it?

KieuQ commented 6 years ago

seems like @florent37 is not watching this repo anymore, what I did to fix this is placing some good old try catch by extending the DiagonalLayout class and overriding dispatchDraw() method then placing the try catch in there.

florent37 commented 6 years ago

I updated diagonal layout recently, can you try with

compile 'com.github.florent37:diagonallayout:1.0.9'