Esempio n. 1
0
        private void PostAdapter_ItemLongClick(object sender, PostAdapterClickEventArgs e)
        {
            string postID  = ListOfPost[e.Position].ID;
            string ownerID = ListOfPost[e.Position].OwnerId;

            if (AppDataHelper.GetFirebaseAuth().CurrentUser.Uid == ownerID)
            {
                Android.Support.V7.App.AlertDialog.Builder alert = new Android.Support.V7.App.AlertDialog.Builder(this);
                alert.SetTitle("Edit or Delete Post");
                alert.SetMessage("Are you sure");

                alert.SetNegativeButton("Edit Post", (o, args) =>
                {
                    EditPostFragment editPostFragment = new EditPostFragment(ListOfPost[e.Position]);
                    var trans = SupportFragmentManager.BeginTransaction();
                    editPostFragment.Show(trans, "edit");
                });

                alert.SetPositiveButton("Delete", (o, args) =>
                {
                    AppDataHelper.GetFirestore().Collection("posts").Document(postID).Delete();

                    StorageReference storageReference = FirebaseStorage.Instance.GetReference("postImages/" + postID);
                    storageReference.Delete();
                });
                alert.Show();
            }
        }