private void BtnInterestedOnClick(object sender, EventArgs e)
        {
            try
            {
                if (!Methods.CheckConnectivity())
                {
                    Toast.MakeText(this, GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short)?.Show();
                    return;
                }

                switch (BtnInterested?.Tag?.ToString())
                {
                case "false":
                    BtnInterested.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends_pressed);
                    BtnInterested.SetTextColor(Color.ParseColor("#ffffff"));
                    BtnInterested.Text = GetText(Resource.String.Lbl_Interested);
                    BtnInterested.Tag  = "true";
                    break;

                default:
                    BtnInterested.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends);
                    BtnInterested.SetTextColor(Color.ParseColor(AppSettings.MainColor));
                    BtnInterested.Text = GetText(Resource.String.Lbl_Interested);
                    BtnInterested.Tag  = "false";
                    break;
                }

                var dataEvent = EventMainActivity.GetInstance()?.EventTab.MAdapter.EventList?.FirstOrDefault(a => a.Id == EventData.Id);
                if (dataEvent != null)
                {
                    dataEvent.IsInterested = Convert.ToBoolean(BtnInterested?.Tag?.ToString());
                }

                PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                    () => RequestsAsync.Event.InterestEventAsync(EventData.Id)
                });
            }
            catch (Exception exception)
            {
                Methods.DisplayReportResultTrack(exception);
            }
        }
Exemplo n.º 2
0
        private void Get_Data_Event()
        {
            try
            {
                if (EventData != null)
                {
                    Glide.With(this).Load(EventData.Cover).Apply(new RequestOptions()).Into(ImageEventCover);

                    Name = Methods.FunString.DecodeString(EventData.Name);

                    TxtName.Text           = Name;
                    ToolbarLayout.Title    = Name;
                    SupportActionBar.Title = Name;

                    if (string.IsNullOrEmpty(EventData.GoingCount))
                    {
                        EventData.GoingCount = "0";
                    }

                    if (string.IsNullOrEmpty(EventData.InterestedCount))
                    {
                        EventData.InterestedCount = "0";
                    }

                    TxtGoing.Text      = EventData.GoingCount + " " + GetText(Resource.String.Lbl_GoingPeople);
                    TxtInterested.Text = EventData.InterestedCount + " " + GetText(Resource.String.Lbl_InterestedPeople);
                    TxtLocation.Text   = EventData.Location;

                    TxtStartDate.Text = EventData.StartDate;
                    TxtEndDate.Text   = EventData.EndDate;


                    if (!string.IsNullOrEmpty(EventData.Description))
                    {
                        var description    = Methods.FunString.DecodeString(EventData.Description);
                        var readMoreOption = new StReadMoreOption.Builder()
                                             .TextLength(250, StReadMoreOption.TypeCharacter)
                                             .MoreLabel(GetText(Resource.String.Lbl_ReadMore))
                                             .LessLabel(GetText(Resource.String.Lbl_ReadLess))
                                             .MoreLabelColor(Color.ParseColor(AppSettings.MainColor))
                                             .LessLabelColor(Color.ParseColor(AppSettings.MainColor))
                                             .LabelUnderLine(true)
                                             .Build();
                        readMoreOption.AddReadMoreTo(TxtDescriptionText, new String(description));
                    }
                    else
                    {
                        TxtDescription.Visibility     = ViewStates.Gone;
                        TxtDescriptionText.Visibility = ViewStates.Gone;
                    }

                    if (EventData.IsGoing != null && EventData.IsGoing.Value)
                    {
                        BtnGo.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends_pressed);
                        BtnGo.SetTextColor(Color.ParseColor("#ffffff"));
                        BtnGo.Text = GetText(Resource.String.Lbl_Going);
                        BtnGo.Tag  = "true";
                    }
                    else
                    {
                        BtnGo.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends);
                        BtnGo.SetTextColor(Color.ParseColor(AppSettings.MainColor));
                        BtnGo.Text = GetText(Resource.String.Lbl_Go);
                        BtnGo.Tag  = "false";
                    }

                    if (EventData.IsInterested != null && EventData.IsInterested.Value)
                    {
                        BtnInterested.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends_pressed);
                        BtnInterested.SetTextColor(Color.ParseColor("#ffffff"));
                        BtnInterested.Text = GetText(Resource.String.Lbl_Interested);
                        BtnInterested.Tag  = "true";
                    }
                    else
                    {
                        BtnInterested.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends);
                        BtnInterested.SetTextColor(Color.ParseColor(AppSettings.MainColor));
                        BtnInterested.Text = GetText(Resource.String.Lbl_Interested);
                        BtnInterested.Tag  = "false";
                    }

                    //add post
                    var checkSection = PostFeedAdapter.ListDiffer.FirstOrDefault(a => a.TypeView == PostModelType.AddPostBox);
                    if (checkSection == null)
                    {
                        Combiner.AddPostBoxPostView("Event", -1, new PostDataObject()
                        {
                            Event = new EventUnion()
                            {
                                EventClass = EventData
                            }
                        });

                        PostFeedAdapter.NotifyItemInserted(PostFeedAdapter.ListDiffer.Count - 1);
                    }

                    StartApiService();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }