private void LoadDocuments() { Utils.WriteLog("edicola PopulateTable"); this.SetTitle(); IList <Pubblicazione> documents = PubblicazioniManager.GetPubblicazioni(_CurrentDir.FullName, DataManager.Get <IPreferencesManager>().Preferences.EdicolaOrder); IList <DirectoryInfo> _Directories = FileSystemManager.GetFolders(_CurrentDir.FullName); int lastLineCol = _Directories.Count - ((int)(_Directories.Count / ColumnNum) * ColumnNum); if (ColumnNum > 1 && lastLineCol > 0) { int n = ColumnNum - lastLineCol; for (int i = 0; i < n; i++) { DirectoryInfo info = new DirectoryInfo("/"); _Directories.Add(info); } } _Items = new List <Object>(); _Items.AddRange(_Directories); _Items.AddRange(documents); var adapter = new EdicolaGridAdapter(Activity, _Items); adapter.ItemOptionClick += OnItemOptionClick; _EdicolaGridView.Adapter = adapter; if (!DataManager.Get <ISettingsManager>().Settings.DocAutoplayRun) { DataManager.Get <ISettingsManager>().Settings.DocAutoplayRun = true; var docAuto = (from d in documents where d.Autoplay == true select d).FirstOrDefault(); if (docAuto != null) { if (docAuto.DataScadenza >= DateTime.Now || docAuto.DataScadenza == DateTime.MinValue) { Intent i = new Intent(); i.SetClass(Activity, typeof(ViewerScreen)); i.SetAction(Intent.ActionView); i.PutExtra("pubPath", docAuto.Path); Activity.StartActivityForResult(i, 0); } } } }
private void CheckUpdates() { Uri host = new Uri(DataManager.Get <ISettingsManager>().Settings.DownloadUrl); if (!Reachability.IsHostReachable("http://" + host.Host)) { return; } var info = new DirectoryInfo(DataManager.Get <ISettingsManager>().Settings.DocPath); var dir = _CurrentDir.FullName.Replace(info.FullName, "").Trim('/'); ThreadPool.QueueUserWorkItem(delegate { var downloads = DownloadManager.GetDocuments(dir); //var updates = downloads.Where(d => d.Stato == DownloadStato.Update); _downloads = downloads.ToList(); if (Activity == null) { return; } Activity.RunOnUiThread(() => { try { EdicolaGridAdapter adapter = (EdicolaGridAdapter)_EdicolaGridView.Adapter; adapter.CheckUpdates(_downloads); } catch (Exception ex) { Log.Error("", ex.Message); } }); }); }