private static void InstallMbPackage(string uri, string localUri) { Uri qUri = new Uri(uri); localUri = Uri.UnescapeDataString(localUri); uri = Uri.UnescapeDataString(uri); string fileName = System.IO.Path.GetFileName(localUri); string search = "/pub/"; //string url = uri.AbsoluteUri; uri = uri.Substring(uri.IndexOf(search) + search.Length).Trim('/'); string outPath = System.IO.Path.Combine(DataManager.Get <ISettingsManager>().Settings.DocPath, uri); //outPath = Path.Combine(outPath, parts[1]).Trim('/'); outPath = System.Web.HttpUtility.UrlDecode(outPath); outPath = System.IO.Path.GetDirectoryName(outPath); string filePath = new Uri(localUri).LocalPath; try { if (System.IO.Path.GetExtension(localUri) == ".mb") { //outPath = Path.Combine(outPath, fileName.Replace(fileExt, ".mbp")); FileSystemManager.UnzipDocument(filePath, outPath); File.Delete(filePath); //ImageLoader.Instance.ClearDiskCache(); //ImageLoader.Instance.ClearMemoryCache(); MBImageLoader.RemoveFromCache(qUri.ToString()); } else if (System.IO.Path.GetExtension(localUri) == ".pdf") { outPath = System.IO.Path.Combine(outPath, fileName); if (File.Exists(outPath)) { File.Delete(outPath); } //se la cartella non esiste la creo string dir = System.IO.Path.GetDirectoryName(outPath); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } File.Move(filePath, outPath); } MBDownloadManager.FinishDownload(qUri, true); } catch (Exception value) { Console.WriteLine(value); MBDownloadManager.FinishDownload(qUri, false); } }
public void SetPage(string imgPath, int page) { if (System.IO.File.Exists(imgPath)) { MBImageLoader.DisplayDiskImage(imgPath, _imgPage, new PointF(400, 400)); } _lblPage.Text = string.Format(this.Context.GetString(Resource.String.pub_pagina), (page + 1)); }
public override View GetView(int position, View convertView, ViewGroup parent) { var item = _Items[position]; View view = null; if (convertView != null) { view = convertView; } else { view = _context.LayoutInflater.Inflate(Resource.Layout.EdicolaListItem, parent, false); } var imgCover = view.FindViewById <ImageView>(Resource.Id.edicolaImgCover); var txtTitolo = view.FindViewById <TextView>(Resource.Id.edicolaTxtTitolo); var txtDettagli = view.FindViewById <TextView>(Resource.Id.edicolaTxtDettagli); var btnInfo = view.FindViewById <ImageView>(Resource.Id.btnInfo); TextView txtLabel = view.FindViewById <TextView>(Resource.Id.txtLabel); //copertina if (item.IsPDF) { imgCover.SetImageResource(Resource.Drawable.pdf_icon); imgCover.SetScaleType(ImageView.ScaleType.FitCenter); } else { string imgPath = System.IO.Path.Combine(item.Path, "copertina.jpg"); if (System.IO.File.Exists(imgPath)) { MBImageLoader.DisplayDiskImage(imgPath, imgCover, new PointF(280, 280)); } } //titolo txtTitolo.SetText(item.Titolo, TextView.BufferType.Normal); //dettagli if (txtDettagli != null) { txtDettagli.SetText(item.Autore, TextView.BufferType.Normal); } //pulsanti if (btnInfo != null) { btnInfo.Visibility = ViewStates.Gone; } return(view); }
private void LoadMultistato() { if (_multistato.Stati.Count() == 0) { return; } _imgSwitcher = new ImageSwitcher(this.Context); _imgSwitcher.SetFactory(this); string imgPath = System.IO.Path.Combine(_basePath, _multistato.Stati[0].Path); MBImageLoader.DisplayDiskImage(imgPath, _imgSwitcher, new PointF(_frame.Width(), _frame.Height())); this.AddView(_imgSwitcher, new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MatchParent, RelativeLayout.LayoutParams.MatchParent)); //transizione this.SetAnimation(); //scorrimento temporizzato _changeHandler = new Handler(Looper.MainLooper); _changeRunnable = new Runnable(() => { try { this.NextState(); } finally { _changeHandler.PostDelayed(_changeRunnable, _multistato.Delay); } }); //gesture if (_multistato.Swipe || _multistato.SwipeContinuo || _multistato.ZoomEnabled) { _gestureDetector = new GestureDetector(this.Context, new GestureListener(this)); } //loop this._partialLoop = _multistato.Loop; //autoplay /*if(_multistato.Autoplay) * { * this.Start(); * }*/ this.SetOnClick(); }
public void GoToState(int index) { if (_imgSwitcher == null || index == _currentIndex) { return; } string imgPath = System.IO.Path.Combine(_basePath, _multistato.Stati[index].Path); MBImageLoader.DisplayDiskImage(imgPath, _imgSwitcher, new PointF(_frame.Width(), _frame.Height())); _currentIndex = index; }
private void LoadImage() { string path = GetPathForState(); this.RecycleBitmap(); if (!File.Exists(path)) { this.SetImageBitmap(null); } else { MBImageLoader.DisplayDiskImage(path, this, new PointF(_frame.Width(), _frame.Height())); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); this.Window.RequestFeature(WindowFeatures.NoTitle); SetContentView(Resource.Layout.EdicolaDetails); this.SetTitle(_pubblicazione.Titolo); TextView txtTitolo = FindViewById <TextView>(Resource.Id.txtTitolo); TextView txtAutore = FindViewById <TextView>(Resource.Id.txtAutore); TextView txtPubblicato = FindViewById <TextView>(Resource.Id.txtPubblicato); TextView txtScadenza = FindViewById <TextView>(Resource.Id.txtScadenza); ImageView imgCover = FindViewById <ImageView>(Resource.Id.imgCover); Button btnOpen = FindViewById <Button>(Resource.Id.btnOpen); Button btnDelete = FindViewById <Button>(Resource.Id.btnDelete); txtTitolo.Text = _pubblicazione.Titolo; txtAutore.Text = _pubblicazione.Autore.Trim(); string imgPath = System.IO.Path.Combine(_pubblicazione.Path, "copertina.jpg"); if (System.IO.File.Exists(imgPath)) { MBImageLoader.DisplayDiskImage(imgPath, imgCover, new PointF(360, 360)); } if (_pubblicazione.DataPubblicazione != DateTime.MinValue) { txtPubblicato.Text = string.Format(Context.GetString(Resource.String.pub_publishedOn), _pubblicazione.DataPubblicazione.ToString("dd-MM-yyyy")); } else { txtPubblicato.Visibility = ViewStates.Gone; } if (_pubblicazione.DataScadenza != DateTime.MinValue) { txtScadenza.Text = string.Format(Context.GetString(Resource.String.pub_expireOn), _pubblicazione.DataScadenza.ToString("dd-MM-yyyy")); } else { txtScadenza.Visibility = ViewStates.Gone; } //pulsante apri btnOpen.SetTextColor(Color.Transparent.FromHex(DataManager.Get <ISettingsManager>().Settings.ButtonColor)); btnOpen.Text = Context.GetString(Resource.String.pub_open); btnOpen.Click += delegate { if (OpenAction != null) { OpenAction(); } }; //pulsante elimina btnDelete.SetTextColor(Color.Transparent.FromHex(DataManager.Get <ISettingsManager>().Settings.ButtonColor)); btnDelete.Text = Context.GetString(Resource.String.pub_delete); btnDelete.Click += delegate { if (DeleteAction != null) { DeleteAction(); } }; }
public override View GetView(int position, View convertView, ViewGroup parent) { var item = _Items[position]; int absPage = _pubblicazione.RelativeToAbsolutePage(item.IdDocumento, item.Index); PageItem view = null; if (convertView == null) { view = new PageItem(_context); } else { view = convertView as PageItem; } //se è la pagina corrente setto il testo in grassetto view.SetBold(false); if (item.IdDocumento == _documento.ID && item.Index == _currentIndex + 1) { view.SetBold(); } if (view.AbsPage == absPage) { return(view); } if (_bookmarks != null && position < _bookmarks.Count && _bookmarks[position].Titolo != "") { view.Title = _bookmarks[position].Titolo; } else { if (Utils.CompareVersion(_pubblicazione.Script, "4.6.0") >= 0) { view.Title = item.Titolo; if (item.Titolo == "") { view.Title = absPage.ToString(); } else if (item.Titolo != absPage.ToString()) { view.Title += " (" + absPage.ToString() + ")"; } } else { view.Title = string.Format(_context.GetString(Resource.String.pub_pagina), absPage.ToString()); } } var doc = _pubblicazione.GetDocumento(item.IdDocumento); if (doc != null) { string imgPath = System.IO.Path.Combine(doc.Path, item.Path, "miniatura.jpg"); if (System.IO.File.Exists(imgPath)) { MBImageLoader.DisplayDiskImage(imgPath, view.ImgCover, new PointF(100, 100)); //Koush.UrlImageViewHelper.SetUrlDrawable(imgThumb, new Uri(imgPath).AbsoluteUri); } } view.AbsPage = absPage; return(view); }
public override View GetView(int position, View convertView, ViewGroup parent) { var item = _Items[position]; DownloadItem view = null; if (convertView != null && convertView is DownloadItem) { view = convertView as DownloadItem; if (view.DownloadUri == item.Uri) { return(view); } } if (view == null) { view = new DownloadItem(_context, true); } //var view = new DownloadItem(_context, true); view.Tag = position; view.DownloadUri = item.Uri; view.Stato = view.InitStato = item.Stato; //copertina if (item.Tipo == "pdf") { view.ImgCover.SetImageResource(Resource.Drawable.pdf_icon); view.ImgCover.SetScaleType(ImageView.ScaleType.FitCenter); } else { string key = item.ImageKey; var uri = new Uri(DataManager.Get <ISettingsManager>().Settings.DownloadUrl + "services/edicola_services.php?action=pubCover&zip=" + item.RelativePath + "&img=copertina.jpg&key=" + key + "&app=" + DataManager.Get <ISettingsManager>().Settings.AppId); view.ImgCover.Tag = uri.ToString(); //Koush.UrlImageViewHelper.SetUrlDrawable (view.ImgCover, uri.AbsoluteUri); MBImageLoader.DisplayNetworkImage(uri, view.ImgCover, new PointF(280, 280)); } //titolo view.Title = item.Titolo; //dettagli if (view.Details != null) { string autore = item.Autore; if (autore == "") { autore = _context.GetString(Resource.String.pub_sconosciuto); } view.Details = autore; } //pulsante apri EventHandler openClick = delegate { if (_OpenAction != null) { OpenAction(item.GetLocalPath()); } }; view.OpenButton.Click -= openClick; view.OpenButton.Click += openClick; //download finito Action downFinish = () => { item.Stato = DownloadStato.NoUpdate; }; view.DownloadFinish -= downFinish; view.DownloadFinish += downFinish; view.ConfigureForDownload(); return(view); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); this.Window.RequestFeature(WindowFeatures.NoTitle); SetContentView(Resource.Layout.DownloadDetails); this.SetTitle(_download.Titolo); TextView txtTitolo = FindViewById <TextView>(Resource.Id.txtTitolo); TextView txtAutore = FindViewById <TextView>(Resource.Id.txtAutore); TextView txtPubblicato = FindViewById <TextView>(Resource.Id.txtPubblicato); TextView txtScadenza = FindViewById <TextView>(Resource.Id.txtScadenza); TextView txtDimensione = FindViewById <TextView>(Resource.Id.txtDimensione); ImageView imgCover = FindViewById <ImageView>(Resource.Id.imgCover); Button btnOpen = FindViewById <Button>(Resource.Id.btnOpen); Button btnDownload = FindViewById <Button>(Resource.Id.btnDownload); Button btnBuy = FindViewById <Button>(Resource.Id.btnBuy); TextView txtPrezzo = FindViewById <TextView>(Resource.Id.txtPrezzo); txtTitolo.Text = _download.Titolo; txtAutore.Text = _download.Autore.Trim(); txtPrezzo.Text = ""; if (_download.Tipo == "pdf") { imgCover.SetImageResource(Resource.Drawable.pdf_icon); } else { string key = _download.ImageKey; var uri = new Uri(DataManager.Get <ISettingsManager>().Settings.DownloadUrl + "services/edicola_services.php?action=pubCover&zip=" + _download.RelativePath + "&img=copertina.jpg&key=" + key + "&app=" + DataManager.Get <ISettingsManager>().Settings.AppId); imgCover.Tag = uri.ToString(); //Koush.UrlImageViewHelper.SetUrlDrawable (imgCover, uri.AbsoluteUri); MBImageLoader.DisplayNetworkImage(uri, imgCover, new PointF(360, 360)); } if (_download.DataPubblicazione != DateTime.MinValue) { txtPubblicato.Text = string.Format(Context.GetString(Resource.String.pub_publishedOn), _download.DataPubblicazione.ToString("dd-MM-yyyy")); } else { txtPubblicato.Visibility = ViewStates.Gone; } if (_download.DataScadenza != DateTime.MinValue) { txtScadenza.Text = string.Format(Context.GetString(Resource.String.pub_expireOn), _download.DataScadenza.ToString("dd-MM-yyyy")); } else { txtScadenza.Visibility = ViewStates.Gone; } txtDimensione.Text = Utils.FormatBytes(_download.Dimensione); if (DataManager.Get <ISettingsManager>().Settings.InAppPurchase&& _download.IapID != "") { if (_download.IapAcquistato) { txtPrezzo.Text = string.Format(Context.GetString(Resource.String.iap_purchaseDate), _download.IapDataAcquisto.ToString("dd-MM-yyyy")); } } //pulsante apri btnOpen.SetTextColor(Color.Transparent.FromHex(DataManager.Get <ISettingsManager>().Settings.ButtonColor)); btnOpen.Text = Context.GetString(Resource.String.pub_open); btnOpen.Click += delegate { if (OpenAction != null) { OpenAction(); } }; //pulsante download btnDownload.SetTextColor(Color.Transparent.FromHex(DataManager.Get <ISettingsManager>().Settings.ButtonColor)); btnDownload.Text = Context.GetString(Resource.String.pub_download); btnDownload.Click += delegate { if (DownloadAction != null) { DownloadAction(); } }; //pulsante buy btnBuy.SetTextColor(Color.Transparent.FromHex(DataManager.Get <ISettingsManager>().Settings.ButtonColor)); btnBuy.Text = _download.IapPrezzo; btnBuy.Click += delegate { if (BuyAction != null) { BuyAction(); } }; GradientDrawable gd = new GradientDrawable(); gd.SetColor(Color.Transparent.FromHex("ffffff")); gd.SetCornerRadius(5); gd.SetStroke(1, Color.Transparent.FromHex(DataManager.Get <ISettingsManager>().Settings.ButtonColor)); btnBuy.Background = gd; /*if(FileDownloader.IsWaiting(_download.Uri)) * { * _download.Stato = DownloadStato.Downloading; * }*/ DownloadInfo down = MBDownloadManager.DownloadInfo(_download.Uri.AbsoluteUri); if (down != null && (down.Status == DownloadStatus.Running || down.Status == DownloadStatus.Pending)) { _download.Stato = DownloadStato.Downloading; } //in base allo stato del download configuro i pulsanti switch (_download.Stato) { case DownloadStato.Download: btnDownload.Text = Context.GetString(Resource.String.pub_download); btnOpen.Visibility = ViewStates.Invisible; btnBuy.Visibility = ViewStates.Gone; btnBuy.Enabled = false; break; case DownloadStato.NoUpdate: btnDownload.Visibility = ViewStates.Invisible; btnOpen.Visibility = ViewStates.Visible; btnBuy.Visibility = ViewStates.Gone; btnBuy.Enabled = false; break; case DownloadStato.Update: btnDownload.Text = Context.GetString(Resource.String.down_update); btnOpen.Visibility = ViewStates.Visible; btnBuy.Visibility = ViewStates.Gone; btnBuy.Enabled = false; break; case DownloadStato.Downloading: btnDownload.Text = Context.GetString(Resource.String.down_wait); btnDownload.Enabled = false; btnOpen.Visibility = ViewStates.Invisible; btnBuy.Visibility = ViewStates.Gone; btnBuy.Enabled = false; break; case DownloadStato.Expired: btnDownload.Text = Context.GetString(Resource.String.pub_expired); btnDownload.Enabled = false; btnOpen.Visibility = ViewStates.Invisible; btnBuy.Visibility = ViewStates.Gone; btnBuy.Enabled = false; break; case DownloadStato.Buy: btnDownload.Visibility = ViewStates.Gone; btnDownload.Enabled = false; btnOpen.Visibility = ViewStates.Invisible; btnBuy.Visibility = ViewStates.Visible; btnBuy.Enabled = true; break; default: break; } }