/// Metodo que envia los rescursos de la lista al adaptador. public async override void OnActivityCreated(Bundle savedInstanceState) { base.OnActivityCreated(savedInstanceState); setUpViews(); dialogoLoadingBcoSecurityActivity.mostrarViewLoadingSecurity(); await notificacionesUtil.Llamarservicio(this.Activity, UtilAndroid.getRut()); DialogoLoadingBcoSecurityActivity.ocultarLoadingSecurity(); var agrupacion = notificacionesUtil.NotificacionesPorFecha(); listadoFinal = new List <Notificacion>(); foreach (var grupo in agrupacion) { var notifFecha = new Notificacion(); notifFecha.esFecha = true; DateTime fecha = DateTime.Parse(grupo.Key, CultureInfo.CurrentCulture); var mes = NombreMes(fecha.Month); var fechaFormat = fecha.Day + " " + mes; notifFecha.mensajeNotificacion = fechaFormat; listadoFinal.Add(notifFecha); listadoFinal.AddRange(grupo.ToList()); } adapterHistoricoNotificaciones = new NotificacionesAdapter(Activity, listadoFinal); NotificacionesListView.Adapter = adapterHistoricoNotificaciones; NotificacionesListView.ItemClick += (sender, e) => { Bean.Notificacion notiSelected = adapterHistoricoNotificaciones.GetNotificacion(e.Position); foreach (var notificacion in listadoFinal) { if (notificacion.idNotificacion == notiSelected.idNotificacion) { if (notificacion.estado) { notificacion.estado = false; } else { notificacion.estado = true; } } } listNotificacionLeidas = preferenciasNotificacionesLeidas.obneterListadoDeNotificacionesLeidas(Activity); if (listNotificacionLeidas.Count == 0) { if (listNotificacionLeidas == null) { listNotificacionLeidas.Remove(null); } preferenciasNotificacionesLeidas.guardarPreferencia(Activity, notiSelected.idNotificacion); } else { foreach (string notificacionLeida in listNotificacionLeidas) { if (!notificacionLeida.Equals(notiSelected.idNotificacion)) { preferenciasNotificacionesLeidas.guardarPreferencia(Activity, notiSelected.idNotificacion); } } } if (listNotificacionLeidas != null || listNotificacionLeidas.Count != 0) { int contadorDeNotificacionesRefrescado = preferenciasNotificacionesLeidas.getContadorNotificacionesNoLeidas(Activity, listadoFinal); lblContadorNotificacionesNoLeidas = Activity.FindViewById <TextView>(Resource.Id.lblContadorNotificacionesNoLeidas); lblContadorNotificacionesNoLeidas.Text = contadorDeNotificacionesRefrescado + string.Empty; } adapterHistoricoNotificaciones.NotifyDataSetChanged(); }; lblMarcarComoLeida.Click += delegate { foreach (var notificacion in listadoFinal) { listNotificacionLeidas = preferenciasNotificacionesLeidas.obneterListadoDeNotificacionesLeidas(Activity); if (listNotificacionLeidas.Count == 0) { if (listNotificacionLeidas == null) { listNotificacionLeidas.Remove(null); } preferenciasNotificacionesLeidas.guardarPreferencia(Activity, notificacion.idNotificacion); } else { preferenciasNotificacionesLeidas.guardarPreferencia(Activity, notificacion.idNotificacion); } notificacion.estado = true; } relativeLayoutCampanaNotificacionesContador.Visibility = ViewStates.Gone; btnCamapanaNotificaciones.Visibility = ViewStates.Visible; adapterHistoricoNotificaciones.NotifyDataSetChanged(); }; }
protected async override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Home); nombreConocido = MainActivity.returnNombreConsultaEnrolado(); nombreDesdeConfirmacion = ConfirmacionEnroladoActivity.returnNombreConsultaEnroladoConocido(); // NotificacionesFragment NotificacionesFragment = new NotificacionesFragment(); nombreTitulo = nombreConocido; if (string.IsNullOrEmpty(nombreTitulo)) { nombreTitulo = nombreDesdeConfirmacion; } string nombreLogin = nombreTitulo; nombreUsuario = nombreLogin.Split(' '); primerNombreUsuario = nombreUsuario[0].ToLower(); segundoNombreUsuario = nombreUsuario[1].ToLower(); string primeraLetraPrimerNombre = primerNombreUsuario.Substring(0, 1).ToUpper(); string restoPrimernombreFormateado = primerNombreUsuario.Substring(1, primerNombreUsuario.Length - 1); primerNombreFormateado = primeraLetraPrimerNombre + restoPrimernombreFormateado; if (!string.IsNullOrEmpty(segundoNombreUsuario)) { string primeraLetraSegundoNombre = segundoNombreUsuario.Substring(0, 1).ToUpper(); string restoSegundonombreFormateado = segundoNombreUsuario.Substring(1, segundoNombreUsuario.Length - 1); segundoNombreFormateado = primeraLetraSegundoNombre + restoSegundonombreFormateado; } string nombreUserFormateado = primerNombreFormateado + " " + segundoNombreFormateado; drawerLayout = FindViewById <DrawerLayout>(Resource.Id.drawer_layout); btnBurger = FindViewById <ImageView>(Resource.Id.btnBurger); btnCamapanaNotificaciones = FindViewById <ImageView>(Resource.Id.btnCamapanaNotificaciones); btnCamapanaNotificacionesNoLeida = FindViewById <ImageView>(Resource.Id.btnCamapanaNotificacionesNoLeida); lblContadorNotificacionesNoLeidas = FindViewById <TextView>(Resource.Id.lblContadorNotificacionesNoLeidas); relativeLayoutCampanaNotificacionesContador = FindViewById <RelativeLayout>(Resource.Id.relativeLayoutCampanaNotificacionesContador); notificacionesUtil = new NotificacionesUtil(this); preferenciasNotificacionesLeidas = new PreferenciasNotificacionesLeidas(); listadoFinal = await notificacionesUtil.Llamarservicio(this, UtilAndroid.getRut()); int contadorNotificaciones = preferenciasNotificacionesLeidas.getContadorNotificacionesNoLeidas(this, listadoFinal); if (contadorNotificaciones == 0) { relativeLayoutCampanaNotificacionesContador.Visibility = ViewStates.Gone; btnCamapanaNotificaciones.Visibility = ViewStates.Visible; btnCamapanaNotificaciones.Click += BtnCamapanaNotificaciones_Click; } else { lblContadorNotificacionesNoLeidas.Text = contadorNotificaciones + string.Empty; relativeLayoutCampanaNotificacionesContador.Visibility = ViewStates.Visible; btnCamapanaNotificaciones.Visibility = ViewStates.Gone; btnCamapanaNotificacionesNoLeida.Click += BtnCamapanaNotificacionesNoLeida_Click; } btnBurger.Click += BtnBurger_Click; var navigationView = FindViewById <NavigationView>(Resource.Id.nav_view); navigationView.NavigationItemSelected += NavigationView_NavigationItemSelected; View hView = navigationView.GetHeaderView(cero); lblUsuarioMenu = hView.FindViewById <TextView>(Resource.Id.lblUsuarioMenu); lblUsuarioMenu.Text = nombreUserFormateado; var fontRegular = Typeface.CreateFromAsset(Assets, rutaFuenteTitilium); var fontBold = Typeface.CreateFromAsset(Assets, rutaFuenteTitiliumBold); lblUsuarioMenu.Typeface = fontRegular; cambiarFuenteMenu(); var fragmentOnOff = FragmentManager.BeginTransaction(); fragmentOnOff.AddToBackStack(null); fragmentOnOff.Add(Resource.Id.HomeLayout, new OnOffFragment()); fragmentOnOff.Commit(); dialogoLoadingBcoSecurityActivity = new DialogoLoadingBcoSecurityActivity(this); }