Exemplo n.º 1
0
        public void OnFilterSuccess(string json)
        {
            try
            {
                StopLoadingAnimation();

                MasterBaseCardData masterCardData = JsonFx.Json.JsonReader.Deserialize <MasterBaseCardData>(json);
                var activityList = masterCardData.results.Cast <BaseCardData>().ToList();
                activityList.ForEach(activity => activity.ParseDateString());
                var filteredActivities = activityList.Where(card => card.dateTime >= DateTime.Now).ToList();

                if (filteredActivities.Count == 0)
                {
                    model.noFilterCard.SetActive(true);
                }
                else
                {
                    dynamicScrollView.Init(600, 1000, 8, null, null, 15, true, true);
                    filteredActivities.Sort((a, b) =>
                    {
                        int dateDifference = a.dateTime.CompareTo(b.dateTime);
                        if (dateDifference == 0)
                        {
                            return(a.Proximity.CompareTo(b.Proximity));
                        }
                        else
                        {
                            return(dateDifference);
                        }
                    });
                    dynamicScrollView.Populate(filteredActivities);
                }
            }
            catch (Exception e)
            {
                Debug.LogError("FilterResultsViewController.OnFilterSuccess: Deserialization error: \n" + e.Message + "\n" + e.StackTrace);
                model.loadingLabel.text = "An error occurred. Try again later.";
            }
        }
Exemplo n.º 2
0
        private void OnRetrieveActivitiesForSelectedDaySuccess(string json)
        {
            List <BaseCardData> baseList = null;

            try
            {
                HelperMethods.ResultReponseObject result = JsonFx.Json.JsonReader.Deserialize <HelperMethods.ResultReponseObject>(json);
                if (result.total_count == 0)
                {
                    Debug.Log("No items for selected day.");
                    OnRetrieveActivitiesForSelectedDayFailure(HelperMethods.Instance.Error_EmptyResults);
                    return;
                }

                MasterBaseCardData  masterBaseCardData = JsonReader.Deserialize <MasterBaseCardData>(json);
                ActivityDataModel[] activityArray      = masterBaseCardData.results;
                baseList = activityArray.Cast <BaseCardData>().ToList();
                ITTDataCache.Instance.Data.AppendDataEntry <ActivityDataModel[]>((int)DataCacheIndices.ACTIVITY_LIST, baseList.Cast <ActivityDataModel>().ToArray());
            }
            catch
            {
                Debug.LogError("CardCarousel error deserializing activity JSON");
            }
        }