Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit def92221 authored by Ricki Hirner's avatar Ricki Hirner
Browse files

Cache task provider in the UI

parent 9c2b8101
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -143,6 +143,7 @@ class AccountListFragment: Fragment() {
        )

        val accounts = MutableLiveData<List<AccountInfo>>()
        val syncAuthorities by lazy { DavUtils.syncAuthorities(getApplication()) }

        val networkAvailable = MutableLiveData<Boolean>()
        private var networkCallback: ConnectivityManager.NetworkCallback? = null
@@ -234,7 +235,7 @@ class AccountListFragment: Fragment() {
                        collator.compare(a.name, b.name)
                    })
            val accountsWithInfo = sortedAccounts.map { account ->
                AccountInfo(account, DavUtils.accountSyncStatus(context, DavUtils.syncAuthorities(context), account))
                AccountInfo(account, DavUtils.accountSyncStatus(context, syncAuthorities, account))
            }
            accounts.postValue(accountsWithInfo)
        }
+4 −1
Original line number Diff line number Diff line
@@ -217,6 +217,9 @@ abstract class CollectionsFragment: Fragment(), SwipeRefreshLayout.OnRefreshList
        val serviceId = MutableLiveData<Long>()
        private lateinit var collectionType: String

        // cache task provider
        val taskProvider by lazy { TaskUtils.currentProvider(getApplication()) }

        val collections: LiveData<PagedList<Collection>> =
                Transformations.switchMap(serviceId) { service ->
                    db.collectionDao().pageByServiceAndType(service, collectionType).toLiveData(25)
@@ -305,7 +308,7 @@ abstract class CollectionsFragment: Fragment(), SwipeRefreshLayout.OnRefreshList
                isSyncPending.postValue(mainSyncPending || syncPending)
            } else {
                val authorities = mutableListOf(CalendarContract.AUTHORITY)
                TaskUtils.currentProvider(context)?.let {
                taskProvider?.let {
                    authorities += it.authority
                }
                isSyncActive.postValue(authorities.any {