Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Gaba
fenix
Commits
7d9274e9
Commit
7d9274e9
authored
Aug 18, 2020
by
Gabriel Luong
Committed by
Jonathan Almeida
Aug 26, 2020
Browse files
For #10342 - Part 1: Remove top sites prefetch and observation of live data
parent
0162fd68
Changes
3
Hide whitespace changes
Inline
Side-by-side
app/src/main/java/org/mozilla/fenix/FenixApplication.kt
View file @
7d9274e9
...
...
@@ -141,7 +141,6 @@ open class FenixApplication : LocaleAwareApplication(), Provider {
}
}
prefetchForHomeFragment
()
setupLeakCanary
()
startMetricsIfEnabled
()
setupPush
()
...
...
@@ -257,14 +256,6 @@ open class FenixApplication : LocaleAwareApplication(), Provider {
// no-op, LeakCanary is disabled by default
}
// This is for issue https://github.com/mozilla-mobile/fenix/issues/11660. We prefetch our info for startup
// so that we're sure that we have all the data available as our fragment is launched.
private
fun
prefetchForHomeFragment
()
{
StrictMode
.
allowThreadDiskReads
().
resetPoliciesAfter
{
components
.
core
.
topSiteStorage
.
prefetch
()
}
}
private
fun
setupPush
()
{
// Sets the PushFeature as the singleton instance for push messages to go to.
// We need the push feature setup here to deliver messages in the case where the service
...
...
app/src/main/java/org/mozilla/fenix/ext/LiveData.kt
deleted
100644 → 0
View file @
0162fd68
/* 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
)
}
})
}
app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt
View file @
7d9274e9
...
...
@@ -68,7 +68,6 @@ import mozilla.components.concept.sync.AccountObserver
import
mozilla.components.concept.sync.AuthType
import
mozilla.components.concept.sync.OAuthAccount
import
mozilla.components.feature.tab.collections.TabCollection
import
mozilla.components.feature.top.sites.TopSite
import
mozilla.components.lib.state.ext.consumeFrom
import
mozilla.components.support.ktx.android.util.dpToPx
import
org.mozilla.fenix.BrowserDirection
...
...
@@ -511,7 +510,6 @@ class HomeFragment : Fragment() {
override
fun
onStart
()
{
super
.
onStart
()
subscribeToTabCollections
()
subscribeToTopSites
()
val
context
=
requireContext
()
val
components
=
context
.
components
...
...
@@ -847,17 +845,6 @@ class HomeFragment : Fragment() {
}
}
private
fun
subscribeToTopSites
():
Observer
<
List
<
TopSite
>>
{
return
Observer
<
List
<
TopSite
>>
{
topSites
->
requireComponents
.
core
.
topSiteStorage
.
cachedTopSites
=
topSites
context
?.
settings
()
?.
preferences
?.
edit
()
?.
putInt
(
getString
(
R
.
string
.
pref_key_top_sites_size
),
topSites
.
size
)
?.
apply
()
homeFragmentStore
.
dispatch
(
HomeFragmentAction
.
TopSitesChange
(
topSites
))
}.
also
{
observer
->
requireComponents
.
core
.
topSiteStorage
.
getTopSites
().
observe
(
this
,
observer
)
}
}
private
fun
registerCollectionStorageObserver
()
{
requireComponents
.
core
.
tabCollectionStorage
.
register
(
collectionStorageObserver
,
this
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment