/** * Sets the active user to <code>userEmail</code> if <code>userEmail</code> is a logged in user. * * @param userEmail The user to be set as active. * @throws IllegalArgumentException if the <code>userEmail</code> does not exist i.e. is not a * logged in user. */ public void setActiveUser(@NotNull String userEmail) throws IllegalArgumentException { synchronized (this) { if (!allUsers.containsKey(userEmail)) { throw new IllegalArgumentException(userEmail + " is not a logged in user."); } if (activeUser != null) { activeUser.setActive(false); } activeUser = allUsers.get(userEmail); activeUser.setActive(true); GoogleLoginPrefs.saveActiveUser(userEmail); notifyLoginStatusChange(); } }
/** If there is an active user, makes the active use no longer active. */ public void removeActiveUser() { synchronized (this) { if (activeUser != null) { activeUser.setActive(false); activeUser = null; GoogleLoginPrefs.removeActiveUser(); notifyLoginStatusChange(); } } }