Example #1
0
        private void LoadData()
        {
            try
            {
                if (!string.IsNullOrEmpty(Arguments.GetString("DataItemActivity")))
                {
                    ItemActivity = JsonConvert.DeserializeObject <ActivitiesObject>(Arguments.GetString("DataItemActivity"));
                    if (ItemActivity != null)
                    {
                        GlideImageLoader.LoadImage(Activity, ItemActivity.Image, ImageAct, ImageStyle.CenterCrop, ImagePlaceholders.Drawable);

                        var dataChannel = ItemActivity.UserData;
                        if (dataChannel != null)
                        {
                            ItemActivity.UserData = dataChannel;

                            GlideImageLoader.LoadImage(Activity, dataChannel.Avatar, ImageUser, ImageStyle.CircleCrop, ImagePlaceholders.Drawable);
                            NameUser.Text = AppTools.GetNameFinal(dataChannel);
                        }

                        TimeUser.Text = Methods.Time.TimeAgo(Convert.ToInt32(ItemActivity.Time), false);

                        ContentAct.Text = Methods.FunString.DecodeString(ItemActivity.Text);

                        switch (ItemActivity.IsLiked)
                        {
                        case "0":
                            FontUtils.SetTextViewIcon(FontsIconFrameWork.FontAwesomeRegular, IconLikeAct, FontAwesomeIcon.ThumbsUp);
                            IconLikeAct.SetTextColor(Color.ParseColor("#444444"));
                            LikeActLayout.Tag = "Like";
                            break;

                        case "1":
                            FontUtils.SetTextViewIcon(FontsIconFrameWork.FontAwesomeSolid, IconLikeAct, FontAwesomeIcon.ThumbsUp);
                            IconLikeAct.SetTextColor(Color.ParseColor("#4caf50"));
                            LikeActLayout.Tag = "Liked";
                            break;

                        default:
                            FontUtils.SetTextViewIcon(FontsIconFrameWork.FontAwesomeRegular, IconLikeAct, FontAwesomeIcon.ThumbsUp);
                            IconLikeAct.SetTextColor(Color.ParseColor("#444444"));
                            LikeActLayout.Tag = "Like";
                            break;
                        }

                        CountLikeAct.Text = Methods.FunString.FormatPriceValue(Convert.ToInt32(ItemActivity.Likes));

                        switch (ItemActivity.IsDisliked)
                        {
                        case "0":
                            FontUtils.SetTextViewIcon(FontsIconFrameWork.FontAwesomeRegular, IconDislikeAct, FontAwesomeIcon.ThumbsDown);
                            IconDislikeAct.SetTextColor(Color.ParseColor("#444444"));
                            DislikeActLayout.Tag = "Dislike";
                            break;

                        case "1":
                            FontUtils.SetTextViewIcon(FontsIconFrameWork.FontAwesomeSolid, IconDislikeAct, FontAwesomeIcon.ThumbsDown);
                            IconDislikeAct.SetTextColor(Color.ParseColor("#4caf50"));
                            DislikeActLayout.Tag = "Disliked";
                            break;

                        default:
                            FontUtils.SetTextViewIcon(FontsIconFrameWork.FontAwesomeRegular, IconDislikeAct, FontAwesomeIcon.ThumbsDown);
                            IconDislikeAct.SetTextColor(Color.ParseColor("#444444"));
                            DislikeActLayout.Tag = "Dislike";
                            break;
                        }

                        CountDislikeAct.Text = Methods.FunString.FormatPriceValue(Convert.ToInt32(ItemActivity.Dislikes));

                        FontUtils.SetTextViewIcon(FontsIconFrameWork.FontAwesomeRegular, IconCommentAct, FontAwesomeIcon.CommentDots);
                        CountCommentAct.Text = Methods.FunString.FormatPriceValue(Convert.ToInt32(ItemActivity.CommentsCount));

                        StartApiService();
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Example #2
0
        //Like
        private void LikeActLayoutOnClick(object sender, EventArgs e)
        {
            try
            {
                if (Methods.CheckConnectivity())
                {
                    if (UserDetails.IsLogin)
                    {
                        if (ItemActivity == null)
                        {
                            return;
                        }

                        ItemActivity.IsLiked = ItemActivity.IsLiked switch
                        {
                            "0" => "1",
                            "1" => "0",
                            _ => "1"
                        };

                        switch (ItemActivity.IsLiked)
                        {
                        case "0":
                            FontUtils.SetTextViewIcon(FontsIconFrameWork.FontAwesomeRegular, IconLikeAct, FontAwesomeIcon.ThumbsUp);
                            IconLikeAct.SetTextColor(Color.ParseColor("#444444"));
                            LikeActLayout.Tag = "Like";
                            break;

                        case "1":
                            FontUtils.SetTextViewIcon(FontsIconFrameWork.FontAwesomeSolid, IconLikeAct, FontAwesomeIcon.ThumbsUp);
                            IconLikeAct.SetTextColor(Color.ParseColor("#4caf50"));
                            LikeActLayout.Tag = "Liked";
                            break;

                        default:
                            FontUtils.SetTextViewIcon(FontsIconFrameWork.FontAwesomeRegular, IconLikeAct, FontAwesomeIcon.ThumbsUp);
                            IconLikeAct.SetTextColor(Color.ParseColor("#444444"));
                            LikeActLayout.Tag = "Like";
                            break;
                        }

                        switch (LikeActLayout.Tag.ToString())
                        {
                        case "Liked":
                        {
                            if (!ItemActivity.Likes.Contains("K") && !ItemActivity.Likes.Contains("M"))
                            {
                                var x = Convert.ToDouble(ItemActivity.Likes);
                                x++;
                                ItemActivity.Likes = x.ToString(CultureInfo.CurrentCulture);
                            }
                            break;
                        }

                        case "Like":
                        {
                            if (!ItemActivity.Likes.Contains("K") && !ItemActivity.Likes.Contains("M"))
                            {
                                var x = Convert.ToDouble(ItemActivity.Likes);
                                if (x > 0)
                                {
                                    x--;
                                }
                                else
                                {
                                    x = 0;
                                }

                                ItemActivity.Likes = x.ToString(CultureInfo.CurrentCulture);
                            }
                            break;
                        }
                        }

                        CountLikeAct.Text = Methods.FunString.FormatPriceValue(Convert.ToInt32(ItemActivity.Likes));

                        if (ItemActivity.IsDisliked == "1")
                        {
                            ItemActivity.IsDisliked = "0";
                            FontUtils.SetTextViewIcon(FontsIconFrameWork.FontAwesomeRegular, IconDislikeAct, FontAwesomeIcon.ThumbsDown);
                            IconDislikeAct.SetTextColor(Color.ParseColor("#444444"));
                            DislikeActLayout.Tag = "Dislike";

                            if (!ItemActivity.Dislikes.Contains("K") && !ItemActivity.Dislikes.Contains("M"))
                            {
                                var x = Convert.ToDouble(ItemActivity.Dislikes);
                                if (x > 0)
                                {
                                    x--;
                                }
                                else
                                {
                                    x = 0;
                                }

                                ItemActivity.Dislikes = x.ToString(CultureInfo.CurrentCulture);
                            }
                        }

                        CountDislikeAct.Text = Methods.FunString.FormatPriceValue(Convert.ToInt32(ItemActivity.Dislikes));

                        if (!Methods.CheckConnectivity())
                        {
                            Toast.MakeText(Activity, Activity.GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                        }
                        else
                        {
                            PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                                () => RequestsAsync.Activities.LikeActivity_Http(ItemActivity.Id)
                            });
                        }
                    }
                    else
                    {
                        PopupDialogController dialog = new PopupDialogController(Activity, null, "Login");
                        dialog.ShowNormalDialog(Activity.GetText(Resource.String.Lbl_Warning), Activity.GetText(Resource.String.Lbl_Please_sign_in_Dislike), Activity.GetText(Resource.String.Lbl_Yes), Activity.GetText(Resource.String.Lbl_No));
                    }
                }
                else
                {
                    Toast.MakeText(Activity, Activity.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }