private void InitializeProfile() { ProfileDatabase db = new ProfileDatabase(); Profile p = db.GetProfile(); CanDistributePoints.Text = p.distribute.ToString(); }
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 MainToolbar_MenuItemClick(object sender, SupportToolBar.MenuItemClickEventArgs e) { switch (e.Item.ItemId) { case Resource.Id.menu_logout: ProgressDialog dialog = ProgressDialog.Show(this, "", "Logging out..."); await MeritMoneyBrain.LogOut(); ProfileDatabase pdb = new ProfileDatabase(); pdb.DeleteDatabase(); UsersDatabase udb = new UsersDatabase(); udb.DeleteDatabase(); ISharedPreferences info = Application.Context.GetSharedPreferences(Application.Context.GetString(Resource.String.ApplicationInfo), FileCreationMode.Private); ISharedPreferencesEditor editor = info.Edit(); editor.Clear(); editor.Apply(); dialog.Dismiss(); Intent LogInIntent = new Intent(this, typeof(LogInActivity)); this.StartActivityForResult(LogInIntent, LOG_IN_REQUEST); break; } }
protected override Java.Lang.Void RunInBackground(params Profile[] @params) { Profile profile = @params[0]; ProfileDatabase db = new ProfileDatabase(); db.Update(profile); return(null); }
private void InitializeProfile() { ProfileDatabase db = new ProfileDatabase(); Profile p = db.GetProfile(); UserName.Text = p.name; UserEmail.Text = p.email; NotificationSwitch.Checked = p.emailNotificaion; new CacheUserAvatar(UserAvatar, Application.Context).Execute(p); }
private void InitializeProfile() { ProfileDatabase db = new ProfileDatabase(); Profile p = db.GetProfile(); UserName.Text = p.name; UserEmail.Text = p.email; Balance.Text = p.balance.ToString(); Rewards.Text = p.rewards.ToString(); Distribute.Text = p.distribute.ToString(); new CacheUserAvatar(UserAvatar, Application.Context).Execute(p); }
private async Task HandleResult() { if (EditName.Text != String.Empty) { UserName.Text = EditName.Text; EditName.Text = String.Empty; } if (SaveSwitchState != NotificationSwitch.Checked) { SwitchWasChanged = true; } else { SwitchWasChanged = false; } if (SaveName != UserName.Text) { nameWasChanged = true; } else { nameWasChanged = false; } if (AvatarWasChanged) { new UploadAvatarOnServer(UserAvatar).Execute().Get(); AvatarWasChanged = false; } if (SwitchWasChanged && !nameWasChanged) { Profile p = await MeritMoneyBrain.updateProfile(String.Empty, SwitchWasChanged, NotificationSwitch.Checked); p.AvatarIsDefault = OperationWithBitmap.isDefault(p.imageUri); ProfileDatabase db = new ProfileDatabase(); db.Update(p); } if (nameWasChanged) { Profile p = await MeritMoneyBrain.updateProfile(UserName.Text, SwitchWasChanged, NotificationSwitch.Checked); ProfileDatabase db = new ProfileDatabase(); db.Update(p); } }
public UsersAdapter(List <UserListItem> users, SearchPersonActivity activity) { MeritMoneyUsers = users; this.activity = activity; ProfileDatabase db = new ProfileDatabase(); curUserId = db.GetProfile().ID; for (int i = 0; i < MeritMoneyUsers.Count; i++) { if (MeritMoneyUsers[i].ID == curUserId) { MeritMoneyUsers.RemoveAt(i); } } }
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; }
public void AddNewList(List <UserListItem> list) { ProfileDatabase pdb = new ProfileDatabase(); String curId = pdb.GetProfile().ID; for (int i = 0; i < list.Count; i++) { if (curId == list[i].ID) { list.RemoveAt(i); } } MeritMoneyUsers.Clear(); MeritMoneyUsers.AddRange(list); NotifyDataSetChanged(); }
protected override Java.Lang.Void RunInBackground(params Profile[] @params) { Profile profile = @params[0]; ISharedPreferences info = Application.Context.GetSharedPreferences(Application.Context.GetString(Resource.String.ApplicationInfo), FileCreationMode.Private); ISharedPreferencesEditor edit = info.Edit(); edit.PutString(Application.Context.GetString(Resource.String.CurrentAccessToken), MeritMoneyBrain.CurrentAccessToken); edit.Apply(); profile.AvatarIsDefault = OperationWithBitmap.isDefault(profile.imageUri); ProfileDatabase db = new ProfileDatabase(); db.CreateDatabase(); db.Insert(profile); return(null); }
public async void OnClick(IDialogInterface dialog, int which) { switch (which) { case (int)DialogButtonType.Neutral: dialog.Dismiss(); NumberOfPoints.Text = String.Empty; SendPointsButton.Enabled = false; break; case (int)DialogButtonType.Positive: try { ProfileDatabase pdb = new ProfileDatabase(); if (Convert.ToInt64(NumberOfPoints.Text) > pdb.GetProfile().distribute) { Toast.MakeText(this, "Unavailible points amount.", ToastLength.Short).Show(); break; } } catch (Exception) { Toast.MakeText(this, "Too many points to send.", ToastLength.Short).Show(); break; } ProgressDialog progressDialog = ProgressDialog.Show(this, "", "Sending points...", true); String name = userNameToDistribute.Text; userNameToDistribute.Text = String.Empty; String number = NumberOfPoints.Text; NumberOfPoints.Text = String.Empty; String notes = Notes.Text; Profile p = await MeritMoneyBrain.DistributePoints(number, userIDtoDistribute, notes); p.AvatarIsDefault = OperationWithBitmap.isDefault(p.imageUri); ProfileDatabase db = new ProfileDatabase(); db.Update(p); new UpdateProfileData(this, progressDialog, number, name).Execute(p); break; } }
public void AddList(List <UserListItem> list) { ProfileDatabase pdb = new ProfileDatabase(); String curId = pdb.GetProfile().ID; for (int i = 0; i < list.Count; i++) { if (curId == list[i].ID) { list.RemoveAt(i); } } int startingPos = MeritMoneyUsers.Count(); MeritMoneyUsers.AddRange(list); NotifyItemRangeInserted(startingPos, list.Count()); for (int i = startingPos; i < startingPos + list.Count(); i++) { new CacheListItemImage(this, i, Application.Context).Execute(MeritMoneyUsers[i]); } }