@@ -20,10 +20,6 @@ import android.util.SparseLongArray
2020import android.view.View
2121import android.view.ViewGroup
2222import androidx.collection.SparseArrayCompat
23- import androidx.collection.forEach
24- import androidx.core.util.forEach
25- import androidx.core.util.isEmpty
26- import androidx.core.view.children
2723
2824object Logger {
2925
@@ -91,43 +87,53 @@ object Logger {
9187 }
9288 // region SparseArrays
9389 this is SparseArray <* > -> {
94- if (this .isEmpty() ) {
90+ if (this .size() == 0 ) {
9591 println (" []" )
9692 } else {
9793 println ()
98- this .forEach { k, v -> v.dump(k.toString(), nextIndent, processed, forceInclude, forceIncludeClasses) }
94+ for (index in 0 until size()) {
95+ valueAt(index).dump(keyAt(index).toString(), nextIndent, processed, forceInclude, forceIncludeClasses)
96+ }
9997 }
10098 }
10199 this is SparseIntArray -> {
102- if (this .isEmpty() ) {
100+ if (this .size() == 0 ) {
103101 println (" []" )
104102 } else {
105103 println ()
106- this .forEach { k, v -> v.dump(k.toString(), nextIndent, processed, forceInclude, forceIncludeClasses) }
104+ for (index in 0 until size()) {
105+ valueAt(index).dump(keyAt(index).toString(), nextIndent, processed, forceInclude, forceIncludeClasses)
106+ }
107107 }
108108 }
109109 this is SparseLongArray -> {
110- if (this .isEmpty() ) {
110+ if (this .size() == 0 ) {
111111 println (" []" )
112112 } else {
113113 println ()
114- this .forEach { k, v -> v.dump(k.toString(), nextIndent, processed, forceInclude, forceIncludeClasses) }
114+ for (index in 0 until size()) {
115+ valueAt(index).dump(keyAt(index).toString(), nextIndent, processed, forceInclude, forceIncludeClasses)
116+ }
115117 }
116118 }
117119 this is SparseBooleanArray -> {
118- if (this .isEmpty() ) {
120+ if (this .size() == 0 ) {
119121 println (" []" )
120122 } else {
121123 println ()
122- this .forEach { k, v -> v.dump(k.toString(), nextIndent, processed, forceInclude, forceIncludeClasses) }
124+ for (index in 0 until size()) {
125+ valueAt(index).dump(keyAt(index).toString(), nextIndent, processed, forceInclude, forceIncludeClasses)
126+ }
123127 }
124128 }
125129 this is SparseArrayCompat <* > -> {
126- if (this .isEmpty ) {
130+ if (this .size() == 0 ) {
127131 println (" []" )
128132 } else {
129133 println ()
130- this .forEach { k, v -> v.dump(k.toString(), nextIndent, processed, forceInclude, forceIncludeClasses) }
134+ for (index in 0 until size()) {
135+ valueAt(index).dump(keyAt(index).toString(), nextIndent, processed, forceInclude, forceIncludeClasses)
136+ }
131137 }
132138 }
133139 // endregion
@@ -163,7 +169,9 @@ object Logger {
163169 }
164170 this is ViewGroup -> {
165171 println ()
166- children.forEachIndexed { view, i -> view.dump(i.toString(), nextIndent, processed, forceInclude, forceIncludeClasses) }
172+ for (i in 0 until childCount) {
173+ getChildAt(i).dump(i.toString(), nextIndent, processed, forceInclude, forceIncludeClasses)
174+ }
167175 }
168176 forceInclude.none { it == this } && forceIncludeClasses.none { it.isInstance(this ) } && listOf (
169177 " android.content.Context" ,
@@ -237,8 +245,8 @@ object Logger {
237245 fun View.dump (indent : Int = 0) {
238246 println (" " .repeat(indent * 2 ) + this )
239247 if (this is ViewGroup ) {
240- children.forEach {
241- it .dump(indent + 1 )
248+ for (i in 0 until childCount) {
249+ getChildAt(i) .dump(indent + 1 )
242250 }
243251 }
244252 }
0 commit comments