private void SetUpdate(EdicolaItem view, string docID) { if (_downloads != null) { var down = _downloads.Where(d => d.ID == docID).FirstOrDefault(); if (down != null) { view.DownloadUri = down.Uri; view.DownloadStato = down.Stato; EventHandler onUpdate = delegate { view.StartDownload(); }; view.UpButton.Click -= onUpdate; view.UpButton.Click += onUpdate; } else { view.DownloadStato = DownloadStato.NoUpdate; } view.Initialize(); } }
private View GetViewThumb(int position, View convertView, ViewGroup parent) { var doc = _Items[position] as Pubblicazione; GridView grid = null; if (parent.GetType() == typeof(GridView)) { grid = parent as GridView; } bool list = (grid != null && grid.NumColumns == 1); EdicolaItem view = null; if (convertView != null && convertView is CheckableLayout) { var v = convertView as CheckableLayout; if (v.MainView != null && v.MainView is EdicolaItem) { view = v.MainView as EdicolaItem; if (view.IdDoc == doc.ID) { SetUpdate(view, doc.ID); if (ActionMode) { view.ActionButton.Visibility = ViewStates.Invisible; } else { view.ActionButton.Visibility = ViewStates.Visible; } return(v); } else { view = null; } } } if (view == null) { view = new EdicolaItem(this.context, list); } view.Tag = position; view.IdDoc = doc.ID; //copertina if (doc.IsPDF) { view.ImgCover.SetImageResource(Resource.Drawable.pdf_icon); view.ImgCover.SetScaleType(ImageView.ScaleType.FitCenter); } else { string imgPath = System.IO.Path.Combine(doc.Path, "copertina.jpg"); if (System.IO.File.Exists(imgPath)) { /*using(Bitmap bmp = ImageUtility.DecodeSampledBitmapFromFile(imgPath, 280, 280)) * { * view.ImgCover.SetImageBitmap(bmp); * }*/ //imgPath += "_" + doc.DataPubblicazione.ToString("yyMMddhhmmss"); /*Uri uri = new Uri(imgPath); * * var options = new DisplayImageOptions.Builder() * .CacheInMemory(false) * .CacheOnDisk(true) * .ConsiderExifParams(true) * .BitmapConfig(Bitmap.Config.Rgb565) * .Build(); * * var targetSize = new ImageSize(280, 280); * * ImageLoader.Instance.LoadImage( * uri.ToString(), * targetSize, * options, * new ImageLoadingListener( * loadingComplete: (imageUri, v, loadedImage) => { * view.ImgCover.SetImageBitmap(loadedImage); * }));*/ //MBImageLoader.DisplayDiskImage(imgPath, view.ImgCover, new PointF(280, 280)); Koush.UrlImageViewHelper.SetUrlDrawable(view.ImgCover, new Uri(imgPath).AbsoluteUri); } } //pulsante info EventHandler onClick = (sender, e) => { //_InfoClick(position); PopupMenu popup = new PopupMenu(this.context, view.ActionButton); popup.MenuInflater.Inflate(Resource.Menu.EdicolaThumbMenu, popup.Menu); var menu = popup.Menu; var el = menu.FindItem(Resource.Id.EdicolaItemOption_Delete); el.SetTitle(context.GetString(Resource.String.gen_delete)); el = menu.FindItem(Resource.Id.EdicolaItemOption_Details); el.SetTitle(context.GetString(Resource.String.pub_details)); popup.MenuItemClick += (object send, PopupMenu.MenuItemClickEventArgs ev) => { _ItemOptionClick(ev, position); }; popup.Show(); }; view.ActionButton.Click -= onClick; view.ActionButton.Click += onClick; //titolo view.Title = doc.Titolo; //dettagli if (view.Details != null) { string autore = doc.Autore; if (autore == "") { autore = context.GetString(Resource.String.pub_sconosciuto); } view.Details = autore; } //update SetUpdate(view, doc.ID); if (ActionMode) { view.ActionButton.Visibility = ViewStates.Invisible; } else { view.ActionButton.Visibility = ViewStates.Visible; } return(view); }