public bool CollectMapFiles(string args) { if (string.IsNullOrEmpty(ActiveContext.User.Folder)) { return(Try.Show <bool>(false, "用户文件箱尚未设置")); } void job() => ActiveContext.FolderMapStore.CollectMapFiles(args); var worker = new PartialBackgroudWorkerAsyncTask(ViewActivity as PartialActivity, job); worker.Execute(); return(true); }
public bool ScanFileMaps(string args) { if (string.IsNullOrEmpty(ActiveContext.User.Folder)) { return(Try.Show <bool>(false, "用户文件箱尚未设置")); } if (string.IsNullOrEmpty(args)) { return(Try.Show <bool>(false, "参数未正确提供")); } var kind = FolderKindExtension.TryParse(args); if (kind == FolderKind.None) { return(TryCatch.Current.Show(false, $"{args} 未定义的文件夹分类")); } List <string> dirs = null; void job() { var exts = FolderKindExtension.GetExtensions(args); if (exts.Length == 0) { return; } dirs = ActiveContext.FolderMapStore.ScanPath(Android.OS.Environment.ExternalStorageDirectory.Path, exts); }; bool after() { if (dirs == null) { return(Try.Show <bool>(false, "扫描返回值异常")); } var view = ViewActivity as PartialActivity; (FolderKind kind, List <string> dirs)model = (kind, dirs); var json = JsonConvert.SerializeObject(model); view.OpenWebview(FolderMapExplerorView.Partial, json); return(true); } var worker = new PartialBackgroudWorkerAsyncTask(ViewActivity as PartialActivity, job, null, () => after()); worker.Execute(); return(true); }