public void doUpdate()
        {
            entity.text   = updateText.Text;
            entity.author = new KinveyReference <KinveyXamarin.User> ("user", KinveyService.getCurrentUserId());

            //byte[] bytes;
            //using (var stream = new MemoryStream())
            //{
            //	((StatusShare)Activity).bitmap.Compress(Bitmap.CompressFormat.Png, 0, stream);
            //	bytes = stream.ToArray();
            //}

            //((StatusShare)Activity).bitmap.

            var stream = new MemoryStream();

            ((StatusShare)Activity).bitmap.Compress(Bitmap.CompressFormat.Png, 0, stream);


            KinveyService.saveUpdate(entity, stream, new KinveyXamarin.KinveyDelegate <UpdateEntity>()
            {
                onSuccess = (update) => {
                    Activity.RunOnUiThread(() => {
                        Toast.MakeText(this.Activity, "uplaoded: " + update.ID, ToastLength.Short).Show();
                        ((StatusShare)this.Activity).ReplaceFragment(new ShareListFragment(), false);
                    });
                },
                onError = (error) => {
                    Activity.RunOnUiThread(() => {
                        Toast.MakeText(this.Activity, "something went wrong: " + error.Message, ToastLength.Short).Show();
                    });
                }
            });
        }
Esempio n. 2
0
        private void setAdapter()
        {
            loading.Visibility = ViewStates.Gone;

            if (((StatusShare)this.Activity).shareList == null || ((StatusShare)this.Activity).shareList.Length == 0)
            {
                empty.Visibility = ViewStates.Visible;
            }
            else
            {
                this.adapter         = new UpdateAdapter(this.Activity, ((StatusShare)this.Activity).shareList, this.Activity.LayoutInflater);
                this.list.Adapter    = this.adapter;
                this.list.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => {
                    ((StatusShare)this.Activity).ReplaceFragment(UpdateDetailsFragment.newInstance((StatusShare)this.Activity, e.Position), true);
                };

//				for (int i = 0; i < adapter.Count; i++){
//					adapter.GetItem (i).loadThumbnail (this.Activity, KinveyService.getClient (), adapter);
//				}

                foreach (UpdateEntity update in  ((StatusShare)this.Activity).shareList)
                {
                    update.loadThumbnail(this.Activity, KinveyService.getClient(), adapter);
                }
            }
        }
Esempio n. 3
0
        private void loadUpdates()
        {
            loading.Visibility = ViewStates.Visible;
            empty.Visibility   = ViewStates.Gone;

            KinveyService.getUpdates(new KinveyDelegate <UpdateEntity[]> {
                onSuccess = (updates) => {
                    this.Activity.RunOnUiThread(() => {
                        ((StatusShare)this.Activity).shareList = updates;
                        setAdapter();
                    });
                },
                onError = (error) => {}
            });
        }
        public override void bindViews(View v)
        {
            username = v.FindViewById <EditText> (Resource.Id.et_login);
            password = v.FindViewById <EditText> (Resource.Id.et_password);

            loginButton        = v.FindViewById <Button> (Resource.Id.login);
            loginButton.Click += (object sender, EventArgs e) => {
                KinveyService.login(username.Text, password.Text, new KinveyDelegate <User> {
                    onSuccess = (user) => {
                        Activity.RunOnUiThread(() => {
                            Toast.MakeText(this.Activity, "logged in as: " + user.Id, ToastLength.Short).Show();
                            loggedIn();
                        });
                    },
                    onError = (error) => {
                        Activity.RunOnUiThread(() => {
                            Toast.MakeText(this.Activity, "something went wrong: " + error.Message, ToastLength.Short).Show();
                        });
                    }
                });
            };

            registerButton        = v.FindViewById <Button> (Resource.Id.login_register);
            registerButton.Click += (sender, e) => {
                KinveyService.register(username.Text, password.Text, new KinveyDelegate <User> {
                    onSuccess = (user) => {
                        Activity.RunOnUiThread(() => {
                            Toast.MakeText(this.Activity, "created: " + user.Id, ToastLength.Short).Show();
                            loggedIn();
                        });
                    },
                    onError = (error) => {
                        Activity.RunOnUiThread(() => {
                            Toast.MakeText(this.Activity, "something went wrong: " + error.Message, ToastLength.Short).Show();
                        });
                    }
                });
            };
        }
Esempio n. 5
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            switch (item.ItemId)
            {
            case Resource.Id.menu_status_post:
                ((StatusShare)Activity).ReplaceFragment(new UpdateEditFragment(), true);
                return(true);

            case Resource.Id.menu_refresh:
                adapter = null;
                loadUpdates();
                return(true);

            case Resource.Id.menu_sign_out:
                KinveyService.logout();
                Activity.Finish();

                return(true);
            }

            return(base.OnOptionsItemSelected(item));
        }