From d98d91a67f6d7bc57b6060ab3e6ee37da379a363 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Sat, 5 Jan 2019 13:03:01 +0000 Subject: [PATCH] Revert "Don't rely on LOGIN_ACCOUNTS_CHANGED_ACTION" Actually, let's not make this change just yet so we are sure we haven't broken anything. This reverts commit dda23fb484730a8955e470fec7d90d0790656f88. --- app/src/main/AndroidManifest.xml | 14 ++++++ .../syncadapter/AccountsChangedReceiver.kt | 47 +++++++++++++++++++ .../syncadapter/ui/AccountListFragment.kt | 5 +- 3 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/com/etesync/syncadapter/AccountsChangedReceiver.kt diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 853693c2..985eced2 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -162,6 +162,20 @@ android:enabled="true"> + + + + + + + + + + + + + + = LinkedList() + + fun registerListener(listener: OnAccountsUpdateListener, callImmediately: Boolean) { + listeners.add(listener) + if (callImmediately) + listener.onAccountsUpdated(null) + } + + fun unregisterListener(listener: OnAccountsUpdateListener) { + listeners.remove(listener) + } + } + +} diff --git a/app/src/main/java/com/etesync/syncadapter/ui/AccountListFragment.kt b/app/src/main/java/com/etesync/syncadapter/ui/AccountListFragment.kt index c9efef77..2d6cc98c 100644 --- a/app/src/main/java/com/etesync/syncadapter/ui/AccountListFragment.kt +++ b/app/src/main/java/com/etesync/syncadapter/ui/AccountListFragment.kt @@ -26,6 +26,7 @@ import android.widget.AbsListView import android.widget.AdapterView import android.widget.ArrayAdapter import android.widget.TextView +import com.etesync.syncadapter.AccountsChangedReceiver import com.etesync.syncadapter.App import com.etesync.syncadapter.R @@ -79,11 +80,11 @@ class AccountListFragment : ListFragment(), LoaderManager.LoaderCallbacks) {