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

Commit 75b34a81 authored by Aaron Liu's avatar Aaron Liu Committed by Automerger Merge Worker
Browse files

Merge "[User Switcher] Remove callback in onDestroy" into tm-dev am: ebf92a1a

parents 2ab903ec ebf92a1a
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -71,6 +71,11 @@ class UserSwitcherActivity @Inject constructor(
    private var popupMenu: UserSwitcherPopupMenu? = null
    private lateinit var addButton: View
    private var addUserRecords = mutableListOf<UserRecord>()
    private val userSwitchedCallback: UserTracker.Callback = object : UserTracker.Callback {
        override fun onUserChanged(newUser: Int, userContext: Context) {
            finish()
        }
    }
    // When the add users options become available, insert another option to manage users
    private val manageUserRecord = UserRecord(
        null /* info */,
@@ -215,11 +220,7 @@ class UserSwitcherActivity @Inject constructor(
        initBroadcastReceiver()

        parent.post { buildUserViews() }
        userTracker.addCallback(object : UserTracker.Callback {
            override fun onUserChanged(newUser: Int, userContext: Context) {
                finish()
            }
        }, mainExecutor)
        userTracker.addCallback(userSwitchedCallback, mainExecutor)
    }

    private fun showPopupMenu() {
@@ -340,6 +341,7 @@ class UserSwitcherActivity @Inject constructor(
        super.onDestroy()

        broadcastDispatcher.unregisterReceiver(broadcastReceiver)
        userTracker.removeCallback(userSwitchedCallback)
    }

    private fun initBroadcastReceiver() {