florent37 / ShapeOfView

Give a custom shape to any android view, Material Design 2 ready
Apache License 2.0
3.13k stars 398 forks source link

Crash on use different ShapeOfView nested #18

Closed alexandre-roulin closed 6 years ago

alexandre-roulin commented 6 years ago

Crash without any use of the widget or view.


<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <com.github.florent37.shapeofview.shapes.RoundRectView
        android:layout_width="match_parent"
        android:layout_height="100dp"
        app:shape_roundRect_bottomLeftRadius="15dp"
        app:shape_roundRect_bottomRightRadius="15dp"
        app:shape_roundRect_topLeftRadius="15dp"
        app:shape_roundRect_topRightRadius="15dp">

        <android.support.constraint.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/deep_dark_blue">

            <com.github.florent37.shapeofview.shapes.DiagonalView
                android:id="@+id/diagonal_view"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                app:layout_constraintEnd_toStartOf="@id/guideline_50"
                app:layout_constraintStart_toStartOf="parent"
                app:shape_diagonal_angle="30"
                app:shape_diagonal_direction="right"
                app:shape_diagonal_position="right">

                <ImageView
                    android:id="@+id/img_flyer_list"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:scaleType="centerCrop"
                    tools:src="@drawable/club_event_flyer_djoon" />
            </com.github.florent37.shapeofview.shapes.DiagonalView>

            <TextView
                android:id="@+id/tv_cell_title"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginStart="12dp"
                android:layout_marginTop="4dp"
                android:gravity="start"
                android:singleLine="true"
                android:textAlignment="gravity"
                android:textColor="@color/white"
                android:textSize="18sp"
                android:textStyle="bold"
                app:layout_constraintStart_toEndOf="@id/guideline_35"
                app:layout_constraintTop_toTopOf="parent"
                tools:text="Titre Event" />

            <TextView
                android:id="@+id/tv_cell_description"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginTop="8dp"
                android:ellipsize="marquee"
                android:focusable="true"
                android:focusableInTouchMode="true"
                android:gravity="center"
                android:marqueeRepeatLimit="marquee_forever"
                android:scrollHorizontally="true"
                android:singleLine="true"
                android:textColor="@color/white"
                app:layout_constraintEnd_toStartOf="@id/guideline_90"
                app:layout_constraintStart_toEndOf="@id/guideline_45"
                app:layout_constraintTop_toBottomOf="@+id/tv_cell_title"
                tools:text="DescriptionDescriptionDescriptionDescription" />

            <TextView
                android:id="@+id/tv_rotate"
                android:layout_width="200dp"
                android:layout_height="wrap_content"
                android:text="Generaliste"
                android:textColor="@color/white"/>

            <android.support.constraint.Guideline
                android:id="@+id/guideline_45"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                app:layout_constraintGuide_percent="0.45" />

            <android.support.constraint.Guideline
                android:id="@+id/guideline_35"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                app:layout_constraintGuide_percent="0.35" />

            <android.support.constraint.Guideline
                android:id="@+id/guideline_50"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                app:layout_constraintGuide_percent="0.5" />

            <android.support.constraint.Guideline
                android:id="@+id/guideline_90"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                app:layout_constraintGuide_percent="0.90" />

        </android.support.constraint.ConstraintLayout>
    </com.github.florent37.shapeofview.shapes.RoundRectView>
</android.support.constraint.ConstraintLayout>`

 `05-30 02:16:55.005 21700-21700/com.itexus.kraze E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.itexus.kraze, PID: 21700
    java.lang.RuntimeException: Canvas: trying to use a recycled bitmap android.graphics.Bitmap@2945586
        at android.graphics.BaseCanvas.throwIfCannotDraw(BaseCanvas.java:62)
        at android.view.DisplayListCanvas.throwIfCannotDraw(DisplayListCanvas.java:226)
        at android.view.RecordingCanvas.drawBitmap(RecordingCanvas.java:79)
        at com.github.florent37.shapeofview.ShapeOfView.dispatchDraw(ShapeOfView.java:121)
        at android.view.View.draw(View.java:20208)
        at android.view.View.updateDisplayListIfDirty(View.java:19080)
        at android.view.View.draw(View.java:19933)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4333)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112)
        at android.support.constraint.ConstraintLayout.dispatchDraw(ConstraintLayout.java:1963)
        at android.view.View.draw(View.java:20208)
        at android.view.View.updateDisplayListIfDirty(View.java:19080)
        at android.view.View.draw(View.java:19933)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4333)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112)
        at com.github.florent37.shapeofview.ShapeOfView.dispatchDraw(ShapeOfView.java:115)
        at com.github.florent37.shapeofview.shapes.RoundRectView.dispatchDraw(RoundRectView.java:96)
        at android.view.View.draw(View.java:20208)
        at android.view.View.updateDisplayListIfDirty(View.java:19080)
        at android.view.View.draw(View.java:19933)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4333)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112)
        at android.support.constraint.ConstraintLayout.dispatchDraw(ConstraintLayout.java:1963)
        at android.view.View.updateDisplayListIfDirty(View.java:19071)
        at android.view.View.draw(View.java:19933)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4333)
        at android.support.v7.widget.RecyclerView.drawChild(RecyclerView.java:4703)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112)
        at android.view.View.draw(View.java:20208)
        at android.support.v7.widget.RecyclerView.draw(RecyclerView.java:4107)
        at android.view.View.updateDisplayListIfDirty(View.java:19080)
        at android.view.View.draw(View.java:19933)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4333)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112)
        at android.support.constraint.ConstraintLayout.dispatchDraw(ConstraintLayout.java:1963)
        at android.view.View.draw(View.java:20208)
        at android.view.View.updateDisplayListIfDirty(View.java:19080)
        at android.view.View.draw(View.java:19933)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4333)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112)
        at android.view.View.updateDisplayListIfDirty(View.java:19071)
        at android.view.View.draw(View.java:19933)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4333)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112)
        at android.view.View.updateDisplayListIfDirty(View.java:19071)
        at android.view.View.draw(View.java:19933)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4333)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112)
        at android.view.View.updateDisplayListIfDirty(View.java:19071)
        at android.view.View.draw(View.java:19933)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4333)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112)
        at android.view.View.updateDisplayListIfDirty(View.java:19071)
        at android.view.View.draw(View.java:19933)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4333)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112)
        at android.view.View.updateDisplayListIfDirty(View.java:19071)
        at android.view.View.draw(View.java:19933)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4333)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112)
        at android.view.View.draw(View.java:20208)
        at com.android.internal.policy.DecorView.draw(DecorView.java:784)
        at android.view.View.updateDisplayListIfDirty(View.java:19080)
05-30 02:16:55.009 21700-21700/com.itexus.kraze E/AndroidRuntime:     at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:685)
        at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:691)
        at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:799)
        at android.view.ViewRootImpl.draw(ViewRootImpl.java:3259)
        at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:3075)
        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2455)
        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1443)
        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7125)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:935)
        at android.view.Choreographer.doCallbacks(Choreographer.java:747)
        at android.view.Choreographer.doFrame(Choreographer.java:682)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:921)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6649)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:826)```
florent37 commented 6 years ago

I found !

use android:src and android:text instead of tools:src and tools:text

florent37 commented 6 years ago

can you try ?