예제 #1
0
            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);
            }
예제 #2
0
            protected override Java.Lang.Void RunInBackground(params Profile[] @params)
            {
                Profile         profile = @params[0];
                ProfileDatabase db      = new ProfileDatabase();

                db.Update(profile);
                return(null);
            }
예제 #3
0
        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);
            }
        }
예제 #4
0
        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;
        }
예제 #5
0
        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;
            }
        }