Skip to content

Instantly share code, notes, and snippets.

@Redth
Created May 19, 2010 03:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Redth/405911 to your computer and use it in GitHub Desktop.
Save Redth/405911 to your computer and use it in GitHub Desktop.
using System;
using MonoTouch.CoreFoundation;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using MonoTouch.Dialog;
namespace FbGroups
{
public class UrlImageStringElement<TKey> : ImageStringElement, MonoTouch.UrlImageStore.IUrlImageUpdated<TKey>
{
UITableViewCell cell = null;
UITableView tableView = null;
MonoTouch.UrlImageStore.UrlImageStore<TKey> imgStore = null;
public UrlImageStringElement (MonoTouch.UrlImageStore.UrlImageStore<TKey> imageStore,
string caption,
NSAction tapped,
string imageUrl,
TKey id) : base(caption, tapped, imageStore.DefaultImage)
{
this.imgStore = imageStore;
this.Id = id;
this.ImageUrl = imageUrl;
}
public UrlImageStringElement(MonoTouch.UrlImageStore.UrlImageStore<TKey> imageStore,
string caption,
string imageUrl,
TKey id) : base(caption, imageStore.DefaultImage)
{
this.imgStore = imageStore;
this.Id = id;
this.ImageUrl = imageUrl;
}
public void UrlImageUpdated (TKey id)
{
if (this.Id.Equals(id))
{
var img = this.imgStore.GetImage(id);
this.cell.BeginInvokeOnMainThread(delegate {
this.cell.ImageView.Image = img;
this.tableView.ReloadData(); });
}
}
public override UITableViewCell GetCell (MonoTouch.UIKit.UITableView tv)
{
cell = base.GetCell (tv);
tableView = tv;
this.cell.ImageView.Image = this.imgStore.RequestImage(this.Id, this.ImageUrl, this);
return cell;
}
public TKey Id
{
get;set;
}
public string ImageUrl
{
get;set;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment