private async Task RepeatVerifyUpload() { do { for (var i = 0; i < Media.Count; i++) { var media = Media[i]; if (media.UploadState != UploadState.UploadEnd) { continue; } var operationResult = await Presenter.TryGetMediaStatus(media.UploadMediaUuid); if (!IsInitialized) { return; } if (operationResult.IsSuccess) { switch (operationResult.Result.Code) { case UploadMediaCode.Done: { media.UploadState = UploadState.UploadVerified; //SaveGalleryTemp(); } break; case UploadMediaCode.FailedToProcess: case UploadMediaCode.FailedToUpload: case UploadMediaCode.FailedToSave: { media.UploadState = UploadState.UploadError; //SaveGalleryTemp(); } break; } } } if (Media.All(m => m.UploadState != UploadState.UploadEnd)) { break; } await Task.Delay(3000); if (!IsInitialized) { return; } } while (true); }
protected async Task ConvertAndSave() { await Task.Run(() => { try { if (Media.All(m => m.UploadState != UploadState.ReadyToSave)) { return; } for (var i = 0; i < Media.Count; i++) { var model = Media[i]; if (model.UploadState == UploadState.ReadyToSave) { model.TempPath = CropAndSave(model); if (string.IsNullOrEmpty(model.TempPath)) { continue; } model.UploadState = UploadState.Saved; if (!IsInitialized) { break; } var i1 = i; Activity.RunOnUiThread(() => { if (_isSingleMode) { Preview.SetImageBitmap(Media[i1]); } else { _galleryAdapter.NotifyItemChanged(i1); } }); } } //SaveGalleryTemp(); } catch (Exception ex) { AppSettings.Logger.Error(ex); } }); }
private void DeleteMessagesInternal(TLMessageBase lastMessage, IList <TLMessageBase> messages) { var cachedMessages = new TLVector <long>(); var remoteMessages = new TLVector <int>(); for (int i = 0; i < messages.Count; i++) { if (messages[i].RandomId.HasValue && messages[i].RandomId != 0L) { cachedMessages.Add(messages[i].RandomId.Value); } if (messages[i].Id > 0) { remoteMessages.Add(messages[i].Id); } } CacheService.DeleteMessages(Peer.ToPeer(), lastMessage, remoteMessages); CacheService.DeleteMessages(cachedMessages); var dialog = CacheService.GetDialog(_peer.ToPeer()); if (dialog != null) { Aggregator.Publish(new MessagesRemovedEventArgs(dialog, messages)); } Execute.BeginOnUIThread(() => { for (int j = 0; j < messages.Count; j++) { Media.All(x => x.Remove(messages[j] as TLMessage)); Files.All(x => x.Remove(messages[j] as TLMessage)); Links.All(x => x.Remove(messages[j] as TLMessage)); Music.All(x => x.Remove(messages[j] as TLMessage)); } RaisePropertyChanged(() => With); SelectionMode = ListViewSelectionMode.None; //this.IsEmptyDialog = (this.Items.get_Count() == 0 && this.LazyItems.get_Count() == 0); //this.NotifyOfPropertyChange<TLObject>(() => this.With); }); }
private async Task RepeatUpload() { var maxRepeat = 3; var repeatCount = 0; do { for (var i = 0; i < Media.Count; i++) { var media = Media[i]; if (!(media.UploadState == UploadState.Saved || media.UploadState == UploadState.UploadError)) { continue; } var operationResult = await UploadMedia(media); if (!IsInitialized) { return; } if (!operationResult.IsSuccess) { Activity.ShowAlert(operationResult.Exception, ToastLength.Short); } else { media.UploadMediaUuid = operationResult.Result; //SaveGalleryTemp(); } } if (Media.All(m => m.UploadState == UploadState.UploadEnd)) { break; } repeatCount++; } while (repeatCount < maxRepeat); }