janheinrichmerker / android-issue-reporter

A powerful and simple library to open issues on GitHub directly from your app.
MIT License
118 stars 27 forks source link

Updated build tools & A force close bug fix #45

Closed rosenpin closed 8 years ago

rosenpin commented 8 years ago

Edit: This PR solves #44

I'm not sure what was the source of the bug but after updating the build tools of my app the ReporterActivity kept force closing on create (When using the setGuestEmailRequired(true)) and when clicking the submit button. This is the exception I was getting

      java.lang.ClassCastException: android.widget.FrameLayout cannot be cast to android.support.design.widget.TextInputLayout
              at com.heinrichreimersoftware.androidissuereporter.IssueReporterActivity.validateInput(Unknown)
              at com.heinrichreimersoftware.androidissuereporter.IssueReporterActivity.reportIssue(Unknown)
              at com.heinrichreimersoftware.androidissuereporter.IssueReporterActivity.access$100(Unknown)
              at com.heinrichreimersoftware.androidissuereporter.IssueReporterActivity$5.onClick(Unknown)

I managed to fix it by replacing the view.getParent with view.getParent().getParent(). But just to be safe (and for backwards compatibility) I added a while loop to check if the correct class is being cast (until the correct class is being cast)


View layout = (View) editText.getParent();
while (!layout.getClass().getSimpleName().equals(TextInputLayout.class.getSimpleName()))
      layout = (View) layout.getParent();
TextInputLayout realLayout = (TextInputLayout) layout;
janheinrichmerker commented 8 years ago

In your commit the @IntDef was moved. Please move it back to the related constants as it was before so I can merge this pull.

rosenpin commented 8 years ago

It was done automatically by Android Studio code rearrangement. Fixed it.