photo-editor-android icon indicating copy to clipboard operation
photo-editor-android copied to clipboard

App crashes when the user clicks on "Clear All" button in the photo editor screen.

Open debabrata-rana opened this issue 6 years ago • 2 comments

Hi,

I've observed the following crash in the sample app. It crashes when the user clicks the "Clear All" button in the photo editor screen.

Steps to reproduce:

  1. In the sample app, click the "Choose From Camera" button.
  2. Capture a photo.
  3. In the photo editor screen, click the "Clear All" button without modifying the photo.
  4. The app crashes throwing NullPointerException.

Exception log: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.graphics.Canvas.drawColor(int, android.graphics.PorterDuff$Mode)' on a null object reference at com.ahmedadeltito.photoeditorsdk.BrushDrawingView.clearAll(BrushDrawingView.java:121) at com.ahmedadeltito.photoeditorsdk.PhotoEditorSDK.clearAllViews(PhotoEditorSDK.java:184) at com.ahmedadeltito.photoeditor.PhotoEditorActivity.clearAllViews(PhotoEditorActivity.java:216) at com.ahmedadeltito.photoeditor.PhotoEditorActivity.onClick(PhotoEditorActivity.java:340) at android.view.View.performClick(View.java:5198) at android.view.View$PerformClick.run(View.java:21147) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

It would be great if this issue is fixed quickly as I'm planning to integrate this lib.

Thanks & regards, Debu

debabrata-rana avatar Nov 15 '18 07:11 debabrata-rana

Observed by me also. @debabrata-rana How to fix this problem?

sreekanth100khere avatar Mar 26 '19 10:03 sreekanth100khere

I fixed it by adding one line if(drawCanvas!=null)

So now the method looks like below


 void clearAll() {
        if(drawCanvas!=null)
        drawCanvas.drawColor(0, PorterDuff.Mode.CLEAR);
        invalidate();
    }

sreekanth100khere avatar Mar 26 '19 10:03 sreekanth100khere