Ejemplo n.º 1
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            // Get our object for this position
            var item = speakers[position];

            //Try to reuse convertView if it's not  null, otherwise inflate it from our item layout
            // This gives us some performance gains by not always inflating a new view
            // This will sound familiar to MonoTouch developers with UITableViewCell.DequeueReusableCell()
            var view = (convertView ??
                        context.LayoutInflater.Inflate(
                            Resource.Layout.SpeakerListItem,
                            parent,
                            false)) as LinearLayout;

            // Find references to each subview in the list item's view
            var bigTextView   = view.FindViewById <TextView>(Resource.Id.NameTextView);
            var smallTextView = view.FindViewById <TextView>(Resource.Id.CompanyTextView);
            var imageview     = view.FindViewById <ImageView>(Resource.Id.SpeakerImageView);

            //Assign this item's values to the various subviews
            bigTextView.SetText(speakers[position].Name, TextView.BufferType.Normal);
            smallTextView.SetText(speakers[position].Title + ", " + this.speakers[position].Company, TextView.BufferType.Normal);

            if (!string.IsNullOrEmpty(speakers[position].ImageUrl))
            {
                var uri = new Uri(speakers[position].ImageUrl);
                imageview.Tag = uri.ToString();
                var iw = new AL.ImageWrapper(imageview, context);

                try {
                    MonoTouch.Dialog.Utilities.ImageLoader.LogDebug("gv + " + position + " " + MonoTouch.Dialog.Utilities.ImageLoader.ImageName(uri.AbsoluteUri));
                    Log.Debug("MWC1", "gv + " + position + " " + MonoTouch.Dialog.Utilities.ImageLoader.ImageName(uri.AbsoluteUri));
                    var drawable = MonoTouch.Dialog.Utilities.ImageLoader.DefaultRequestImage(uri, iw);
                    if (drawable == null)
                    {
                        imageview.SetImageResource(Resource.Drawable.Icon);
                    }
                    else
                    {
                        imageview.SetImageDrawable(drawable);
                    }
                } catch (Exception ex) {
                    MonoTouch.Dialog.Utilities.ImageLoader.Purge();                      // have seen outofmemory here
                    MWCApp.LogDebug("SPEAKERS " + ex.ToString());
                }
            }
            else
            {
                imageview.SetImageResource(Resource.Drawable.Icon);
            }
            //Finally return the view
            return(view);
        }
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            // Get our object for this position
            var item = this.tweets[position];

            //Try to reuse convertView if it's not  null, otherwise inflate it from our item layout
            // This gives us some performance gains by not always inflating a new view
            // This will sound familiar to MonoTouch developers with UITableViewCell.DequeueReusableCell()
            var view = (convertView ??
                        this.context.LayoutInflater.Inflate(
                            Resource.Layout.TwitterListItem,
                            parent,
                            false)) as LinearLayout;

            // Find references to each subview in the list item's view
            var nametextview    = view.FindViewById <TextView>(Resource.Id.NameTextView);
            var timetextview    = view.FindViewById <TextView>(Resource.Id.TimeTextView);
            var handletextview  = view.FindViewById <TextView>(Resource.Id.HandleTextView);
            var contenttextview = view.FindViewById <TextView>(Resource.Id.ContentTextView);
            var imageview       = view.FindViewById <ImageView>(Resource.Id.TwitterImageView);

            //assign this item's values to the various subviews
            nametextview.SetText(this.tweets[position].RealName, TextView.BufferType.Normal);
            timetextview.SetText(this.tweets[position].FormattedTime, TextView.BufferType.Normal);
            handletextview.SetText(this.tweets[position].FormattedAuthor, TextView.BufferType.Normal);
            contenttextview.SetText(this.tweets[position].Title, TextView.BufferType.Normal);

            var uri = new Uri(this.tweets[position].ImageUrl);
            var iw  = new AL.ImageWrapper(imageview, context);

            imageview.Tag = uri.ToString();
            try {
                var drawable = MonoTouch.Dialog.Utilities.ImageLoader.DefaultRequestImage(uri, iw);
                if (drawable != null)
                {
                    imageview.SetImageDrawable(drawable);
                }
            } catch (Exception ex) {
                Log.Debug("TWITTER", ex.ToString());
            }

            //Finally return the view
            return(view);
        }
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            // Get our object for this position
            var item = this.exhibitors[position];

            //Try to reuse convertView if it's not  null, otherwise inflate it from our item layout
            // This gives us some performance gains by not always inflating a new view
            // This will sound familiar to MonoTouch developers with UITableViewCell.DequeueReusableCell()
            var view = (convertView ??
                        this.context.LayoutInflater.Inflate(
                            Resource.Layout.ExhibitorListItem,
                            parent,
                            false)) as LinearLayout;

            // Find references to each subview in the list item's view
            var nameTextView     = view.FindViewById <TextView>(Resource.Id.NameTextView);
            var countryTextView  = view.FindViewById <TextView>(Resource.Id.CountryTextView);
            var locationTextView = view.FindViewById <TextView>(Resource.Id.LocationTextView);
            var imageview        = view.FindViewById <ImageView>(Resource.Id.ExhibitorImageView);

            //Assign this item's values to the various subviews
            nameTextView.SetText(this.exhibitors[position].Name, TextView.BufferType.Normal);
            countryTextView.SetText(this.exhibitors[position].City + ", " + this.exhibitors[position].Country, TextView.BufferType.Normal);
            locationTextView.SetText(this.exhibitors[position].Locations, TextView.BufferType.Normal);

            var uri = new Uri(this.exhibitors[position].ImageUrl);
            var iw  = new AL.ImageWrapper(imageview, context);

            imageview.Tag = uri.ToString();

            try {
                var drawable = MonoTouch.Dialog.Utilities.ImageLoader.DefaultRequestImage(uri, iw);
                if (drawable != null)
                {
                    imageview.SetImageDrawable(drawable);
                }
            } catch (Exception ex) {
                MonoTouch.Dialog.Utilities.ImageLoader.Purge(); // have seen outofmemory here
                MWCApp.LogDebug("EXHIBITORS " + ex.ToString());
            }

            //Finally return the view
            return(view);
        }