2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-15 18:12:54 +00:00

For #3678: Fix crash when tapping on your account (#3688)

This commit is contained in:
Yeon Taek Jeong 2019-06-26 13:33:27 -07:00 committed by Sawyer Blatz
parent a1ddf17364
commit 2cafd5bba6

View File

@ -181,11 +181,9 @@ class AccountSettingsFragment : PreferenceFragmentCompat() {
} }
private val syncStatusObserver = object : SyncStatusObserver { private val syncStatusObserver = object : SyncStatusObserver {
private val key = context!!.getPreferenceKey(R.string.pref_key_sync_now)
override fun onStarted() { override fun onStarted() {
lifecycleScope.launch { lifecycleScope.launch {
val pref = findPreference<Preference>(key) val pref = findPreference<Preference>(context!!.getPreferenceKey(R.string.pref_key_sync_now))
view?.announceForAccessibility(getString(R.string.sync_syncing_in_progress)) view?.announceForAccessibility(getString(R.string.sync_syncing_in_progress))
pref?.title = getString(R.string.sync_syncing_in_progress) pref?.title = getString(R.string.sync_syncing_in_progress)
pref?.isEnabled = false pref?.isEnabled = false
@ -197,7 +195,8 @@ class AccountSettingsFragment : PreferenceFragmentCompat() {
// Sync stopped successfully. // Sync stopped successfully.
override fun onIdle() { override fun onIdle() {
lifecycleScope.launch { lifecycleScope.launch {
findPreference<Preference>(key)?.let { pref -> val pref = findPreference<Preference>(context!!.getPreferenceKey(R.string.pref_key_sync_now))
pref?.let {
pref.title = getString(R.string.preferences_sync_now) pref.title = getString(R.string.preferences_sync_now)
pref.isEnabled = true pref.isEnabled = true
updateLastSyncedTimePref(context!!, pref, failed = false) updateLastSyncedTimePref(context!!, pref, failed = false)
@ -208,7 +207,8 @@ class AccountSettingsFragment : PreferenceFragmentCompat() {
// Sync stopped after encountering a problem. // Sync stopped after encountering a problem.
override fun onError(error: Exception?) { override fun onError(error: Exception?) {
lifecycleScope.launch { lifecycleScope.launch {
findPreference<Preference>(key)?.let { pref -> val pref = findPreference<Preference>(context!!.getPreferenceKey(R.string.pref_key_sync_now))
pref?.let {
pref.title = getString(R.string.preferences_sync_now) pref.title = getString(R.string.preferences_sync_now)
pref.isEnabled = true pref.isEnabled = true
updateLastSyncedTimePref(context!!, pref, failed = true) updateLastSyncedTimePref(context!!, pref, failed = true)