static Task <SelectorResult> OpenDialog(Context context, SelectorType type, bool isSelectMany, string path = null, string[] paths = null) { return(Task.Factory.StartNew <SelectorResult>(() => { SelectorResult selected = null; var waitSelectedResetEvent = new ManualResetEvent(false); var selectorIntent = new Intent(context, typeof(FileSelectorActivity)); FileSelectorActivity.IsSelectMany = isSelectMany; FileSelectorActivity.SelectorType = type; FileSelectorActivity.OnCanceled += () => { selected = new SelectorResult { SelectItem = path, SelectItems = paths }; waitSelectedResetEvent.Set(); }; FileSelectorActivity.OnSelectorCompleted += (SelectorResult result) => { selected = result; waitSelectedResetEvent.Set(); }; context.StartActivity(selectorIntent); waitSelectedResetEvent.WaitOne(); return selected; })); }
void SureSelect() { Finish(); if (Adapter != null) { var result = new SelectorResult { SelectItem = Adapter.Selects.FirstOrDefault(), SelectItems = Adapter.Selects.ToArray(), }; OnSelectorCompleted?.Invoke(result); } }