Beispiel #1
0
        private void OrderHistory(TraktActivity activity, ActivityListItemViewModel tempModel)
        {
            if (sortedOrderHistory == null)
            {
                sortedOrderHistory = new Dictionary <DateTime, List <ActivityListItemViewModel> >();
            }


            DateTime time = new DateTime(1970, 1, 1, 0, 0, 9, DateTimeKind.Utc);

            time = time.AddSeconds(activity.TimeStamp);
            time = time.ToLocalTime();
            DateTime onlyDay = new DateTime(time.Year, time.Month, time.Day);

            tempModel.Date = onlyDay;

            if (sortedOrderHistory.ContainsKey(onlyDay))
            {
                sortedOrderHistory[onlyDay].Add(tempModel);
            }
            else
            {
                List <ActivityListItemViewModel> tempList = new List <ActivityListItemViewModel>();
                tempList.Add(tempModel);
                sortedOrderHistory.Add(onlyDay, tempList);
            }
        }
Beispiel #2
0
        private void HistoryList_ItemUnrealized(object sender, ItemRealizationEventArgs e)
        {
            ActivityListItemViewModel model = (ActivityListItemViewModel)e.Container.DataContext;

            model.ClearScreenImage();
            model.hasBeenUnrealized = true;
        }
Beispiel #3
0
        private void CreateHistoryList(List <TraktActivity> newsFeedActivity)
        {
            int counter = 0;

            sortedOrderHistory = null;
            newsFeedActivity.Sort(TraktActivity.ActivityComparison);
            foreach (TraktActivity activity in newsFeedActivity)
            {
                ActivityListItemViewModel tempModel = null;

                if (counter++ <= 60)
                {
                    switch (activity.Action)
                    {
                    case "checkin":
                        tempModel = Checkin(activity);
                        break;

                    case "scrobble":
                        tempModel = Scrobble(activity);
                        break;
                    }

                    if (tempModel != null)
                    {
                        OrderHistory(activity, tempModel);
                    }
                }
            }

            if (sortedOrderHistory != null)
            {
                foreach (DateTime key in sortedOrderHistory.Keys)
                {
                    Boolean isFirst = true;

                    foreach (ActivityListItemViewModel model in sortedOrderHistory[key])
                    {
                        if (isFirst)
                        {
                            model.HasHeader = true;
                            isFirst         = false;
                        }

                        App.CheckinHistoryViewModel.HistoryItems.Add(model);
                    }
                }
            }

            if (newsFeedActivity.Count == 0)
            {
                ToastNotification.ShowToast("User", "History list is empty!");
            }

            App.CheckinHistoryViewModel.NotifyPropertyChanged("HistoryItems");
            indicator.IsVisible = false;
        }
Beispiel #4
0
        private void HistoryList_ItemRealized(object sender, ItemRealizationEventArgs e)
        {
            ActivityListItemViewModel model = (ActivityListItemViewModel)e.Container.DataContext;

            model.LoadScreenImage();

            if (model.IsAlmostLastDay && !model.hasBeenUnrealized)
            {
                if (!this.isFilter)
                {
                    CreateHistoryList(this.newsFeedActivity, timesLoaded++ *6);
                }
                else
                {
                    FilterHistory(this.lastSelection, timesLoaded++ *6);
                }
            }
        }
Beispiel #5
0
        private void HistoryRate_Click(object sender, RoutedEventArgs e)
        {
            ActivityListItemViewModel model = (ActivityListItemViewModel)((MenuItem)sender).DataContext;

            switch (model.Type)
            {
            case "movie":
                NavigationService.Navigate(new Uri("/RatingSelector.xaml?type=movie&imdb=" + model.Imdb + "&year=" + model.Year + "&title=" + model.Name, UriKind.Relative));
                break;

            case "show":
                NavigationService.Navigate(new Uri("/RatingSelector.xaml?type=show&imdb=" + model.Imdb + "&tvdb=" + model.Tvdb + "&year=" + model.Year + "&title=" + model.Name, UriKind.Relative));
                break;

            case "episode":
                NavigationService.Navigate(new Uri("/RatingSelector.xaml?type=episode&imdb=" + model.Imdb + "&tvdb=" + model.Tvdb + "&year=" + model.Year + "&title=" + model.Name + "&season=" + model.Season + "&episode=" + model.Episode, UriKind.Relative));
                break;
            }
        }
Beispiel #6
0
        private void Grid_Tap_1(object sender, System.Windows.Input.GestureEventArgs e)
        {
            ActivityListItemViewModel model = (ActivityListItemViewModel)((Grid)sender).DataContext;

            Uri redirectUri = null;

            if (model.Type != null)
            {
                if (model.Type.Equals("episode"))
                {
                    redirectUri = new Uri("/ViewEpisode.xaml?id=" + model.Tvdb + "&season=" + model.Season + "&episode=" + model.Episode, UriKind.Relative);
                }
                else if (model.Type.Equals("movie"))
                {
                    redirectUri = new Uri("/ViewMovie.xaml?id=" + model.Imdb, UriKind.Relative);
                }
                else
                {
                    redirectUri = new Uri("/ViewShow.xaml?id=" + model.Tvdb, UriKind.Relative);
                }

                Animation.NavigateToFadeOut(this, LayoutRoot, redirectUri);
            }
        }
Beispiel #7
0
        public void FilterHistory(int type, int startDay)
        {
            isFilter = true;
            App.TrackEvent("MainPage", "Filter newsfeed to " + type);

            if (newsFeedActivity == null)
            {
                return;
            }

            sortedOrderHistory = null;

            if (this.timesLoaded == 1)
            {
                App.ViewModel.clearHistory();
            }

            foreach (TraktActivity activity in this.newsFeedActivity)
            {
                ActivityListItemViewModel activityModel = DetermineActivityWithFilter(type, activity);

                if (activityModel != null)
                {
                    SortHistoryByDate(activity, activityModel, ref sortedOrderHistory);
                }
            }

            int count    = 0;
            int dayCount = 1;

            if (sortedOrderHistory != null)
            {
                foreach (DateTime key in sortedOrderHistory.Keys)
                {
                    if (dayCount++ < startDay + 1)
                    {
                        continue;
                    }

                    if (count++ == 6)
                    {
                        break;
                    }

                    Boolean isFirst = true;

                    foreach (ActivityListItemViewModel model in sortedOrderHistory[key])
                    {
                        if (isFirst)
                        {
                            model.HasHeader = true;
                            isFirst         = false;

                            if (count == 5)
                            {
                                model.IsAlmostLastDay = true;
                            }
                        }

                        App.ViewModel.HistoryItems.Add(model);
                    }
                }
            }


            App.ViewModel.NotifyPropertyChanged("HistoryItems");
        }
Beispiel #8
0
        private void CreateHistoryList(List <TraktActivity> newsFeedActivity, int startDay)
        {
            this.newsFeedActivity = newsFeedActivity;
            sortedOrderHistory    = null;
            isFilter = false;
            newsFeedActivity.Sort(TraktActivity.ActivityComparison);

            foreach (TraktActivity activity in newsFeedActivity)
            {
                ActivityListItemViewModel tempModel = null;
                try
                {
                    tempModel = DetermineActivity(activity, tempModel);

                    SortHistoryByDate(activity, tempModel, ref sortedOrderHistory);
                }
                catch (NullReferenceException) { }
            }

            if (sortedOrderHistory != null)
            {
                int count    = 0;
                int dayCount = 1;
                foreach (DateTime key in sortedOrderHistory.Keys)
                {
                    if (dayCount++ < startDay + 1)
                    {
                        continue;
                    }

                    if (count++ == 6)
                    {
                        break;
                    }

                    Boolean isFirst = true;

                    foreach (ActivityListItemViewModel model in sortedOrderHistory[key])
                    {
                        if (isFirst)
                        {
                            model.HasHeader = true;
                            isFirst         = false;

                            if (count == 5)
                            {
                                model.IsAlmostLastDay = true;
                            }
                        }



                        App.ViewModel.HistoryItems.Add(model);
                    }
                }
            }

            if (newsFeedActivity.Count == 0)
            {
                ToastNotification.ShowToast("User", "News feed is empty!");
            }

            App.ViewModel.NotifyPropertyChanged("HistoryItems");

            this.Loading             = false;
            this.indicator.IsVisible = false;
        }
Beispiel #9
0
        private void HistoryList_ItemRealized(object sender, ItemRealizationEventArgs e)
        {
            ActivityListItemViewModel model = (ActivityListItemViewModel)e.Container.DataContext;

            model.LoadScreenImage();
        }
Beispiel #10
0
        protected ActivityListItemViewModel DetermineActivityWithFilter(int type, TraktActivity activity)
        {
            ActivityListItemViewModel tempModel = null;

            try
            {
                switch (activity.Action)
                {
                case "watchlist":
                    if (type == 4 || (type >= 0 && type < 4))
                    {
                        if (type == 1 && activity.User.Username.Equals(AppUser.Instance.UserName))
                        {
                            break;
                        }
                        else if (type == 2 && !activity.User.Username.Equals(AppUser.Instance.UserName))
                        {
                            break;
                        }

                        tempModel = AddToWatchList(activity);
                    }
                    break;

                case "rating":
                    if (type == 5 || (type >= 0 && type < 4))
                    {
                        if (type == 1 && activity.User.Username.Equals(AppUser.Instance.UserName))
                        {
                            break;
                        }
                        else if (type == 2 && !activity.User.Username.Equals(AppUser.Instance.UserName))
                        {
                            break;
                        }

                        tempModel = Rated(activity);
                    }
                    break;

                case "checkin":
                    if (type == 6 || (type >= 0 && type < 4))
                    {
                        if (type == 1 && activity.User.Username.Equals(AppUser.Instance.UserName))
                        {
                            break;
                        }
                        else if (type == 2 && !activity.User.Username.Equals(AppUser.Instance.UserName))
                        {
                            break;
                        }

                        tempModel = Checkin(activity);
                    }
                    break;

                case "scrobble":
                    if (type == 7 || (type >= 0 && type < 4))
                    {
                        if (type == 1 && activity.User.Username.Equals(AppUser.Instance.UserName))
                        {
                            break;
                        }
                        else if (type == 2 && !activity.User.Username.Equals(AppUser.Instance.UserName))
                        {
                            break;
                        }

                        tempModel = Scrobble(activity);
                    }
                    break;

                case "shout":
                    if (type == 8 || (type >= 0 && type < 4))
                    {
                        if (type == 1 && activity.User.Username.Equals(AppUser.Instance.UserName))
                        {
                            break;
                        }
                        else if (type == 2 && !activity.User.Username.Equals(AppUser.Instance.UserName))
                        {
                            break;
                        }

                        tempModel = Shout(activity);
                    }
                    break;
                }
            }
            catch (NullReferenceException) { }
            return(tempModel);
        }
Beispiel #11
0
        protected ActivityListItemViewModel DetermineActivity(TraktActivity activity, ActivityListItemViewModel tempModel)
        {
            switch (activity.Action)
            {
            case "watchlist":
                tempModel = AddToWatchList(activity);
                break;

            case "rating":
                tempModel = Rated(activity);
                break;

            case "checkin":
                tempModel = Checkin(activity);
                break;

            case "scrobble":
                tempModel = Scrobble(activity);
                break;

            case "shout":
                tempModel = Shout(activity);
                break;
            }

            return(tempModel);
        }
Beispiel #12
0
        private void CreateHistoryList(List <TraktActivity> newsFeedActivity)
        {
            int counter = 0;

            this.newsFeedActivity = newsFeedActivity;
            sortedOrderHistory    = null;
            newsFeedActivity.Sort(TraktActivity.ActivityComparison);
            foreach (TraktActivity activity in newsFeedActivity)
            {
                ActivityListItemViewModel tempModel = null;
                try
                {
                    if (counter++ <= 20)
                    {
                        switch (activity.Action)
                        {
                        case "watchlist":
                            tempModel = AddToWatchList(activity);
                            break;

                        case "rating":
                            tempModel = Rated(activity);
                            break;

                        case "checkin":
                            tempModel = Checkin(activity);
                            break;

                        case "scrobble":
                            tempModel = Scrobble(activity);
                            break;

                        case "shout":
                            tempModel = Shout(activity);
                            break;
                        }

                        OrderHistory(activity, tempModel);
                    }
                }
                catch (NullReferenceException) { }
            }

            if (sortedOrderHistory != null)
            {
                foreach (DateTime key in sortedOrderHistory.Keys)
                {
                    Boolean isFirst = true;

                    foreach (ActivityListItemViewModel model in sortedOrderHistory[key])
                    {
                        if (isFirst)
                        {
                            model.HasHeader = true;
                            isFirst         = false;
                        }

                        App.FriendViewModel.HistoryItems.Add(model);
                    }
                }
            }

            if (newsFeedActivity.Count == 0)
            {
                ToastNotification.ShowToast("User", "News feed is empty!");
            }

            App.FriendViewModel.NotifyPropertyChanged("HistoryItems");
            this.Loading             = false;
            this.indicator.IsVisible = false;
        }