blonsky95 / DigiCoachAndroid

0 stars 0 forks source link

Load different userdata for one same device #81

Closed blonsky95 closed 4 years ago

blonsky95 commented 4 years ago

While creating the dynamic database selection (depending on the user logged in get a different local database) I realised that before entering any activity after login, the Dataholder object (which is used throughout the app to access easily the username, email and docId) should have its values loaded.

To do so, in the loginSignUpViewModel when a user wants to log in there is 3 ways: log in - grants access register - grants access remember user if they havent logged out manually before - grants access

When access is granted - viewmodel checks if in preferences there is a key associated to their useremail, if there is, it loads the dataholder and gives access to home screen. If there is no key associated it does a firebase query and gets the username and id, and stores them in preferences, after which it recalls the function that checks if they are in preferences (which they should be).

functions concerned are: in LoginSignUpViewModel: