public override void OnMessageReceived(RemoteMessage firebasemessage) { //StoringService.LoadMessages(); if (LoginService.LoginStatus) { StoringService.LoadMessages(); Message message = new Message(firebasemessage.Data["NotificationUrl"], firebasemessage.Data["AlertType"], (firebasemessage.Data["CreatedDate"])); StoringService.AddMessage(message); StoringService.SaveMessages(); SendNotification(message); } }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { StoringService.LoadMessages(); View view = inflater.Inflate(Resource.Layout.HomeLayout, container, false); listView = view.FindViewById <ListView>(Resource.Id.lvNotifications); adapter = new MessageListAdapter(view.Context, StoringService.Messages); listView.Adapter = adapter; refresher = view.FindViewById <SwipeRefreshLayout>(Resource.Id.refresher); refresher.Refresh += (sender, e) => { adapter.Update(StoringService.Messages); refresher.Refreshing = false; }; listView.ItemClick += (sender, e) => { try { string url = StoringService.Messages[StoringService.Messages.Count - e.Position - 1].NotificationUrl; StoringService.Messages[StoringService.Messages.Count - e.Position - 1].Checked = true; StoringService.SaveMessages(); adapter.Update(StoringService.Messages); var uri = Android.Net.Uri.Parse(url); Intent intent = new Intent(Intent.ActionView, uri); StartActivity(intent); } catch { AlertDialog.Builder alert = new AlertDialog.Builder(view.Context); alert.SetTitle("Error :"); alert.SetMessage("This message is not a url."); alert.SetPositiveButton("Close", (senderAlert, args) => { Toast.MakeText(view.Context, "Closed!", ToastLength.Short).Show(); }); Dialog dialog = alert.Create(); dialog.Show(); } }; return(view); }
public override void OnPause() { base.OnPause(); StoringService.SaveMessages(); }
public override void OnResume() { base.OnResume(); StoringService.LoadMessages(); }