public void OnNotificationRemoved(StatusBarNotification sbn) { int position = GetNotificationPosition(sbn); if (position >= 0) { StatusBarNotifications.RemoveAt(position); using (var h = new Handler(Looper.MainLooper)) h.Post(() => { //When removing a summary notification it causes a IndexOutOfBoundsException... //notificationAdapter.NotifyItemRemoved(position); //This has to be fixed, anyway, because this change makes the adapter to lose the animations when removing a item notificationAdapter.NotifyDataSetChanged(); }); } if (StatusBarNotifications.Count == 0) { OnNotificationListSizeChanged(new NotificationListSizeChangedEventArgs { ThereAreNotifications = false }); } OnNotificationRemoved(); }
private void clearItemsSelected() { List <LNotication> list = adapterLvw.List.Where(x => x.IsSelected = true).ToList(); View view; foreach (LNotication notification in list) { view = getViewByPosition(adapterLvw.GetPosition(notification), lvwNotification); view.SetBackgroundColor(Android.Graphics.Color.White); notification.IsSelected = false; } adapterLvw.NotifyDataSetChanged(); }
private void SwipeRefreshLayoutOnRefresh(object sender, EventArgs e) { try { //Get Data Api MAdapter.NotificationList.Clear(); MAdapter.NotifyDataSetChanged(); StartApiService(); } catch (Exception exception) { Console.WriteLine(exception); } }
public void OnNotificationRemoved(OpenNotification sbn) { if (sbn.GetPackage() == "android" && sbn.GetTag() == "com.android.server.wm.AlertWindowNotification - com.underground.livedisplay") { return; } if (sbn.IsSummary()) { return; //Ignore the summary notification. } int position = GetNotificationPosition(sbn); OpenNotification notificationToBeRemoved = null; if (position >= 0) { //if found, then use the Notification to be removed instead. //the reason is that the 'sbn' coming from this method has less data. //then it makes data that I need from the notification unavailable. notificationToBeRemoved = StatusBarNotifications[position]; StatusBarNotifications.RemoveAt(position); using (var h = new Handler(Looper.MainLooper)) h.Post(() => { //When removing a summary notification it causes a IndexOutOfBoundsException... //notificationAdapter.NotifyItemRemoved(position); //This has to be fixed, anyway, because this change makes the adapter to lose the animations when removing a item notificationAdapter.NotifyDataSetChanged(); }); } OnNotificationListSizeChanged(new NotificationListSizeChangedEventArgs { ThereAreNotifications = !(StatusBarNotifications.Where(n => n.IsRemovable()).ToList().Count == 0) }); NotificationRemoved?.Invoke(this, new NotificationRemovedEventArgs() { OpenNotification = notificationToBeRemoved ?? sbn, //avoid nulls. }); }
async void LoadNotifications() { _notificationList.Add(new Notifications { Name = "Daniel Sarabusing", Content = "Aircon not functioning", Time = "08:00AM" }); _notificationList.Add(new Notifications { Name = "Daniel Sarabusing", Content = "Aircon not functioning", Time = "08:00AM" }); _notificationList.Add(new Notifications { Name = "Enber Francisco", Content = "Aircon problem", Time = "08:01AM" }); _notificationList.Add(new Notifications { Name = "JB Rillo", Content = "Mainit po", Time = "08:03AM" }); _notificationList.Add(new Notifications { Name = "Rico Arabia", Content = "Sira ang aircon", Time = "08:05AM" }); NotificationAdapter adapter = new NotificationAdapter(Activity, _notificationList); _notifications.SetAdapter(adapter); adapter.NotifyDataSetChanged(); }
private void LoadElements() { if (_notificationList != null && _notificationList.Any()) { _notificationListView = _view.FindViewById <ListView>(Resource.Id.notificationListView); var notificationAdapter = new NotificationAdapter(Activity, _notificationList); var newsLayout = _view.FindViewById <LinearLayout>(Resource.Id.newsLayoutId); newsLayout.Visibility = ViewStates.Visible; _lottieAnimation.Visibility = ViewStates.Gone; _notificationListView.Adapter = notificationAdapter; notificationAdapter.NotifyDataSetChanged(); } else { _emptyState = _view.FindViewById <LinearLayout>(Resource.Id.empty_state); _emptyState.Visibility = ViewStates.Visible; _lottieAnimation.Visibility = ViewStates.Gone; } _lottieAnimation.Dispose(); GarbageCollector(); }
public void CancelAllNotifications() { notificationAdapter.NotifyDataSetChanged(); }