Last active
November 20, 2015 15:12
-
-
Save SlyNet/f1fad9ee956c08512814 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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