예제 #1
0
        public override async Task processImageLoadAsync(long lookupId)
        {
            loadingMoreCategories = true;

            string result = await failProcessing(lookupId);

            Debug.WriteLine("DHB:LikesPage:processImageLoadAsync through request call");

            if ((result.Equals(EMPTY)) && (submissions.Count == 0))
            {
                SubmissionsTitleRow titleRow = new SubmissionsTitleRow {
                    title = "No favorites yet",
                };
                submissions.Add(titleRow);
            }
            else
            {
                try {
                    // Results can be empty. This means we have some results already, but no more from older stuff.
                    if (!result.Equals(EMPTY))
                    {
                        LikesResponseJSON myLikes = JsonConvert.DeserializeObject <LikesResponseJSON>(result);
                        Debug.WriteLine("DHB:LikesPage:processImageLoadAsync pre if stmt");
                        if ((myLikes != null) && (myLikes.likes != null) && (myLikes.likes.Count > 0))
                        {
                            Debug.WriteLine("DHB:LikesPage:processImageLoadAsync post if stmt");
                            myLikes.likes.Sort();
                            myLikes.likes.Reverse();  // hmm.... harry may have done this already...
                            Debug.WriteLine("DHB:LikesPage:processImageLoadAsync break");
                            foreach (LikesJSON subCategory in myLikes.likes)
                            {
                                Debug.WriteLine("DHB:LikesPage:processImageLoadAsync inside foreach");
                                if ((subCategory.photos != null) && (subCategory.photos.Count > 0))
                                {
                                    SubmissionsTitleRow titleRow = new SubmissionsTitleRow {
                                        title = subCategory.category.description
                                    };
#if DEBUG
                                    titleRow.title += " - " + subCategory.category.categoryId;
#endif
                                    submissions.Add(titleRow);
                                    Debug.WriteLine("DHB:LikesPage:processImageLoadAsync about to load: " + subCategory.photos.Count + " photos.");
                                    //foreach (PhotoMetaJSON photo in subCategory.photos) {
                                    for (int i = 0; i < subCategory.photos.Count; i = i + 3)
                                    {
                                        int j = i;
                                        SubmissionsImageRow imgRow = new SubmissionsImageRow();
                                        submissions.Add(imgRow);
                                        imgRow.bitmap0  = GlobalSingletonHelpers.loadSKBitmapFromResourceName(LOADING_IMG_NAME, assembly);
                                        imgRow.bmp0Meta = subCategory.photos[j];
                                        PhotoLoad pl = new PhotoLoad(subCategory.photos[j].pid, imgRow, 0);
                                        photosToLoad.Enqueue(pl);
                                        //imgRow.bitmap0 = loadBitmapAsync(subCategory.photos[j].pid).Result;

                                        if (j + 1 < subCategory.photos.Count)
                                        {
                                            imgRow.bitmap1  = GlobalSingletonHelpers.loadSKBitmapFromResourceName(LOADING_IMG_NAME, assembly);
                                            imgRow.bmp1Meta = subCategory.photos[j + 1];
                                            //imgRow.bitmap1 = loadBitmapAsync(subCategory.photos[j + 1].pid).Result;
                                            //Task.Run(() => imgRow.bitmap1 = loadBitmapAsync(subCategory.photos[j + 1].pid).Result);
                                            //imgRow.bmp1Meta = subCategory.photos[j + 1];
                                            pl = new PhotoLoad(subCategory.photos[j + 1].pid, imgRow, 1);
                                            photosToLoad.Enqueue(pl);
                                        }

                                        if (j + 2 < subCategory.photos.Count)
                                        {
                                            imgRow.bitmap2  = GlobalSingletonHelpers.loadSKBitmapFromResourceName(LOADING_IMG_NAME, assembly);
                                            imgRow.bmp2Meta = subCategory.photos[j + 2];
                                            pl = new PhotoLoad(subCategory.photos[j + 2].pid, imgRow, 2);
                                            photosToLoad.Enqueue(pl);
                                        }
                                        Debug.WriteLine("DHB:LikesPage:processImageLoadAsync  complete.");
                                    }
                                    //SubmissionsBlankRow blank = new SubmissionsBlankRow();
                                    //submissions.Add(blank);  // causing issues at this row. skip for now.
                                }
                                Debug.WriteLine("DHB:LikesPage:processImageLoadAsync  category: " + subCategory.category.description + " complete.");
                            }
                            nextLookupId = myLikes.likes[myLikes.likes.Count - 1].category.categoryId;
                        }
                    }
                } catch (Exception ex) {
                    Debug.WriteLine("DHB:LikesPage:processImageLoadAsync LikesResponseJSON crash");
                    Debug.WriteLine("DHB:LikesPage:processImageLoadAsync input json:" + result);
                    Debug.WriteLine("DHB:LikesPage:processImageLoadAsync LikesResponseJSON crash Done.");
                }
            }
            // this did not fix the problem.
            //myListView.ItemsSource = null;  // testing whether this clears up my observable collection changed issue.
            //myListView.ItemsSource = submissions;  // testing whether this clears up my observable collection changed issue.
            Debug.WriteLine("DHB:LikesPage:processImageLoadAsync  complete.");
            loadingMoreCategories = false;
        }
예제 #2
0
        public override async Task processImageLoadAsync(long lookupId)
        {
            loadingMoreCategories = true;

            /*
             * string result = "fail";
             * while (result.Equals("fail")) {
             *  result = await requestApiCallAsync(lookupId, activeApiCall);
             *  if (result == null) result = "fail";
             *  if (result.Equals("fail")) {
             *      await Task.Delay(10000);
             *  }
             * }
             */
            string result = await failProcessing(lookupId);

            Debug.WriteLine("DHB:MySubmissionsPage:processImageLoadAsync through request call");

            if (result.Equals(EMPTY))
            {
                SubmissionsTitleRow titleRow = new SubmissionsTitleRow {
                    title = "You have not yet submitted a photo",
                };
                if (submissions.Count == 0)
                {
                    submissions.Add(titleRow);
                }
            }
            else
            {
                SubmissionsResponseJSON mySubs = JsonConvert.DeserializeObject <SubmissionsResponseJSON>(result);
                Debug.WriteLine("DHB:MySubmissionsPage:processSubmissionsLoadAsync pre if stmt");
                if ((mySubs != null) && (mySubs.submissions != null) && (mySubs.submissions.Count > 0))
                {
                    Debug.WriteLine("DHB:MySubmissionsPage:processSubmissionsLoadAsync post if stmt");
                    mySubs.submissions.Sort();
                    printSubs(mySubs.submissions);
                    mySubs.submissions.Reverse();
                    Debug.WriteLine("DHB:MySubmissionsPage:processSubmissionsLoadAsync break");
                    printSubs(mySubs.submissions);
                    foreach (SubmissionJSON subCategory in mySubs.submissions)
                    {
                        Debug.WriteLine("DHB:MySubmissionsPage:processSubmissionsLoadAsync inside foreach");
                        //if (subCategory.photos.Count > 0) && (!subCategory.category.state.Equals(CategoryJSON.CLOSED))) {
                        if ((subCategory.photos != null) && (subCategory.photos.Count > 0))
                        {
                            if ((GlobalStatusSingleton.pendingCategories.Count == 0) ||
                                ((GlobalStatusSingleton.pendingCategories.Count > 0) && (subCategory.category.categoryId < GlobalStatusSingleton.pendingCategories[0].categoryId)))
                            {
                                SubmissionsTitleRow titleRow = new SubmissionsTitleRow {
                                    title = subCategory.category.description
                                };
#if DEBUG
                                titleRow.title += " - " + subCategory.category.categoryId;
#endif
                                submissions.Add(titleRow);
                                Debug.WriteLine("DHB:MySubmissionsPage:processSubmissionsLoadAsync  about to load: " + subCategory.photos.Count + " photos.");
                                //foreach (PhotoMetaJSON photo in subCategory.photos) {
                                for (int i = 0; i < subCategory.photos.Count; i = i + 3)
                                {
                                    int j = i;
                                    SubmissionsImageRow imgRow = new SubmissionsImageRow();
                                    submissions.Add(imgRow);
                                    imgRow.bitmap0  = GlobalSingletonHelpers.loadSKBitmapFromResourceName(LOADING_IMG_NAME, assembly);
                                    imgRow.bmp0Meta = subCategory.photos[j];
                                    PhotoLoad pl = new PhotoLoad(subCategory.photos[j].pid, imgRow, 0);
                                    photosToLoad.Enqueue(pl);
                                    //imgRow.bitmap0 = loadBitmapAsync(subCategory.photos[j].pid).Result;

                                    /*
                                     * Task.Run(async () => {
                                     *  Debug.WriteLine("DHB:MySubmissionsPage imgload started for img " + j);
                                     *  imgRow.bitmap0 = await loadBitmapAsync(subCategory.photos[j].pid);
                                     *  Debug.WriteLine("DHB:MySubmissionsPage imgload finished for img " + j);
                                     * });
                                     */

                                    if (j + 1 < subCategory.photos.Count)
                                    {
                                        imgRow.bitmap1  = GlobalSingletonHelpers.loadSKBitmapFromResourceName(LOADING_IMG_NAME, assembly);
                                        imgRow.bmp1Meta = subCategory.photos[j + 1];
                                        //imgRow.bitmap1 = loadBitmapAsync(subCategory.photos[j + 1].pid).Result;
                                        //Task.Run(() => imgRow.bitmap1 = loadBitmapAsync(subCategory.photos[j + 1].pid).Result);
                                        //imgRow.bmp1Meta = subCategory.photos[j + 1];
                                        pl = new PhotoLoad(subCategory.photos[j + 1].pid, imgRow, 1);
                                        photosToLoad.Enqueue(pl);
                                    }

                                    if (j + 2 < subCategory.photos.Count)
                                    {
                                        imgRow.bitmap2  = GlobalSingletonHelpers.loadSKBitmapFromResourceName(LOADING_IMG_NAME, assembly);
                                        imgRow.bmp2Meta = subCategory.photos[j + 2];
                                        pl = new PhotoLoad(subCategory.photos[j + 2].pid, imgRow, 2);
                                        photosToLoad.Enqueue(pl);
                                    }
                                    Debug.WriteLine("DHB:MySubmissionsPage:processSubmissionsLoadAsync  complete.");
                                }
                                //SubmissionsBlankRow blank = new SubmissionsBlankRow();
                                //submissions.Add(blank);  // causing issues at this row. skip for now.
                            }
                        }
                        Debug.WriteLine("DHB:MySubmissionsPage:processSubmissionsLoadAsync  category: " + subCategory.category.description + " complete.");
                    }
                    nextLookupId = mySubs.submissions[mySubs.submissions.Count - 1].category.categoryId;
                }
            }
            // this did not fix the problem.
            //myListView.ItemsSource = null;  // testing whether this clears up my observable collection changed issue.
            //myListView.ItemsSource = submissions;  // testing whether this clears up my observable collection changed issue.
            Debug.WriteLine("DHB:MySubmissionsPage:processSubmissionsLoadAsync  complete.");
            loadingMoreCategories = false;
        }
예제 #3
0
 public PhotoLoad(long pid, SubmissionsImageRow row, int idx)
 {
     this.pid = pid;
     drawRow  = row;
     index    = idx;
 }
예제 #4
0
        public override async Task processImageLoadAsync(long lookupId)
        {
            loadingMoreCategories = true;

            string result = await failProcessing(lookupId);

            Debug.WriteLine("DHB:EventCategoryImagesPage:processImageLoadAsync through request call");

            if (result.Equals(EMPTY))
            {
                SubmissionsTitleRow titleRow = new SubmissionsTitleRow {
                    title = "No entries yet, be the first!",
                };
                submissions.Add(titleRow);
            }
            else
            {
                try {
                    // Results can be empty. This means we have some results already, but no more from older stuff.
                    if (!result.Equals(EMPTY))
                    {
                        PhotosResponseJSON catImages = JsonConvert.DeserializeObject <PhotosResponseJSON>(result);  // need to update
                        Debug.WriteLine("DHB:EventCategoryImagesPage:processImageLoadAsync pre if stmt");
                        if ((catImages != null) && (catImages.photos != null) && (catImages.photos.Count > 0))
                        {
                            Debug.WriteLine("DHB:EventCategoryImagesPage:processImageLoadAsync post if stmt");
                            catImages.photos.Sort();
                            catImages.photos.Reverse();  // hmm.... harry may have done this already...
                            Debug.WriteLine("DHB:EventCategoryImagesPage:processImageLoadAsync break");

                            // title row
                            // @todo There's a race condition here... shitshers.
                            SubmissionsTitleRow titleRow = new SubmissionsTitleRow {
                                title = _ActiveCategory.description
                            };
#if DEBUG
                            titleRow.title += " - " + _ActiveCategory.categoryId;
#endif
                            submissions.Add(titleRow);
                            Debug.WriteLine("DHB:EventCategoryImagesPage:processImageLoadAsync about to load: " + catImages.photos.Count + " photos.");
                            //foreach (PhotoMetaJSON photo in subCategory.photos) {
                            for (int i = 0; i < catImages.photos.Count; i = i + 3)
                            {
                                int j = i;
                                SubmissionsImageRow imgRow = new SubmissionsImageRow();
                                submissions.Add(imgRow);
                                imgRow.bitmap0  = GlobalSingletonHelpers.loadSKBitmapFromResourceName(LOADING_IMG_NAME, assembly);
                                imgRow.bmp0Meta = catImages.photos[j];
                                PhotoLoad pl = new PhotoLoad(catImages.photos[j].pid, imgRow, 0);
                                photosToLoad.Enqueue(pl);
                                //imgRow.bitmap0 = loadBitmapAsync(subCategory.photos[j].pid).Result;

                                if (j + 1 < catImages.photos.Count)
                                {
                                    imgRow.bitmap1  = GlobalSingletonHelpers.loadSKBitmapFromResourceName(LOADING_IMG_NAME, assembly);
                                    imgRow.bmp1Meta = catImages.photos[j + 1];
                                    //imgRow.bitmap1 = loadBitmapAsync(subCategory.photos[j + 1].pid).Result;
                                    //Task.Run(() => imgRow.bitmap1 = loadBitmapAsync(subCategory.photos[j + 1].pid).Result);
                                    //imgRow.bmp1Meta = subCategory.photos[j + 1];
                                    pl = new PhotoLoad(catImages.photos[j + 1].pid, imgRow, 1);
                                    photosToLoad.Enqueue(pl);
                                }

                                if (j + 2 < catImages.photos.Count)
                                {
                                    imgRow.bitmap2  = GlobalSingletonHelpers.loadSKBitmapFromResourceName(LOADING_IMG_NAME, assembly);
                                    imgRow.bmp2Meta = catImages.photos[j + 2];
                                    pl = new PhotoLoad(catImages.photos[j + 2].pid, imgRow, 2);
                                    photosToLoad.Enqueue(pl);
                                }
                                Debug.WriteLine("DHB:EventCategoryImagesPage:processImageLoadAsync  complete.");
                            }
                            //SubmissionsBlankRow blank = new SubmissionsBlankRow();
                            //submissions.Add(blank);  // causing issues at this row. skip for now.
                        }
                        else
                        {
                            // @todo This may need to adjust after an entry comes in!
                            SubmissionsTitleRow titleRow = new SubmissionsTitleRow {
                                title = "No entries yet, be the first!",
                            };
                            submissions.Add(titleRow);
                        }
                        Debug.WriteLine("DHB:EventCategoryImagesPage:processImageLoadAsync  category: " + _ActiveCategory.description + " complete.");
                    }
                } catch (Exception ex) {
                    Debug.WriteLine("DHB:EventCategoryImagesPage:processImageLoadAsync PhotosResponseJSON crash");
                    Debug.WriteLine("DHB:EventCategoryImagesPage:processImageLoadAsync input json:" + result);
                    Debug.WriteLine("DHB:EventCategoryImagesPage:processImageLoadAsync ex:" + ex.ToString());
                    Debug.WriteLine("DHB:EventCategoryImagesPage:processImageLoadAsync PhotosResponseJSON crash Done.");
                }
            }
            Debug.WriteLine("DHB:EventCategoryImagesPage:processImageLoadAsync  complete.");
            loadingMoreCategories = false;
        }