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

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

Open
debabrata-rana opened this issue Nov 15, 2018 · 2 comments

Comments

@debabrata-rana
Copy link

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

@sreekanth100khere
Copy link

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

@sreekanth100khere
Copy link

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();
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants