Skip to content

Instantly share code, notes, and snippets.

@SlyNet
Last active November 20, 2015 15:12
Show Gist options
  • Save SlyNet/f1fad9ee956c08512814 to your computer and use it in GitHub Desktop.
Save SlyNet/f1fad9ee956c08512814 to your computer and use it in GitHub Desktop.
public class HttpImageView : ImageView
{
private readonly MvxDynamicImageHelper<Bitmap> _imageHelper;
public HttpImageView(Context context, IAttributeSet attrs)
: base(context, attrs)
{
this._imageHelper = new MvxDynamicImageHelper<Bitmap>();
this._imageHelper.ImageChanged += this.ImageHelperOnImageChanged;
var typedArray = context.ObtainStyledAttributes(attrs, MvxAndroidBindingResource.Instance.ImageViewStylableGroupId);
int numStyles = typedArray.IndexCount;
for (var i = 0; i < numStyles; ++i)
{
int attributeId = typedArray.GetIndex(i);
if (attributeId == MvxAndroidBindingResource.Instance.SourceBindId)
{
this.HttpImageUrl = typedArray.GetString(attributeId);
}
}
typedArray.Recycle();
}
public string HttpImageUrl
{
get { return this.Image.ImageUrl; }
set { this.Image.ImageUrl = value; }
}
public HttpImageView(Context context)
: base(context)
{
}
protected HttpImageView(IntPtr javaReference, JniHandleOwnership transfer)
: base(javaReference, transfer)
{
}
public MvxDynamicImageHelper<Bitmap> Image { get { return this._imageHelper; } }
private void ImageHelperOnImageChanged(object sender, MvxValueEventArgs<Bitmap> mvxValueEventArgs)
{
this.SetImageBitmap(mvxValueEventArgs.Value);
this.Invalidate();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment