-
Notifications
You must be signed in to change notification settings - Fork 956
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Workaround for a crash when converting Compose nodes
Summary: For an unknown reason we're getting reports about `NoSuchMethodError`s happening when using ui-inspector code. I'm not able to reproduce it locally so I'm adding another try-catch to prevent it from crashing. I hope that once we convince Google to properly publish ui-inspector as a standalone library and we won't have to copy this code manually to our monorepo, those issues will get resolved. This diff also updates the ui-inspector code in flipper codebase which is needed for gradle builds. Reviewed By: pengj Differential Revision: D53701915 fbshipit-source-id: aced2a1ca311c6d5db01e48903ef9662649811b4
- Loading branch information
1 parent
8afb9ff
commit 0d83935
Showing
10 changed files
with
113 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...ose/src/main/java/facebook/internal/androidx/compose/ui/inspection/util/CollectionUtil.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright 2021 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package androidx.compose.ui.inspection.util | ||
|
||
import androidx.collection.IntList | ||
import androidx.collection.MutableIntList | ||
import androidx.collection.MutableLongObjectMap | ||
import androidx.collection.mutableIntListOf | ||
|
||
fun MutableIntList.removeLast() { | ||
val last = lastIndex | ||
if (last < 0) throw NoSuchElementException("List is empty.") else removeAt(last) | ||
} | ||
|
||
fun <T, M : MutableLongObjectMap<MutableList<T>>> Iterable<T>.groupByToLongObjectMap( | ||
destination: M, | ||
keySelector: (T) -> Long | ||
): M { | ||
for (element in this) { | ||
val key = keySelector(element) | ||
val list = destination.getOrPut(key) { ArrayList() } | ||
list.add(element) | ||
} | ||
return destination | ||
} | ||
|
||
fun IntList.copy(): IntList { | ||
val result = mutableIntListOf() | ||
forEach { result.add(it) } | ||
return result | ||
} |
21 changes: 0 additions & 21 deletions
21
...k-compose/src/main/java/facebook/internal/androidx/compose/ui/inspection/util/IntArray.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters