public void onTransferTemporaryError(MegaSDK api, MTransfer transfer, MError e) { Deployment.Current.Dispatcher.BeginInvoke(() => { if (DebugService.DebugSettings.IsDebugMode || Debugger.IsAttached) { if (ProgressService.GetProgressBarBackgroundColor() != (Color)Application.Current.Resources["MegaRedColor"]) { ProgressService.ChangeProgressBarBackgroundColor((Color)Application.Current.Resources["MegaRedColor"]); } } }); switch (e.getErrorCode()) { case MErrorType.API_EGOINGOVERQUOTA: // Not enough quota case MErrorType.API_EOVERQUOTA: // Overquota error ProcessOverquotaError(api, e); break; } // Extra checking to avoid NullReferenceException if (transfer == null) { return; } // Search the corresponding transfer in the transfers list var megaTransfer = TransfersService.SearchTransfer(TransfersService.MegaTransfers.SelectAll(), transfer); if (megaTransfer == null) { return; } var isBusy = api.areTransfersPaused((int)transfer.getType()) ? false : true; var transferState = api.areTransfersPaused((int)transfer.getType()) ? MTransferState.STATE_QUEUED : transfer.getState(); var transferPriority = transfer.getPriority(); Deployment.Current.Dispatcher.BeginInvoke(() => { // Only update the values if they have changed to improve the UI performance if (megaTransfer.Transfer != transfer) { megaTransfer.Transfer = transfer; } if (megaTransfer.IsBusy != isBusy) { megaTransfer.IsBusy = isBusy; } if (megaTransfer.TransferState != transferState) { megaTransfer.TransferState = transferState; } if (megaTransfer.TransferPriority != transferPriority) { megaTransfer.TransferPriority = transferPriority; } }); }
public void onTransferUpdate(MegaSDK api, MTransfer transfer) { // Extra checking to avoid NullReferenceException if (transfer == null) { return; } // Search the corresponding transfer in the transfers list var megaTransfer = TransfersService.SearchTransfer(TransfersService.MegaTransfers.SelectAll(), transfer); if (megaTransfer == null) { return; } var isBusy = api.areTransfersPaused((int)transfer.getType()) ? false : true; var transferState = api.areTransfersPaused((int)transfer.getType()) ? MTransferState.STATE_QUEUED : transfer.getState(); var totalBytes = transfer.getTotalBytes(); var transferedBytes = transfer.getTransferredBytes(); var transferSpeed = transfer.getSpeed().ToStringAndSuffixPerSecond(); var transferMeanSpeed = transfer.getMeanSpeed(); var transferPriority = transfer.getPriority(); Deployment.Current.Dispatcher.BeginInvoke(() => { if (ProgressService.GetProgressBarBackgroundColor() != (Color)Application.Current.Resources["PhoneChromeColor"]) { ProgressService.ChangeProgressBarBackgroundColor((Color)Application.Current.Resources["PhoneChromeColor"]); } // Only update the values if they have changed to improve the UI performance if (megaTransfer.Transfer != transfer) { megaTransfer.Transfer = transfer; } if (megaTransfer.IsBusy != isBusy) { megaTransfer.IsBusy = isBusy; } if (megaTransfer.TransferState != transferState) { megaTransfer.TransferState = transferState; } if (megaTransfer.TotalBytes != totalBytes) { megaTransfer.TotalBytes = totalBytes; } if (megaTransfer.TransferedBytes != transferedBytes) { megaTransfer.TransferedBytes = transferedBytes; } if (megaTransfer.TransferSpeed != transferSpeed) { megaTransfer.TransferSpeed = transferSpeed; } if (megaTransfer.TransferMeanSpeed != transferMeanSpeed) { megaTransfer.TransferMeanSpeed = transferMeanSpeed; } if (megaTransfer.TransferPriority != transferPriority) { megaTransfer.TransferPriority = transferPriority; } }); }