[fenix] for https://github.com/mozilla-mobile/fenix/issues/13479, added a VisualCompletenessQueue.kt class to handle all the functionality related to visual completeness
parent
7d93541b3f
commit
3b46908756
@ -0,0 +1,33 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.fenix.perf
|
||||
|
||||
import android.view.View
|
||||
import androidx.core.view.doOnPreDraw
|
||||
import mozilla.components.support.utils.RunWhenReadyQueue
|
||||
import java.lang.ref.WeakReference
|
||||
|
||||
/**
|
||||
* class for all functionality related to Visual completeness queue
|
||||
*/
|
||||
class VisualCompletenessQueue(val queue: RunWhenReadyQueue) {
|
||||
@Suppress("MagicNumber")
|
||||
val delay = 5000L
|
||||
|
||||
/**
|
||||
*
|
||||
* @param containerWeakReference a weak reference to the root view of a view hierarchy. Weak
|
||||
* reference is to avoid memory leak.
|
||||
*/
|
||||
fun attachViewToRunVisualCompletenessQueueLater(containerWeakReference: WeakReference<View>) {
|
||||
containerWeakReference.get()?.doOnPreDraw {
|
||||
// This delay is temporary. We are delaying 5 seconds until the performance
|
||||
// team can locate the real point of visual completeness.
|
||||
it.postDelayed({
|
||||
queue.ready()
|
||||
}, delay)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue