Ejemplo n.º 1
0
        public override void SetupDialog(Dialog dialog, int style)
        {
            try
            {
                base.SetupDialog(dialog, style);
                View contentView = View.Inflate(Context, Resource.Layout.Style_Bottom_Sheet_Reply, null);
                dialog.SetContentView(contentView);
                var layoutParams = (CoordinatorLayout.LayoutParams)((View)contentView.Parent).LayoutParameters;
                var behavior     = layoutParams.Behavior;

                if (behavior != null && behavior.GetType() == typeof(BottomSheetBehavior))
                {
                    ((BottomSheetBehavior)behavior).SetBottomSheetCallback(MBottomSheetBehaviorCallback);
                }

                Instance = this;

                Type = Arguments.GetString("Type");

                if (Arguments.ContainsKey("Object"))
                {
                    Comment = JsonConvert.DeserializeObject <CommentObject>(Arguments.GetString("Object"));
                }

                if (Type == "video")
                {
                    ActivityContext = TabbedMainActivity.GetInstance();
                }

                InitComponent(contentView);
                SetRecyclerViewAdapters();

                CommentClickListener = new CommentClickListener(ActivityContext, "Reply");
                SendButton.Click    += SendButton_Click;
                LikeButton.Click    += OnLikeButtonClick;
                UnLikeButton.Click  += OnUnLikeButtonClick;

                LoadReplies();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Ejemplo n.º 2
0
        public void OnInput(MaterialDialog p0, ICharSequence p1)
        {
            try
            {
                if (p1.Length() > 0)
                {
                    var strName = p1.ToString();

                    if (!Methods.CheckConnectivity())
                    {
                        Toast.MakeText(MainContext, Context.GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                    }
                    else
                    {
                        if (TypeClass == "Comment")
                        {
                            //TypeClass
                            var adapterGlobal = MainContext?.CommentsFragment?.MAdapter;
                            var dataGlobal    = adapterGlobal?.CommentList?.FirstOrDefault(a => a.Id == CommentObject?.Id);
                            if (dataGlobal != null)
                            {
                                dataGlobal.Text = strName;
                                var index = adapterGlobal.CommentList.IndexOf(dataGlobal);
                                if (index > -1)
                                {
                                    adapterGlobal.NotifyItemChanged(index);
                                }
                            }

                            var adapterGlobal1 = GlobalPlayerActivity.GetInstance()?.CommentsFragment?.MAdapter;
                            var dataGlobal1    = adapterGlobal1?.CommentList?.FirstOrDefault(a => a.Id == CommentObject?.Id);
                            if (dataGlobal1 != null)
                            {
                                dataGlobal1.Text = strName;
                                var index = adapterGlobal1.CommentList.IndexOf(dataGlobal1);
                                if (index > -1)
                                {
                                    adapterGlobal1.NotifyItemChanged(index);
                                }
                            }
                            PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                                () => RequestsAsync.Comments.Edit_Comment_Http(CommentObject.Id.ToString(), strName)
                            });
                        }
                        else if (TypeClass == "Reply")
                        {
                            //TypeClass
                            var adapterGlobal = ReplyCommentBottomSheet.GetInstance()?.ReplyAdapter;
                            var dataGlobal    = adapterGlobal?.ReplyList?.FirstOrDefault(a => a.Id == ReplyObject?.Id);
                            if (dataGlobal != null)
                            {
                                dataGlobal.Text = strName;
                                var index = adapterGlobal.ReplyList.IndexOf(dataGlobal);
                                if (index > -1)
                                {
                                    adapterGlobal.NotifyItemChanged(index);
                                }
                            }

                            PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                                () => RequestsAsync.Comments.Edit_Comment_Reply_Http(ReplyObject.Id.ToString(), strName)
                            });
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Ejemplo n.º 3
0
        public void OnClick(MaterialDialog p0, DialogAction p1)
        {
            try
            {
                if (p1 == DialogAction.Positive)
                {
                    if (TypeDialog == "DeleteComment")
                    {
                        MainContext.RunOnUiThread(() =>
                        {
                            try
                            {
                                if (TypeClass == "Comment")
                                {
                                    //TypeClass
                                    var adapterGlobal = MainContext?.CommentsFragment?.MAdapter;
                                    var dataGlobal    = adapterGlobal?.CommentList?.FirstOrDefault(a => a.Id == CommentObject?.Id);
                                    if (dataGlobal != null)
                                    {
                                        var index = adapterGlobal.CommentList.IndexOf(dataGlobal);
                                        if (index > -1)
                                        {
                                            adapterGlobal.CommentList.RemoveAt(index);
                                            adapterGlobal.NotifyItemRemoved(index);
                                        }
                                    }

                                    var adapterGlobal1 = GlobalPlayerActivity.GetInstance()?.CommentsFragment?.MAdapter;
                                    var dataGlobal1    = adapterGlobal1?.CommentList?.FirstOrDefault(a => a.Id == CommentObject?.Id);
                                    if (dataGlobal1 != null)
                                    {
                                        var index = adapterGlobal1.CommentList.IndexOf(dataGlobal1);
                                        if (index > -1)
                                        {
                                            adapterGlobal1.CommentList.RemoveAt(index);
                                            adapterGlobal1.NotifyItemRemoved(index);
                                        }
                                    }

                                    PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                                        () => RequestsAsync.Comments.Delete_Comment_Http(CommentObject.Id.ToString())
                                    });
                                }
                                else if (TypeClass == "Reply")
                                {
                                    //TypeClass
                                    var adapterGlobal = ReplyCommentBottomSheet.GetInstance()?.ReplyAdapter;
                                    var dataGlobal    = adapterGlobal?.ReplyList?.FirstOrDefault(a => a.Id == ReplyObject?.Id);
                                    if (dataGlobal != null)
                                    {
                                        var index = adapterGlobal.ReplyList.IndexOf(dataGlobal);
                                        if (index > -1)
                                        {
                                            adapterGlobal.ReplyList.RemoveAt(index);
                                            adapterGlobal.NotifyItemRemoved(index);
                                        }
                                    }

                                    PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                                        () => RequestsAsync.Comments.Delete_Reply_Http(ReplyObject.Id.ToString())
                                    });
                                }

                                Toast.MakeText(MainContext, MainContext.GetText(Resource.String.Lbl_CommentSuccessfullyDeleted), ToastLength.Short).Show();
                            }
                            catch (Exception e)
                            {
                                Console.WriteLine(e);
                            }
                        });
                    }
                    else
                    {
                        if (p1 == DialogAction.Positive)
                        {
                        }
                        else if (p1 == DialogAction.Negative)
                        {
                            p0.Dismiss();
                        }
                    }
                }
                else if (p1 == DialogAction.Negative)
                {
                    p0.Dismiss();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }