| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- using System;
- using MonoTouch.Dialog;
- using SDWebImage;
- #if __UNIFIED__
- using Foundation;
- using UIKit;
- #else
- using MonoTouch.Foundation;
- using MonoTouch.UIKit;
- #endif
- namespace SDWebImageMTDialogSample
- {
- public class ImageLoaderStringElement : StringElement
- {
- static NSString skey = new NSString ("ImageLoaderStringElement");
- public UIImage Placeholder { get; private set; }
- public NSUrl ImageUrl { get; private set; }
- public UITableViewCellAccessory Accessory { get; set; }
-
- public ImageLoaderStringElement (string caption, NSUrl imageUrl, UIImage placeholder) : base (caption)
- {
- Placeholder = placeholder;
- ImageUrl = imageUrl;
- this.Accessory = UITableViewCellAccessory.None;
- }
-
- public ImageLoaderStringElement (string caption, string value, NSUrl imageUrl, UIImage placeholder) : base (caption, value)
- {
- Placeholder = placeholder;
- ImageUrl = imageUrl;
- this.Accessory = UITableViewCellAccessory.None;
- }
- #if __UNIFIED__
- public ImageLoaderStringElement (string caption, Action tapped, NSUrl imageUrl, UIImage placeholder) : base (caption, tapped)
- #else
- public ImageLoaderStringElement (string caption, NSAction tapped, NSUrl imageUrl, UIImage placeholder) : base (caption, tapped)
- #endif
- {
- Placeholder = placeholder;
- ImageUrl = imageUrl;
- this.Accessory = UITableViewCellAccessory.None;
- }
-
- protected override NSString CellKey {
- get {
- return skey;
- }
- }
- public override UITableViewCell GetCell (UITableView tv)
- {
- var cell = tv.DequeueReusableCell (CellKey);
- if (cell == null){
- cell = new UITableViewCell (Value == null ? UITableViewCellStyle.Default : UITableViewCellStyle.Subtitle, CellKey);
- cell.SelectionStyle = UITableViewCellSelectionStyle.Blue;
- }
-
- cell.Accessory = Accessory;
- cell.TextLabel.Text = Caption;
- cell.TextLabel.TextAlignment = Alignment;
-
- cell.ImageView.SetImage (ImageUrl, Placeholder);
-
- // The check is needed because the cell might have been recycled.
- if (cell.DetailTextLabel != null)
- cell.DetailTextLabel.Text = Value == null ? "" : Value;
-
- return cell;
- }
-
- }
- }
|