This repository has been archived by the owner on Feb 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…11668) * For #11660:added prefetch for topsites TopSites will be prefetched with observerOnce (wrapper around observerForever). Also, the SessionControlView.update() is called right away instead of waiting from consumeFrom in the HomeFragment.onCreateView() which will allow the UI to render all at once on its first perform traversal * Removed the submitList(null) since it retriggered a drawing on lower end device
- Loading branch information
1 parent
44ff29b
commit b52091e
Showing
5 changed files
with
52 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* 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.ext | ||
|
||
import androidx.lifecycle.LiveData | ||
import androidx.lifecycle.Observer | ||
|
||
/** | ||
* Observe a LiveData once and unregister from it as soon as the live data returns a value | ||
*/ | ||
fun <T> LiveData<T>.observeOnce(observer: (T) -> Unit) { | ||
observeForever(object : Observer<T> { | ||
override fun onChanged(value: T) { | ||
removeObserver(this) | ||
observer(value) | ||
} | ||
}) | ||
} |
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