private async void OnSigninButtonClicked(object sender, EventArgs e) { //await Rg.Plugins.Popup.Services.PopupNavigation.Instance.PushAsync(new LoadingPage()); int userID = await CheckLoginInput(); if (userID == -1) { return; } string password = Entry_Password.Text; //login in via web server string loginResponse = await Communications.Login(userID, password); if (loginResponse == Convert.ToString(Constants.SERVER_ERROR)) { await DisplayAlert(null, Constants.SERVER_ERROR_MSG, "OK"); return; } List <string> responses = loginResponse.Split('!').ToList <string>(); int responseCode = int.Parse(responses[0]); if (responseCode != Constants.SUCCESS) { //login unsuccessful //await Rg.Plugins.Popup.Services.PopupNavigation.Instance.PopAsync(); await DisplayErrorMsg(responseCode); } else { string userJson = responses[1]; User user = JsonConvert.DeserializeObject <User>(userJson); Constants.me = user; user.username = user.username.Substring(1, user.username.Length - 2); Constants.Friend = new Friend(); //Constants.Friend.Friends = await Communications.GetAllFriend(); int userDBIndex = getUserDBIndex(); if (userDBIndex == Constants.NEW_USER_LOGIN) { //retrieve from web server, create new database, update userList db User.SaveToLocal(); Constants.Friend.Friends = await Communications.GetAllFriendEntity(); Friend.SaveToLocal(); } else { //load from local db string dbFile = string.Format("userDB{0}.db3", userDBIndex); String userPath = Path.Combine(Constants.PathPrefix, dbFile); App.Database = new UserDatabase(userPath); await App.UserDB.UpdateAsync(new UserDBModel(1, Constants.me.userid)); Friend.LoadFromLocal(); } //await Rg.Plugins.Popup.Services.PopupNavigation.Instance.PopAsync(); PushToMyTask(); Constants.firstLoginToday = UserLog.isFirstLoginToday(); UserLog.WriteLoginTime(); } }