Example #1
0
        private void InitializeProfile()
        {
            ProfileDatabase db = new ProfileDatabase();
            Profile         p  = db.GetProfile();

            CanDistributePoints.Text = p.distribute.ToString();
        }
Example #2
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);
            }
Example #3
0
        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;
            }
        }
Example #4
0
            protected override Java.Lang.Void RunInBackground(params Profile[] @params)
            {
                Profile         profile = @params[0];
                ProfileDatabase db      = new ProfileDatabase();

                db.Update(profile);
                return(null);
            }
Example #5
0
        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);
        }
Example #6
0
        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);
        }
Example #7
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);
            }
        }
Example #8
0
        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);
                }
            }
        }
Example #9
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;
        }
Example #10
0
        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();
        }
Example #11
0
            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);
            }
Example #12
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;
            }
        }
Example #13
0
        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]);
            }
        }