/// <summary>
        ///     Retrieve user's filtered out gallery.
        ///     OAuth authentication required.
        /// </summary>
        /// <param name="sort">The order that the gallery should be sorted by. Default: Viral</param>
        /// <param name="window">The time period that should be used in filtering requests. Default: Week</param>
        /// <param name="page">Set the page number so you don't have to retrieve all the data at once. Default: null</param>
        /// <exception cref="T:System.ArgumentNullException">
        ///     Thrown when a null reference is passed to a method that does not accept it as a
        ///     valid argument.
        /// </exception>
        /// <exception cref="T:Imgur.API.ImgurException">Thrown when an error is found in a response from an Imgur endpoint.</exception>
        /// <exception cref="T:Imgur.API.MashapeException">Thrown when an error is found in a response from a Mashape endpoint.</exception>
        /// <returns></returns>
        public async Task <ICustomGallery> GetFilteredOutGalleryAsync(
            CustomGallerySortOrder?sort = CustomGallerySortOrder.Viral,
            TimeWindow?window           = TimeWindow.Week,
            int?page = null)
        {
            if (this.ApiClient.OAuth2Token == null)
            {
                throw new ArgumentNullException("OAuth2Token", "OAuth authentication required.");
            }
            CustomGallerySortOrder?nullable1 = sort;

            sort = new CustomGallerySortOrder?(nullable1.HasValue ? nullable1.GetValueOrDefault() : CustomGallerySortOrder.Viral);
            TimeWindow?nullable2 = window;

            window = new TimeWindow?(nullable2.HasValue ? nullable2.GetValueOrDefault() : TimeWindow.Week);
            string         sortValue   = string.Format("{0}", (object)sort).ToLower();
            string         windowValue = string.Format("{0}", (object)window).ToLower();
            string         url         = string.Format("g/filtered/{0}/{1}/{2}", (object)sortValue, (object)windowValue, (object)page);
            ICustomGallery customGallery;

            using (HttpRequestMessage request = this.RequestBuilder.CreateRequest(HttpMethod.Get, url))
            {
                CustomGallery gallery = await this.SendRequestAsync <CustomGallery>(request).ConfigureAwait(false);

                customGallery = (ICustomGallery)gallery;
            }
            return(customGallery);
        }
示例#2
0
        public FormCamera(Context contxt, ReportElement element, int userID, int ownerID, int verifiedID, ReportStatus reportStatus,
                          string typeFlag, string type, List <ReportElement> elementList)
            : base(contxt)
        {
            imageDownloadArray = new List <string>();
            if (cameraPreviewView == null)
            {
                cameraPreviewView = new List <GridView>();
            }
            else
            {
                for (int i = 0; i < cameraPreviewView.Count; i++)
                {
                    if (IMAGE_PREVIEW_Header_ID + element.Id == cameraPreviewView[i].Id || IMAGE_PREVIEW_Info_ID + element.Id == cameraPreviewView[i].Id)
                    {
                        cameraPreviewView.RemoveAt(i);
                    }
                }
            }

            if (cameraIndicatorView == null)
            {
                cameraIndicatorView = new List <ImageView>();
            }
            else
            {
                for (int i = 0; i < cameraIndicatorView.Count; i++)
                {
                    if (IMAGE_INDICATOR_ID + element.Id == cameraIndicatorView[i].Id)
                    {
                        cameraIndicatorView.RemoveAt(i);
                    }
                }
            }

            imageJPGFile = new ImageFile();

            context  = contxt;
            resource = context.Resources;

            sharedPreferences       = PreferenceManager.GetDefaultSharedPreferences(context);
            sharedPreferencesEditor = sharedPreferences.Edit();

            InitImageLoader();

            LinearLayout imageLay = new LinearLayout(context);

            imageLay.Orientation = Orientation.Vertical;

            var addImageButton = new ImageButton(context);

            addImageButton.Id = element.Id;
            addImageButton.SetPadding(20, 5, 5, 5);

            RelativeLayout.LayoutParams paramsForImageButton = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent);
            paramsForImageButton.AddRule(LayoutRules.AlignParentLeft);
            addImageButton.LayoutParameters = paramsForImageButton;

            GridView gridGallery = new ExpandingGrid(context);

            RelativeLayout.LayoutParams paramsForgridGallery = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MatchParent, RelativeLayout.LayoutParams.WrapContent);
            paramsForgridGallery.AddRule(LayoutRules.Above, addImageButton.Id);
            gridGallery.LayoutParameters = paramsForgridGallery;
            gridGallery.SetNumColumns(6);

            List <CustomGallery> dataT = new List <CustomGallery>();
            string sdCardPath2         = Environment.ExternalStorageDirectory.AbsolutePath;

            foreach (var VARIABLE in element.Values)
            {
                CustomGallery item = new CustomGallery();
                item.SdCardPath = "/storage/emulated/0/Checkd/" + VARIABLE.Value;
                dataT.Add(item);

                String fileExist = Path.Combine(sdCardPath2, "Checkd/" + VARIABLE.Value);
                File   existFile = new File(fileExist);
                if (!existFile.Exists())
                {
                    imageDownloadArray.Add(VARIABLE.Value);
                }
            }

            MultipleImageDownloader(imageDownloadArray);

            MiniGallerAdapter adapter = new MiniGallerAdapter(Application.Context, imageLoader);

            if (dataT.Count != 0)
            {
                adapter.AddAll(dataT);
            }
            gridGallery.Adapter = adapter;

            if (typeFlag == "Info")
            {
                int artificial_Preview_ID = IMAGE_PREVIEW_Info_ID + element.Id;
                gridGallery.Id = artificial_Preview_ID;
                cameraPreviewView.Add(gridGallery);
            }
            else
            {
                int artificial_header_Preview_ID = IMAGE_PREVIEW_Header_ID + element.Id;
                gridGallery.Id = artificial_header_Preview_ID;
                cameraPreviewView.Add(gridGallery);
            }

            gridGallery.ItemClick += delegate(object sender, AdapterView.ItemClickEventArgs args)
            {
                List <CustomGallery> items    = new List <CustomGallery>();
                MiniGallerAdapter    adapter3 = (MiniGallerAdapter)gridGallery.Adapter;
                items = adapter3.getList();
                Object obj   = items[args.Position].SdCardPath;
                String value = obj.ToString().Substring(obj.ToString().LastIndexOf('/') + 1);
                GalleryImagePreview(value);
            };

            imageLay.AddView(gridGallery);
            imageLay.AddView(addImageButton);

            RelativeLayout theme    = new FormTheme(context, element.Title);
            LinearLayout   btnLayer = new LinearLayout(context);

            btnLayer.Orientation = Orientation.Vertical;

            String img = element.Value;

            String sdCardPath = Environment.ExternalStorageDirectory.AbsolutePath;
            String filePath   = Path.Combine(sdCardPath, "Checkd/" + img);
            File   file       = new File(filePath);

            addImageButton.SetImageResource(Resource.Drawable.android_camera_grey);
            addImageButton.SetBackgroundResource(0);

            ImageView indicatorImage = (ImageView)theme.GetChildAt(1);

            activateElementInfo(element, theme);
            int artificial_ID = IMAGE_INDICATOR_ID + element.Id;

            indicatorImage.Id = artificial_ID;
            cameraIndicatorView.Add(indicatorImage);

            addImageButton.Click += (sender2, e) => ImageSelectionChoiceDialog(sender2, e, element.Id + "", type);

            if (!element.Value.Equals(""))
            {
                indicatorImage.SetImageResource(Resource.Drawable.checked_forms_create_project_medium);
            }

            if (ownerID == 0 || ownerID == userID)
            {
                if (verifiedID != 0)
                {
                    addImageButton.Enabled   = false;
                    addImageButton.Clickable = false;

                    if (reportStatus == ReportStatus.Rejected)
                    {
                        addImageButton.Enabled   = true;
                        addImageButton.Clickable = true;
                    }
                }

                else
                {
                    addImageButton.Enabled   = true;
                    addImageButton.Clickable = true;
                }
            }
            else
            {
                addImageButton.Enabled   = false;
                addImageButton.Clickable = false;
            }

            isArcheived = sharedPreferences.GetBoolean(Resources.GetString(Resource.String.is_archived), false);

            if (isArcheived)
            {
                addImageButton.Clickable = false;
                addImageButton.Enabled   = false;
                addImageButton.Click    += null;
            }

            btnLayer.AddView(theme);
            btnLayer.AddView(imageLay);
            btnLayer.SetPadding(45, 10, 45, 20);
            AddView(btnLayer);
        }