async Task Connect() { try { hubConnection.On <List <int> >("Neprocitane", (list) => { if (list.Count > 0) { ToolbarItems.Where(t => t.Text.Contains("poruke")).SingleOrDefault().IconImageSource = "envnew.png"; } else { ToolbarItems.Where(t => t.Text.Contains("poruke")).SingleOrDefault().IconImageSource = "envelope.png"; } DependencyService.Get <INotification>().DeleteNotification(list); }); hubConnection.On <List <int> >("NeprocitaneObavijesti", (list) => { if (list.Count > 0) { ToolbarItems.Where(t => t.Text.Contains("obavijest")).SingleOrDefault().IconImageSource = "signsNew.png"; } else { ToolbarItems.Where(t => t.Text.Contains("obavijest")).SingleOrDefault().IconImageSource = "signs.png"; } DependencyService.Get <INotification>().DeleteNotification(list); }); hubConnection.On <Poruka, string>("ReceiveMessageMob", async(poruka, ime) => { await hubConnection.SendAsync("NeprocitanePoruke"); DependencyService.Get <INotification>().CreateNotification(poruka.IdRazgovor, "Nova poruka: " + ime, poruka.Poruka1); }); hubConnection.On <Razgovor, string>("ReceiveNewConversationMob", async(razg, ime) => { await hubConnection.SendAsync("NeprocitanePoruke"); DependencyService.Get <INotification>().CreateNotification(razg.Id, "Nova poruka: " + ime, razg.Poruka.First().Poruka1); }); hubConnection.On <OsobneObavijesti>("NovaObavijest", async(ob) => { await hubConnection.SendAsync("NeprocitaneObavijesti"); var tekst = ob.Tekst.Replace("<b>", ""); tekst = tekst.Replace("</b>", ""); DependencyService.Get <INotification>().CreateNotification(ob.Id, "Nova obavijest: ", tekst); }); await hubConnection.StartAsync(); await hubConnection.SendAsync("NeprocitanePoruke"); await hubConnection.SendAsync("NeprocitaneObavijesti"); } catch (Exception e) { int g = 0; } }
void OnRemoveSecondaryToolBarItemClicked(object sender, EventArgs e) { var secondaryToolbarItems = ToolbarItems.Where(i => i.Order == ToolbarItemOrder.Secondary).ToList(); if (secondaryToolbarItems.Count == 0) { return; } var toolBarItemIndex = secondaryToolbarItems.Count - 1; var toolbarItem = secondaryToolbarItems[toolBarItemIndex]; ToolbarItems.Remove(toolbarItem); }