Example #1
0
        // Create new views (invoked by the layout manager)
        public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
        {
            try
            {
                //Setup your layout here >> Style_PageCircle_view
                View itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.Style_Comment, parent, false);


                var vh = new CommentAdapterViewHolder(itemView, OnClick, OnLongClick);
                return(vh);
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
                return(null);
            }
        }
Example #2
0
        private void OnUnLikeButtonClick(CommentAdapterViewHolder holder, CommentAdapterClickEventArgs e)
        {
            try
            {
                if (Methods.CheckConnectivity())
                {
                    if (UserDetails.IsLogin)
                    {
                        if (e.Class != null)
                        {
                            if (holder.UnLikeButton.Tag.ToString() == "1")
                            {
                                holder.UnLikeiconView.SetColorFilter(Color.ParseColor("#777777"));

                                holder.UnLikeButton.Tag   = "0";
                                e.Class.IsDislikedComment = 0;

                                if (!holder.UnLikeNumber.Text.Contains("K") && !holder.UnLikeNumber.Text.Contains("M"))
                                {
                                    double x = Convert.ToDouble(holder.UnLikeNumber.Text);
                                    if (x > 0)
                                    {
                                        x--;
                                    }
                                    else
                                    {
                                        x = 0;
                                    }
                                    holder.UnLikeNumber.Text = x.ToString(CultureInfo.InvariantCulture);
                                    e.Class.DisLikes         = Convert.ToInt32(x);
                                }
                            }
                            else
                            {
                                holder.UnLikeiconView.SetColorFilter(Color.ParseColor(AppSettings.MainColor));

                                holder.UnLikeButton.Tag   = "1";
                                e.Class.IsDislikedComment = 1;

                                if (!holder.UnLikeNumber.Text.Contains("K") && !holder.UnLikeNumber.Text.Contains("M"))
                                {
                                    double x = Convert.ToDouble(holder.UnLikeNumber.Text);
                                    x++;
                                    holder.UnLikeNumber.Text = x.ToString(CultureInfo.InvariantCulture);
                                    e.Class.DisLikes         = Convert.ToInt32(x);
                                }
                            }

                            if (holder.LikeButton.Tag.ToString() == "1")
                            {
                                holder.LikeiconView.SetColorFilter(Color.ParseColor("#777777"));

                                holder.LikeButton.Tag  = "0";
                                e.Class.IsLikedComment = 0;

                                if (!holder.LikeNumber.Text.Contains("K") && !holder.LikeNumber.Text.Contains("M"))
                                {
                                    double x = Convert.ToDouble(holder.LikeNumber.Text);
                                    if (x > 0)
                                    {
                                        x--;
                                    }
                                    else
                                    {
                                        x = 0;
                                    }

                                    holder.LikeNumber.Text = x.ToString(CultureInfo.InvariantCulture);
                                    e.Class.Likes          = Convert.ToInt32(x);
                                }
                            }
                            PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                                () => RequestsAsync.Comments.Add_likeOrDislike_Comment_Http(e.Class.Id.ToString(), false)
                            });
                        }
                    }
                    else
                    {
                        PopupDialogController dialog = new PopupDialogController(ActivityContext, null, "Login");
                        dialog.ShowNormalDialog(ActivityContext.GetText(Resource.String.Lbl_Warning),
                                                ActivityContext.GetText(Resource.String.Lbl_Please_sign_in_Dislike),
                                                ActivityContext.GetText(Resource.String.Lbl_Yes),
                                                ActivityContext.GetText(Resource.String.Lbl_No));
                    }
                }
                else
                {
                    Toast.MakeText(ActivityContext, ActivityContext.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }