Intent CreateProperIntent(HistoryItem item) { var intent = new Intent (); intent.SetAction (Intent.ActionView); if (!string.IsNullOrEmpty (item.Outgoing)) { var uri = Android.Net.Uri.Parse (item.LocalPath); intent.SetDataAndType (uri, GetMimeTypeForFile (GetDisplayNameFromURI (uri))); } else { var uri = Android.Net.Uri.FromFile (new Java.IO.File (item.LocalPath)); intent.SetDataAndType (uri, GetMimeTypeForFile (item.LocalPath)); } return intent; }
private void StartDownload(string url, HistoryItem hItem, ProgressBarX progress, View view) { Directory.CreateDirectory (Path.GetDirectoryName (hItem.LocalPath)); Server.DownloadFileAsync (url, hItem.LocalPath, (s, e) => { if (e.Error != null) Console.Out.WriteLine ("Error fetching file: " + e.Error.ToString ()); hItem.Downloading = false; UpdateProgress (progress, view, 100); }); }
HistoryItem CreateIncomingItem(DataItem item, bool alreadyDownloaded, ProgressBarX progress, View view) { if (!item.Data.StartsWith (CrossCopyApp.Srv.CurrentPath)) return new HistoryItem { Incoming = item.Data, Downloading = false }; var hItem = new HistoryItem { Incoming = Path.GetFileName (item.Data), LocalPath = BaseDir + item.Data.Substring (4, item.Data.Length - 4), Downloading = !alreadyDownloaded }; if (hItem.Downloading) { progress.Visibility = ViewStates.Visible; progress.Indeterminate = true; view.Visibility = ViewStates.Invisible; StartDownload (item.Data, hItem, progress, view); } return hItem; }