Skip to content

Commit c92b4c9

Browse files
committed
Re-run snapshot tests
1 parent 6910929 commit c92b4c9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+9790
-3525
lines changed

tests/snapshots/src/main/generated/BaseByteRenderer.scala

Lines changed: 75 additions & 73 deletions
Large diffs are not rendered by default.

tests/snapshots/src/main/generated/BaseCharRenderer.scala

Lines changed: 75 additions & 73 deletions
Large diffs are not rendered by default.

tests/snapshots/src/main/generated/ByteParser.scala

Lines changed: 367 additions & 388 deletions
Large diffs are not rendered by default.

tests/snapshots/src/main/generated/CharParser.scala

Lines changed: 367 additions & 388 deletions
Large diffs are not rendered by default.
Lines changed: 248 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,248 @@
1+
package com.airbnb.epoxy
2+
// ^^^ reference com/
3+
// ^^^^^^ reference com/airbnb/
4+
// ^^^^^ reference com/airbnb/epoxy/
5+
6+
import android.app.Activity
7+
import android.content.Context
8+
import android.content.ContextWrapper
9+
import android.os.Build
10+
import androidx.core.view.ViewCompat
11+
// ^^^^^^^^ reference androidx/
12+
import androidx.lifecycle.Lifecycle
13+
// ^^^^^^^^ reference androidx/
14+
// ^^^^^^^^^ reference androidx/lifecycle/
15+
// ^^^^^^^^^ reference androidx/lifecycle/Lifecycle#
16+
import androidx.lifecycle.LifecycleObserver
17+
// ^^^^^^^^ reference androidx/
18+
// ^^^^^^^^^ reference androidx/lifecycle/
19+
// ^^^^^^^^^^^^^^^^^ reference androidx/lifecycle/LifecycleObserver#
20+
import androidx.lifecycle.LifecycleOwner
21+
// ^^^^^^^^ reference androidx/
22+
// ^^^^^^^^^ reference androidx/lifecycle/
23+
// ^^^^^^^^^^^^^^ reference androidx/lifecycle/LifecycleOwner#
24+
import androidx.lifecycle.OnLifecycleEvent
25+
// ^^^^^^^^ reference androidx/
26+
// ^^^^^^^^^ reference androidx/lifecycle/
27+
// ^^^^^^^^^^^^^^^^ reference androidx/lifecycle/OnLifecycleEvent#
28+
import androidx.recyclerview.widget.RecyclerView
29+
// ^^^^^^^^ reference androidx/
30+
import java.lang.ref.WeakReference
31+
// ^^^^ reference java/
32+
// ^^^^ reference java/lang/
33+
// ^^^ reference java/lang/ref/
34+
// ^^^^^^^^^^^^^ reference java/lang/ref/WeakReference#
35+
import java.util.ArrayList
36+
// ^^^^ reference java/
37+
// ^^^^ reference java/util/
38+
// ^^^^^^^^^ reference java/util/ArrayList#
39+
40+
internal class ActivityRecyclerPool {
41+
// ^^^^^^^^^^^^^^^^^^^^ definition com/airbnb/epoxy/ActivityRecyclerPool#
42+
// ^^^^^^^^^^^^^^^^^^^^ definition com/airbnb/epoxy/ActivityRecyclerPool#`<init>`().
43+
44+
/**
45+
* Store one unique pool per activity. They are cleared out when activities are destroyed, so this
46+
* only needs to hold pools for active activities.
47+
*/
48+
private val pools = ArrayList<PoolReference>(5)
49+
// ^^^^^ definition com/airbnb/epoxy/ActivityRecyclerPool#pools.
50+
// ^^^^^ definition com/airbnb/epoxy/ActivityRecyclerPool#getPools().
51+
// ^^^^^^^^^ reference java/util/ArrayList#`<init>`().
52+
// ^^^^^^^^^^^^^ reference com/airbnb/epoxy/PoolReference#
53+
54+
@JvmOverloads
55+
// ^^^^^^^^^^^^ reference kotlin/jvm/JvmOverloads#`<init>`().
56+
fun getPool(
57+
// ^^^^^^^ definition com/airbnb/epoxy/ActivityRecyclerPool#getPool().
58+
context: Context,
59+
// ^^^^^^^ definition com/airbnb/epoxy/ActivityRecyclerPool#getPool().(context)
60+
poolFactory: () -> RecyclerView.RecycledViewPool
61+
// ^^^^^^^^^^^ definition com/airbnb/epoxy/ActivityRecyclerPool#getPool().(poolFactory)
62+
): PoolReference {
63+
// ^^^^^^^^^^^^^ reference com/airbnb/epoxy/PoolReference#
64+
65+
val iterator = pools.iterator()
66+
// ^^^^^^^^ definition local0
67+
// ^^^^^ reference com/airbnb/epoxy/ActivityRecyclerPool#pools.
68+
// ^^^^^ reference com/airbnb/epoxy/ActivityRecyclerPool#getPools().
69+
// ^^^^^^^^ reference java/util/ArrayList#iterator().
70+
var poolToUse: PoolReference? = null
71+
// ^^^^^^^^^ definition local1
72+
// ^^^^^^^^^^^^^ reference com/airbnb/epoxy/PoolReference#
73+
74+
while (iterator.hasNext()) {
75+
// ^^^^^^^^ reference local0
76+
// ^^^^^^^ reference kotlin/collections/MutableIterator#hasNext().
77+
val poolReference = iterator.next()
78+
// ^^^^^^^^^^^^^ definition local2
79+
// ^^^^^^^^ reference local0
80+
// ^^^^ reference kotlin/collections/MutableIterator#next().
81+
when {
82+
poolReference.context === context -> {
83+
// ^^^^^^^^^^^^^ reference local2
84+
// ^^^^^^^ reference com/airbnb/epoxy/PoolReference#context.
85+
// ^^^^^^^ reference com/airbnb/epoxy/ActivityRecyclerPool#getPool().(context)
86+
if (poolToUse != null) {
87+
// ^^^^^^^^^ reference local1
88+
// ^^ reference com/airbnb/epoxy/PoolReference#equals(+-1).
89+
throw IllegalStateException("A pool was already found")
90+
// ^^^^^^^^^^^^^^^^^^^^^ reference kotlin/IllegalStateException#`<init>`(+1).
91+
}
92+
poolToUse = poolReference
93+
// ^^^^^^^^^ reference local1
94+
// ^^^^^^^^^^^^^ reference local2
95+
// finish iterating to remove any old contexts
96+
}
97+
poolReference.context.isActivityDestroyed() -> {
98+
// ^^^^^^^^^^^^^ reference local2
99+
// ^^^^^^^ reference com/airbnb/epoxy/PoolReference#context.
100+
// A pool from a different activity that was destroyed.
101+
// Clear the pool references to allow the activity to be GC'd
102+
poolReference.viewPool.clear()
103+
// ^^^^^^^^^^^^^ reference local2
104+
// ^^^^^^^^ reference com/airbnb/epoxy/PoolReference#viewPool.
105+
// ^^^^^^^^ reference com/airbnb/epoxy/PoolReference#getViewPool().
106+
iterator.remove()
107+
// ^^^^^^^^ reference local0
108+
// ^^^^^^ reference kotlin/collections/MutableIterator#remove().
109+
}
110+
}
111+
}
112+
113+
if (poolToUse == null) {
114+
// ^^^^^^^^^ reference local1
115+
// ^^ reference com/airbnb/epoxy/PoolReference#equals(+-1).
116+
poolToUse = PoolReference(context, poolFactory(), this)
117+
// ^^^^^^^^^ reference local1
118+
// ^^^^^^^^^^^^^ reference com/airbnb/epoxy/PoolReference#`<init>`().
119+
// ^^^^^^^ reference com/airbnb/epoxy/ActivityRecyclerPool#getPool().(context)
120+
// ^^^^^^^^^^^ reference com/airbnb/epoxy/ActivityRecyclerPool#getPool().(poolFactory)
121+
// ^^^^ reference com/airbnb/epoxy/ActivityRecyclerPool#
122+
context.lifecycle()?.addObserver(poolToUse)
123+
// ^^^^^^^ reference com/airbnb/epoxy/ActivityRecyclerPool#getPool().(context)
124+
// ^^^^^^^^^ reference local1
125+
pools.add(poolToUse)
126+
// ^^^^^ reference com/airbnb/epoxy/ActivityRecyclerPool#pools.
127+
// ^^^^^ reference com/airbnb/epoxy/ActivityRecyclerPool#getPools().
128+
// ^^^ reference java/util/ArrayList#add(+1).
129+
// ^^^^^^^^^ reference local1
130+
}
131+
132+
return poolToUse
133+
// ^^^^^^^^^ reference local1
134+
}
135+
136+
fun clearIfDestroyed(pool: PoolReference) {
137+
// ^^^^^^^^^^^^^^^^ definition com/airbnb/epoxy/ActivityRecyclerPool#clearIfDestroyed().
138+
// ^^^^ definition com/airbnb/epoxy/ActivityRecyclerPool#clearIfDestroyed().(pool)
139+
// ^^^^^^^^^^^^^ reference com/airbnb/epoxy/PoolReference#
140+
if (pool.context.isActivityDestroyed()) {
141+
// ^^^^ reference com/airbnb/epoxy/ActivityRecyclerPool#clearIfDestroyed().(pool)
142+
// ^^^^^^^ reference com/airbnb/epoxy/PoolReference#context.
143+
pool.viewPool.clear()
144+
// ^^^^ reference com/airbnb/epoxy/ActivityRecyclerPool#clearIfDestroyed().(pool)
145+
// ^^^^^^^^ reference com/airbnb/epoxy/PoolReference#viewPool.
146+
// ^^^^^^^^ reference com/airbnb/epoxy/PoolReference#getViewPool().
147+
pools.remove(pool)
148+
// ^^^^^ reference com/airbnb/epoxy/ActivityRecyclerPool#pools.
149+
// ^^^^^ reference com/airbnb/epoxy/ActivityRecyclerPool#getPools().
150+
// ^^^^^^ reference java/util/ArrayList#remove().
151+
// ^^^^ reference com/airbnb/epoxy/ActivityRecyclerPool#clearIfDestroyed().(pool)
152+
}
153+
}
154+
155+
private fun Context.lifecycle(): Lifecycle? {
156+
// ^^^^^^^^^ definition com/airbnb/epoxy/ActivityRecyclerPool#lifecycle().
157+
// ^^^^^^^^^ reference androidx/lifecycle/Lifecycle#
158+
if (this is LifecycleOwner) {
159+
// ^^^^ reference com/airbnb/epoxy/ActivityRecyclerPool#lifecycle().
160+
// ^^^^^^^^^^^^^^ reference androidx/lifecycle/LifecycleOwner#
161+
return lifecycle
162+
}
163+
164+
if (this is ContextWrapper) {
165+
// ^^^^ reference com/airbnb/epoxy/ActivityRecyclerPool#lifecycle().
166+
return baseContext.lifecycle()
167+
}
168+
169+
return null
170+
}
171+
}
172+
173+
internal class PoolReference(
174+
// ^^^^^^^^^^^^^ definition com/airbnb/epoxy/PoolReference#
175+
// ^^^^^^^^^^^^^ definition com/airbnb/epoxy/PoolReference#`<init>`().
176+
context: Context,
177+
// ^^^^^^^ definition com/airbnb/epoxy/PoolReference#`<init>`().(context)
178+
val viewPool: RecyclerView.RecycledViewPool,
179+
// ^^^^^^^^ definition com/airbnb/epoxy/PoolReference#viewPool.
180+
// ^^^^^^^^ definition com/airbnb/epoxy/PoolReference#getViewPool().
181+
// ^^^^^^^^ definition com/airbnb/epoxy/PoolReference#`<init>`().(viewPool)
182+
private val parent: ActivityRecyclerPool
183+
// ^^^^^^ definition com/airbnb/epoxy/PoolReference#parent.
184+
// ^^^^^^ definition com/airbnb/epoxy/PoolReference#getParent().
185+
// ^^^^^^ definition com/airbnb/epoxy/PoolReference#`<init>`().(parent)
186+
// ^^^^^^^^^^^^^^^^^^^^ reference com/airbnb/epoxy/ActivityRecyclerPool#
187+
) : LifecycleObserver {
188+
// ^^^^^^^^^^^^^^^^^ reference androidx/lifecycle/LifecycleObserver#
189+
private val contextReference: WeakReference<Context> = WeakReference(context)
190+
// ^^^^^^^^^^^^^^^^ definition com/airbnb/epoxy/PoolReference#contextReference.
191+
// ^^^^^^^^^^^^^^^^ definition com/airbnb/epoxy/PoolReference#getContextReference().
192+
// ^^^^^^^^^^^^^ reference java/lang/ref/WeakReference#
193+
// ^^^^^^^^^^^^^ reference java/lang/ref/WeakReference#`<init>`().
194+
// ^^^^^^^ reference com/airbnb/epoxy/PoolReference#`<init>`().(context)
195+
196+
val context: Context? get() = contextReference.get()
197+
// ^^^^^^^ definition com/airbnb/epoxy/PoolReference#context.
198+
// ^^^ definition com/airbnb/epoxy/PoolReference#getContext().
199+
// ^^^^^^^^^^^^^^^^ reference com/airbnb/epoxy/PoolReference#contextReference.
200+
// ^^^^^^^^^^^^^^^^ reference com/airbnb/epoxy/PoolReference#getContextReference().
201+
// ^^^ reference java/lang/ref/WeakReference#get().
202+
203+
fun clearIfDestroyed() {
204+
// ^^^^^^^^^^^^^^^^ definition com/airbnb/epoxy/PoolReference#clearIfDestroyed().
205+
parent.clearIfDestroyed(this)
206+
// ^^^^^^ reference com/airbnb/epoxy/PoolReference#parent.
207+
// ^^^^^^ reference com/airbnb/epoxy/PoolReference#getParent().
208+
// ^^^^^^^^^^^^^^^^ reference com/airbnb/epoxy/ActivityRecyclerPool#clearIfDestroyed().
209+
// ^^^^ reference com/airbnb/epoxy/PoolReference#
210+
}
211+
212+
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
213+
// ^^^^^^^^^^^^^^^^ reference androidx/lifecycle/OnLifecycleEvent#`<init>`().
214+
// ^^^^^^^^^ reference androidx/lifecycle/Lifecycle#
215+
// ^^^^^ reference androidx/lifecycle/Lifecycle#Event#
216+
// ^^^^^^^^^^ reference androidx/lifecycle/Lifecycle#Event#ON_DESTROY#
217+
fun onContextDestroyed() {
218+
// ^^^^^^^^^^^^^^^^^^ definition com/airbnb/epoxy/PoolReference#onContextDestroyed().
219+
clearIfDestroyed()
220+
// ^^^^^^^^^^^^^^^^ reference com/airbnb/epoxy/PoolReference#clearIfDestroyed().
221+
}
222+
}
223+
224+
internal fun Context?.isActivityDestroyed(): Boolean {
225+
// ^^^^^^^^^^^^^^^^^^^ definition com/airbnb/epoxy/ActivityRecyclerPoolKt#isActivityDestroyed().
226+
// ^^^^^^^ reference kotlin/Boolean#
227+
if (this == null) {
228+
// ^^^^ reference com/airbnb/epoxy/ActivityRecyclerPoolKt#isActivityDestroyed().
229+
return true
230+
}
231+
232+
if (this !is Activity) {
233+
// ^^^^ reference com/airbnb/epoxy/ActivityRecyclerPoolKt#isActivityDestroyed().
234+
return (this as? ContextWrapper)?.baseContext?.isActivityDestroyed() ?: false
235+
// ^^^^ reference com/airbnb/epoxy/ActivityRecyclerPoolKt#isActivityDestroyed().
236+
}
237+
238+
if (isFinishing) {
239+
return true
240+
}
241+
242+
return if (Build.VERSION.SDK_INT >= 17) {
243+
isDestroyed
244+
} else {
245+
// Use this as a proxy for being destroyed on older devices
246+
!ViewCompat.isAttachedToWindow(window.decorView)
247+
}
248+
}

tests/snapshots/src/main/generated/com/airbnb/epoxy/AfterPropsSet.java

Lines changed: 0 additions & 44 deletions
This file was deleted.

tests/snapshots/src/main/generated/com/airbnb/epoxy/AutoModel.java

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)