Esempio n. 1
0
        public override void OnViewCreated(View view, Bundle savedInstanceState)
        {
            base.OnViewCreated(view, savedInstanceState);

            GetData(true);

            btnSend.Click += (sender, args) =>
            {
                if (string.IsNullOrEmpty(txtComment.Text))
                {
                    return;
                }

                ActivityProgresDialog.ShowProgressDialog();
                var apiTask = new ServiceApi().SaveComment(txtComment.Text, (Activity as PostDetailsActivity).PostId, expandedCommentId);
                apiTask.HandleError(ActivityProgresDialog);
                apiTask.OnSucess(ActivityProgresDialog, response =>
                {
                    txtComment.Text = "";
                    GetData(true);
                    ActivityProgresDialog.HideProgressDialog();
                });
            };
        }
Esempio n. 2
0
        void GetData(bool updateParent = false)
        {
            var apiTask = new ServiceApi().GetComments((Activity as PostDetailsActivity).PostId);

            apiTask.HandleError(ActivityProgresDialog);
            apiTask.OnSucess(ActivityProgresDialog, response =>
            {
                adapter               = new CustomListAdapter <Comment>(response.Result, GetView);
                adapter.Items         = CommentsHelper.GetCommentsWithReply(adapter.AllItems, expandedCommentId);
                adapter.NoContentText = "No Comments";
                lvComments.Adapter    = adapter;
                Count = response.Result.Count;
                ActivityProgresDialog.HideProgressDialog();
                if (updateParent)
                {
                    (Activity as PostDetailsActivity).SetHeaderInfo(Name, Count);
                }

                lvComments.Post(() =>
                {
                    lvComments.SetSelection(adapter.Items.Count - 1);
                });
            });
        }
        public void GetData()
        {
            if (lvScores == null)
            {
                return;
            }

            var filter = new ScoresFilterModel();

            filter.FollowFilter           = new FollowingFilterModel();
            filter.TeamId                 = TeamId;
            filter.SportId                = SportId;
            filter.SchoolId               = SchoolId;
            filter.FollowFilter.MySchools = mySchools;
            filter.FollowFilter.MySports  = mySports;
            filter.FollowFilter.MyTeams   = myTeams;
            filter.DateFilter             = dateFilter;
            //  var dt = DateTime.ParseExact("1/14/2018 12:00:00 AM", "M/d/yyyy h:mm:ss tt", CultureInfo.InvariantCulture);
            filter.Today = DateTime.Now.Date;
            //filter.Today = DateTime.UtcNow.Date;

            webLoadingIcon.Visibility = ViewStates.Visible;
            webLoadingIcon.SetBackgroundColor(new Color(227, 228, 230));
            webLoadingIcon.LoadUrl(string.Format("file:///android_asset/loader.gif"));

            Timer timer = new Timer();

            timer.Interval = 1000;
            timer.Start();
            timer.Elapsed += (object sender, ElapsedEventArgs e) => {
                webLoadingIcon.LoadUrl(string.Format("file:///android_asset/loader.gif"));
            };

            var apiTask = new ServiceApi().GetScores(filter);

            apiTask.HandleError(ActivityProgresDialog);

            apiTask.OnSucess(ActivityProgresDialog, response =>
            {
                ActivityProgresDialog.HideProgressDialog();
                if (lvScores.Adapter == null)
                {
                    adapter = new CustomListAdapter <ScoreModel>(response.Result, GetView);
                    adapter.SetViewTypes(GetViewType, 2);
                    adapter.NoContentText = "No Scores";
                    lvScores.Adapter      = adapter;
                    adapter.NotifyDataSetChanged();
                }
                else
                {
                    if (ScoreChanged != null)
                    {
                        ScoreChanged.Invoke(response.Result);
                    }
                    //adapter.Items = response.Result;
                    //adapter.NotifyDataSetChanged();
                }
                webLoadingIcon.Visibility = ViewStates.Invisible;
                timer.Stop();
            });

            ScoresFragment.ScoreChanged += (List <ScoreModel> obj) =>
            {
                List <ScoreModel> TempList = new List <ScoreModel>();
                TempList.Clear();
                foreach (var item in obj)
                {
                    DateTime eventDate = ConvertToUTC(item.EventDate, item.TimezoneId);
                    if (dateFilter == DateFilter.Today)
                    {
                        if (eventDate.Date < DateTime.Now.Date)
                        {
                            System.Console.Write("No");
                        }
                        else
                        {
                            TempList.Add(new ScoreModel()
                            {
                                EventDate       = eventDate,
                                EventId         = item.EventId,
                                EventName       = item.EventName,
                                IsTbd           = item.IsTbd,
                                PostCount       = item.PostCount,
                                ShowTicketUrl   = item.ShowTicketUrl,
                                SportName       = item.SportName,
                                SportProfileUrl = item.SportProfileUrl,
                                Team1Name       = item.Team1Name,
                                Team1Score      = item.Team1Score,
                                Team1Url        = item.Team1Url,
                                Team2Name       = item.Team2Name,
                                Team2Score      = item.Team2Score,
                                Team2Url        = item.Team2Url,
                                TeamCount       = item.TeamCount,
                                TicketUrl       = item.TicketUrl,
                                TimezoneId      = item.TimezoneId
                            });
                        }
                    }
                    else if (dateFilter == DateFilter.Upcoming)
                    {
                        if (eventDate.Date > DateTime.Now.Date)
                        {
                            TempList.Add(new ScoreModel()
                            {
                                EventDate       = eventDate,
                                EventId         = item.EventId,
                                EventName       = item.EventName,
                                IsTbd           = item.IsTbd,
                                PostCount       = item.PostCount,
                                ShowTicketUrl   = item.ShowTicketUrl,
                                SportName       = item.SportName,
                                SportProfileUrl = item.SportProfileUrl,
                                Team1Name       = item.Team1Name,
                                Team1Score      = item.Team1Score,
                                Team1Url        = item.Team1Url,
                                Team2Name       = item.Team2Name,
                                Team2Score      = item.Team2Score,
                                Team2Url        = item.Team2Url,
                                TeamCount       = item.TeamCount,
                                TicketUrl       = item.TicketUrl,
                                TimezoneId      = item.TimezoneId
                            });
                        }
                    }
                    else
                    {
                        TempList.Add(new ScoreModel()
                        {
                            EventDate       = eventDate,
                            EventId         = item.EventId,
                            EventName       = item.EventName,
                            IsTbd           = item.IsTbd,
                            PostCount       = item.PostCount,
                            ShowTicketUrl   = item.ShowTicketUrl,
                            SportName       = item.SportName,
                            SportProfileUrl = item.SportProfileUrl,
                            Team1Name       = item.Team1Name,
                            Team1Score      = item.Team1Score,
                            Team1Url        = item.Team1Url,
                            Team2Name       = item.Team2Name,
                            Team2Score      = item.Team2Score,
                            Team2Url        = item.Team2Url,
                            TeamCount       = item.TeamCount,
                            TicketUrl       = item.TicketUrl,
                            TimezoneId      = item.TimezoneId
                        });
                    }
                }

                var grouped = TempList.GroupBy(m => m.EventDate.ToString("D"));
                var items   = new List <ScoreModel>();
                foreach (var group in grouped)
                {
                    items.Add(new ScoreModel()
                    {
                        EventDate = Convert.ToDateTime(group.Key),
                        TeamCount = group.Count()
                    });
                    items.AddRange(group);
                }
                adapter.Items = items;
                adapter.NotifyDataSetChanged();
            };
        }