Ejemplo n.º 1
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            var item         = this[position];
            var fontRegular  = Typeface.CreateFromAsset(_context.Assets, rutaFuenteTitiliumRegular);
            var fontSemiBold = Typeface.CreateFromAsset(_context.Assets, rutaFuenteTitiliumSemiBold);

            if (!item.esFecha)
            {
                convertView = _context.LayoutInflater.Inflate(Resource.Layout.NotificacionesRow, null);
                string horaFormatoCorrecto = this.formateadorHora(item.hora);
                convertView.FindViewById <TextView>(Resource.Id.horaNotificacion).Text = horaFormatoCorrecto;

                if (item.estado)
                {
                    convertView.FindViewById <TextView>(Resource.Id.contenidoNotificacion).Text     = item.mensajeNotificacion;
                    convertView.FindViewById <TextView>(Resource.Id.contenidoNotificacion).Typeface = fontRegular;
                    convertView.FindViewById <TextView>(Resource.Id.contenidoNotificacion).LayoutParameters.Height = LayoutParams.WrapContent;
                    convertView.FindViewById <ImageView>(Resource.Id.chevron).SetImageResource(Resource.Drawable.exp2);
                    convertView.FindViewById <ImageView>(Resource.Id.ic_noLeida).Visibility    = ViewStates.Invisible;
                    convertView.FindViewById <TextView>(Resource.Id.horaNotificacion).Typeface = fontRegular;
                    convertView.FindViewById <LinearLayout>(Resource.Id.llFondoItemNotificacion).SetBackgroundColor(Color.Rgb(255, 255, 255));
                }
                else
                {
                    convertView.FindViewById <LinearLayout>(Resource.Id.llFondoItemNotificacion).SetBackgroundColor(Color.Rgb(245, 245, 245));
                    convertView.FindViewById <TextView>(Resource.Id.contenidoNotificacion).Text     = item.mensajeNotificacionCorto;
                    convertView.FindViewById <TextView>(Resource.Id.contenidoNotificacion).Typeface = fontSemiBold;
                    convertView.FindViewById <TextView>(Resource.Id.contenidoNotificacion).LayoutParameters.Height = LayoutParams.WrapContent;
                    convertView.FindViewById <ImageView>(Resource.Id.chevron).SetImageResource(Resource.Drawable.exp1);
                    convertView.FindViewById <ImageView>(Resource.Id.ic_noLeida).Visibility = ViewStates.Visible;
                    List <string> listadoDeNotificacionesLeidas = preferenciasNotificacionesLeidas.obneterListadoDeNotificacionesLeidas(_context);
                    convertView.FindViewById <TextView>(Resource.Id.horaNotificacion).Typeface = fontSemiBold;
                    foreach (var notificacionLeida in listadoDeNotificacionesLeidas)
                    {
                        if (item.idNotificacion.Equals(notificacionLeida))
                        {
                            convertView.FindViewById <ImageView>(Resource.Id.ic_noLeida).Visibility         = ViewStates.Invisible;
                            convertView.FindViewById <TextView>(Resource.Id.contenidoNotificacion).Typeface = fontRegular;
                            convertView.FindViewById <TextView>(Resource.Id.horaNotificacion).Typeface      = fontRegular;
                            convertView.FindViewById <LinearLayout>(Resource.Id.llFondoItemNotificacion).SetBackgroundColor(Color.Rgb(255, 255, 255));
                        }
                    }
                }
            }
            else
            {
                convertView = _context.LayoutInflater.Inflate(Resource.Layout.FechaRow, null);
                convertView.FindViewById <TextView>(Resource.Id.lblFecha).Text     = item.mensajeNotificacion;
                convertView.FindViewById <TextView>(Resource.Id.lblFecha).Typeface = fontSemiBold;
            }
            return(convertView);
        }
Ejemplo n.º 2
0
        /// 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();
            };
        }