private async void HandleSignInResult(GoogleSignInResult result) { if (result.IsSuccess) { // Signed in successfully, show authenticated UI. ProgressDialog progressDialog = ProgressDialog.Show(this, "", "Retrieving profile data", true); GoogleSignInAccount acct = result.SignInAccount; await MeritMoneyBrain.SingInWithGoogle(acct.IdToken); Profile profile = await MeritMoneyBrain.GetProfile(); Intent returnIntent = new Intent(); returnIntent.PutExtra(GetString(Resource.String.LogIn), true); SetResult(Result.Ok, returnIntent); await new SaveData().Execute(profile).GetAsync(); progressDialog.Dismiss(); Finish(); //updateUI(true); } else { // Signed out, show unauthenticated UI. //updateUI(false); } }
protected override async Task <Java.Lang.Void> RunInBackground(params Java.Lang.Void[] @params) { ISharedPreferences info = Application.Context.GetSharedPreferences(context.GetString(Resource.String.ApplicationInfo), FileCreationMode.Private); bool LoggedIn = info.GetBoolean(context.GetString(Resource.String.LogIn), false); MeritMoneyBrain.CurrentAccessToken = info.GetString(context.GetString(Resource.String.CurrentAccessToken), String.Empty); if (context.NetworkStatus.State != NetworkState.Disconnected) { if (LoggedIn) { Profile p = await MeritMoneyBrain.GetProfile(); p.AvatarIsDefault = OperationWithBitmap.isDefault(p.imageUri); ProfileDatabase db = new ProfileDatabase(); db.Update(p); } context.StartActivity(new Intent(Application.Context, typeof(MainActivity))); } else { await Task.Delay(500); context.StartActivity(new Intent(Application.Context, typeof(NoInternetActivity))); } return(null); }
private async void Profile_Refresh(object sender, EventArgs e) { if (NetworkStatus.State != NetworkState.Disconnected) { Profile profile = await MeritMoneyBrain.GetProfile(); ProfileDatabase db = new ProfileDatabase(); db.Update(profile); InitializeProfile(); } else { Toast.MakeText(this, GetString(Resource.String.NoInternet), ToastLength.Short).Show(); } RefreshInfo.Refreshing = false; }