/// <summary> /// Loads the image into given UIButton using defined parameters. /// IMPORTANT: It throws image loading exceptions - you should handle them /// </summary> /// <returns>An awaitable Task.</returns> /// <param name="parameters">Parameters for loading the image.</param> /// <param name="button">UIButton that should receive the image.</param> public static Task <IScheduledWork> IntoAsync(this TaskParameter parameters, UIButton button) { return(parameters.IntoAsync(param => param.Into(button))); }
/// <summary> /// Loads the image into given imageView using defined parameters. /// IMPORTANT: It throws image loading exceptions - you should handle them /// </summary> /// <returns>An awaitable Task.</returns> /// <param name="parameters">Parameters for loading the image.</param> /// <param name="item">Image view that should receive the image.</param> public static Task <IScheduledWork> IntoAsync(this TaskParameter parameters, UITabBarItem item) { return(parameters.IntoAsync(param => param.Into(item))); }
public override void BindViewModel(ChatMessageViewModel viewModel) { _viewModelRef = WeakReferenceEx.Create(viewModel); Bindings.Add(this.SetBinding(() => _viewModelRef.Target.Body).WhenSourceChanges(() => { // TODO: check Execute.OnUIThread(() => { var hideMessageBody = string.IsNullOrEmpty(_viewModelRef.Target.Body) && _viewModelRef.Target.HasAttachment; MessageBodyTextView.Visibility = BoolToViewStateConverter.ConvertGone(hideMessageBody == false); MessageBodyTextView.Text = _viewModelRef.Target.Body; }); })); Bindings.Add(this.SetBinding(() => _viewModelRef.Target.TextDateTime).WhenSourceChanges(() => { // TODO: check Execute.OnUIThread(() => { MessageDateTimeTextView.Text = _viewModelRef.Target.TextDateTime; }); })); if (_viewModelRef.Target.HasAttachment) { var model = _viewModelRef.Target.Model; var expr = default(TaskParameter); AttachmentImageView.SetImageResource(StyleHelper.Style.AttachmentImagePlaceholder); UpdateAttachmentImageViewSizeAndVisibility(); if (!string.IsNullOrEmpty(model.ImageCacheKey)) { expr = ImageService.Instance.LoadFile(model.ImageCacheKey); } else if (!string.IsNullOrEmpty(model.ImageRemoteUrl)) { expr = ImageService.Instance.LoadUrl(model.ImageRemoteUrl); } if (expr == null) { return; } _downloadAttachTask = expr.DownSampleInDip(90, 90) .Finish(x => { Execute.BeginOnUIThread(UpdateAttachmentImageViewSizeAndVisibility); }); _downloadAttachTask.IntoAsync(AttachmentImageView); } else { _downloadAttachTask?.Dispose(); AttachmentImageView.SetImageDrawable(null); AttachmentImageView.Visibility = ViewStates.Gone; } if (_isIncomingMessageViewType && SenderPhotoImageView != null) { SenderPhotoImageView.LoadImageWithTextPlaceholder( _viewModelRef.Target.SenderPhotoUrl, _viewModelRef.Target.SenderName, new WhiteLabel.Droid.Controls.AvatarPlaceholderDrawable.AvatarStyles { BackgroundHexColors = StyleHelper.Style.ChatAvatarStyles.BackgroundHexColors, Size = new System.Drawing.Size(35, 35) }, x => x.Transform(new CircleTransformation())); } if (!_isIncomingMessageViewType && MessageStatusView != null) { Bindings.Add(this.SetBinding(() => _viewModelRef.Target.Status).WhenSourceChanges(() => { // TODO: check Execute.OnUIThread(() => { if (_viewModelRef.Target == null) { return; } ChangeMessageViewStatus(_viewModelRef.Target.Status); }); })); } }