public AutoCompleteList() { InitializeComponent(); TicketListView.ItemTapped += (sender, args) => { RepliconTask ticket = args.Item as RepliconTask; OnTicketSelected?.Invoke(ticket); SelectedTicket = ticket; SearchBar.Text = ""; }; SearchBar.TextChanged += (sender, args) => { SearchTextChanged(args); }; }
static void OnSelectedTicketChanged(BindableObject bindable, object oldValue, object newValue) { if (newValue == null) { ((AutoCompleteList)bindable).SelectedItemStack.IsVisible = false; ((AutoCompleteList)bindable).SearchBar.IsVisible = true; } else { RepliconTask ticket = ((RepliconTask)newValue); ((AutoCompleteList)bindable).SelectedItemStack.IsVisible = true; var descriptionText = ((AutoCompleteList)bindable).SelectedTicket.description; if (!string.IsNullOrEmpty(descriptionText)) { descriptionText = $": {descriptionText}"; } ((AutoCompleteList)bindable).SelectedItemLabel.Text = $"{((AutoCompleteList)bindable).SelectedTicket.name}{descriptionText}"; ((AutoCompleteList)bindable).SearchBar.IsVisible = false; } }
public static async Task <bool> LoadData(IProgress <double> progress) { //get list of all uri's on the database. currentURIS = App.Database.GetItems <RepliconTask>().Select(x => x.uri).ToArray(); //update progressbar progress?.Report(.010); //load ticket from DB var rawData = await RepliConnect.GetTickets(); if (rawData == null) { progress?.Report(0); return(false); } //update progressbar progress?.Report(.015); //cast to list to allow getting total count var dataList = rawData.ToList(); //set local variable of total count int rawDataCount = dataList.Count; //counter for number of items itterated double totalProcessed = 0; foreach (var item in dataList) { //update progress progress?.Report(Math.Round(totalProcessed++ / rawDataCount, 3)); //Skip item if already in DB if (!Predicate(item)) { continue; } //create new task var task = new RepliconTask(); task.ProjectURI = item.ProjectURI; //assign values if (string.IsNullOrEmpty(item.TaskURI)) //is Project { task.name = item.ProjectName; } else // is task { task.description = item.TaskCode; task.name = item.TaskName; task.uri = item.TaskURI; } //set billable status task.IsBillable = (!string.IsNullOrEmpty(item.BillingType)) && item.BillingType.Equals("Time And Material"); //save to DB App.Database.SaveItem(task); } //update progress to 100% progress?.Report(1); //Invoke delegate for any work to be done after sync OnTicketLoadCompleted?.Invoke(); return(true); }