private void SetDataPost() { try { TxtDescription.Text = Methods.FunString.DecodeString(PostData.Orginaltext); if (PostData.IsLiked != null && (bool)PostData.IsLiked) { BtnLike.Tag = "true"; ImgLike.SetColorFilter(Color.ParseColor(AppSettings.MainColor)); } else { BtnLike.Tag = "false"; ImgLike.SetColorFilter(Color.White); } if (PostData.IsWondered != null && (bool)PostData.IsWondered) { BtnWonder.Tag = "true"; ImgWonder.SetColorFilter(Color.ParseColor("#f89823")); ImgObeeNetwork.SetColorFilter(Color.ParseColor("#f89823")); TxtWonder.Text = GetText(Resource.String.Lbl_wondered); } else { BtnWonder.Tag = "false"; ImgWonder.SetColorFilter(Color.White); ImgObeeNetwork.SetColorFilter(Color.White); TxtWonder.Text = GetText(Resource.String.Btn_Wonder); } TxtCountObeeNetwork.Text = Methods.FunString.FormatPriceValue(int.Parse(PostData.PostWonders)); if (AppSettings.PostButton == PostButtonSystem.Reaction) { if (PostData.Reaction == null) { PostData.Reaction = new ObeeNetworkClient.Classes.Posts.Reaction(); } TxtCountLike.Text = Methods.FunString.FormatPriceValue(PostData.Reaction.Count); if ((bool)(PostData.Reaction != null & PostData.Reaction?.IsReacted)) { if (!string.IsNullOrEmpty(PostData.Reaction.Type)) { switch (PostData.Reaction.Type) { case "1": case "Like": LikeButton.SetReactionPack(ReactConstants.Like); break; case "2": case "Love": LikeButton.SetReactionPack(ReactConstants.Love); break; case "3": case "HaHa": LikeButton.SetReactionPack(ReactConstants.HaHa); break; case "4": case "WoW": LikeButton.SetReactionPack(ReactConstants.Wow); break; case "5": case "Sad": LikeButton.SetReactionPack(ReactConstants.Sad); break; case "6": case "Angry": LikeButton.SetReactionPack(ReactConstants.Angry); break; default: LikeButton.SetReactionPack(ReactConstants.Default); break; } } } else { LikeButton.SetDefaultReaction(XReactions.GetDefaultReact()); LikeButton.SetTextColor(Color.White); } } else { if (PostData.IsLiked != null && (bool)PostData.IsLiked) { LikeButton.SetReactionPack(ReactConstants.Like); } TxtCountLike.Text = Methods.FunString.FormatPriceValue(int.Parse(PostData.PostLikes)); if (AppSettings.PostButton == PostButtonSystem.Wonder) { if (PostData.IsWondered != null && (bool)PostData.IsWondered) { ImgWonder.SetImageResource(Resource.Drawable.ic_action_ObeeNetwork); ImgWonder.SetColorFilter(Color.ParseColor(AppSettings.MainColor)); TxtWonder.Text = GetString(Resource.String.Lbl_wondered); TxtWonder.SetTextColor(Color.ParseColor(AppSettings.MainColor)); } else { ImgWonder.SetImageResource(Resource.Drawable.ic_action_ObeeNetwork); ImgWonder.SetColorFilter(Color.White); TxtWonder.Text = GetString(Resource.String.Btn_Wonder); TxtWonder.SetTextColor(Color.ParseColor("#444444")); } } else if (AppSettings.PostButton == PostButtonSystem.DisLike) { if (PostData.IsWondered != null && (bool)PostData.IsWondered) { ImgWonder.SetImageResource(Resource.Drawable.ic_action_dislike); ImgWonder.SetColorFilter(Color.ParseColor(AppSettings.MainColor)); TxtWonder.Text = GetString(Resource.String.Lbl_disliked); TxtWonder.SetTextColor(Color.ParseColor(AppSettings.MainColor)); } else { ImgWonder.SetImageResource(Resource.Drawable.ic_action_dislike); ImgWonder.SetColorFilter(Color.White); TxtWonder.Text = GetString(Resource.String.Btn_Dislike); TxtWonder.SetTextColor(Color.ParseColor("#444444")); } } } } catch (Exception e) { Console.WriteLine(e); } }
//Event Add Wonder private void BtnWonderOnClick(object sender, EventArgs e) { try { if (!Methods.CheckConnectivity()) { Toast.MakeText(Application.Context, Application.Context.GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show(); return; } if (PostData.IsWondered != null && (bool)PostData.IsWondered) { var x = Convert.ToInt32(PostData.PostWonders); if (x > 0) { x--; } else { x = 0; } ImgWonder.SetColorFilter(Color.White); ImgObeeNetwork.SetColorFilter(Color.White); PostData.IsWondered = false; PostData.PostWonders = Convert.ToString(x, CultureInfo.InvariantCulture); TxtCountObeeNetwork.Text = Methods.FunString.FormatPriceValue(x); if (AppSettings.PostButton == PostButtonSystem.Wonder) { TxtWonder.Text = GetText(Resource.String.Btn_Wonder); } else if (AppSettings.PostButton == PostButtonSystem.DisLike) { TxtWonder.Text = GetText(Resource.String.Btn_Dislike); } BtnWonder.Tag = "false"; } else { var x = Convert.ToInt32(PostData.PostWonders); x++; PostData.PostWonders = Convert.ToString(x, CultureInfo.InvariantCulture); PostData.IsWondered = true; ImgWonder.SetColorFilter(Color.ParseColor("#f89823")); ImgObeeNetwork.SetColorFilter(Color.ParseColor("#f89823")); TxtCountObeeNetwork.Text = Methods.FunString.FormatPriceValue(x); if (AppSettings.PostButton == PostButtonSystem.Wonder) { TxtWonder.Text = GetText(Resource.String.Lbl_wondered); } else if (AppSettings.PostButton == PostButtonSystem.DisLike) { TxtWonder.Text = GetText(Resource.String.Lbl_disliked); } BtnWonder.Tag = "true"; } TxtCountObeeNetwork.Text = Methods.FunString.FormatPriceValue(int.Parse(PostData.PostWonders)); if (AppSettings.PostButton == PostButtonSystem.Wonder) { PollyController.RunRetryPolicyFunction(new List <Func <Task> > { () => RequestsAsync.Global.Post_Actions(PostData.PostId, "wonder") }); } else if (AppSettings.PostButton == PostButtonSystem.DisLike) { PollyController.RunRetryPolicyFunction(new List <Func <Task> > { () => RequestsAsync.Global.Post_Actions(PostData.PostId, "dislike") }); } } catch (Exception exception) { Console.WriteLine(exception); } }