When logging errors with deleteView, try to find actual index of view

Summary:
If we try to delete a view and find the wrong one, when we crash, try to log the *actual* index of the view in question.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D23368229

fbshipit-source-id: 7f9835fd07cfe4924d05c7e37b42b9bcdffff4a9
This commit is contained in:
Joshua Gross 2020-08-27 13:58:25 -07:00 коммит произвёл Facebook GitHub Bot
Родитель cb48b50290
Коммит d344fb4e29
1 изменённых файлов: 13 добавлений и 2 удалений

Просмотреть файл

@ -366,7 +366,16 @@ public class MountingManager {
// Verify that the view we're about to remove has the same tag we expect // Verify that the view we're about to remove has the same tag we expect
View view = viewGroupManager.getChildAt(parentView, index); View view = viewGroupManager.getChildAt(parentView, index);
if (view != null && view.getId() != tag) { int actualTag = (view != null ? view.getId() : -1);
if (actualTag != tag) {
int tagActualIndex = -1;
for (int i = 0; i < parentView.getChildCount(); i++) {
if (parentView.getChildAt(i).getId() == tag) {
tagActualIndex = i;
break;
}
}
throw new IllegalStateException( throw new IllegalStateException(
"Tried to delete view [" "Tried to delete view ["
+ tag + tag
@ -375,7 +384,9 @@ public class MountingManager {
+ "] at index " + "] at index "
+ index + index
+ ", but got view tag " + ", but got view tag "
+ view.getId()); + actualTag
+ " - actual index of view: "
+ tagActualIndex);
} }
try { try {