Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions app/src/org/commcare/views/QuestionsView.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
import java.util.Collections;
import java.util.HashMap;

import androidx.annotation.NonNull;

/**
* @author carlhartung
*/
Expand Down Expand Up @@ -346,6 +348,30 @@ public void setFocus(Context context, int indexOfLastChangedWidget) {
}
}

@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
try {
super.onSizeChanged(w, h, oldw, oldh);
} catch (IllegalArgumentException e) {
Logger.log(LogTypes.SOFT_ASSERT,
"Resizing from " + oldw + "X" + oldh + " to " + w + "X" + h + " failed with focus on: " + getFocusedViewClassName());
Comment on lines +356 to +357
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Log exception as it will gives exception details also?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We rethrow the exception, so the crashes will continue to happen and we will be able to get the details from the crash reports. But I'm happy to send add these to the log as well.

throw e;
}
}

@NonNull
private String getFocusedViewClassName() {
View focusedView = findFocus();
String focusedViewClassName = "None";
if (focusedView != null) {
focusedViewClassName = focusedView.getClass().toString();
if (focusedView.getParent() != null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What can be parent of QuestionView ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parent here is of the view who has the focus which is likely to be a QuestionWidget, like a StringWidget for instance. A StringWidget is composed by an EditText which if it has the focus, I'm expecting this to return something like Resizing 1from 0X0 to 720X1600 failed with focus on: class androidx.widget.EditText/class org.commcare.views.widgets.StringWidget

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, in case I think you can use simple class name by getClass().getSimpleName() or if full path required by getClass().getName()

focusedViewClassName += "/"+ focusedView.getParent().getClass();
}
}
return focusedViewClassName;
}

private void scrollToWidget(final QuestionWidget widget) {
new Handler().post(() -> QuestionsView.this.scrollTo(0, widget.getTop()));
}
Expand Down