private void OnDownloadStatusChange(Feed downloadList, Feed entry, DownloadState downloadState, double percentage)
        {
            if (Entries.Count <= 0 || _onStatusChanged == null) return;
            if (downloadState == DownloadState.Deleted) {
                _settings.SaveDownloadLists(this);
                UpdateStatus(downloadList, entry, DownloadState.AllFinished, 100.0);
                return;
            }
            var finishedCount = 0;
            var average = 0.0;
            foreach (var en in Entries) {
                if (en.DownloadState == DownloadState.AllFinished)
                    finishedCount++;
                average += en.Percentage;
            }
            average = average/Entries.Count;

            if (downloadState == DownloadState.DownloadProgressChanged)
                UpdateStatus(downloadList, entry, DownloadState.DownloadProgressChanged, average);
            else if (finishedCount == Entries.Count) 
                UpdateStatus(downloadList, entry, DownloadState.AllFinished, 100.0);
            else if (Entries.Count == 1 && downloadState == DownloadState.AllStart)
                UpdateStatus(downloadList, entry, DownloadState.AllStart, 0.0);
            else if(_onStatusChanged != null && 
                    !(downloadState == DownloadState.AllFinished || 
                        downloadState == DownloadState.AllStart || 
                        downloadState == DownloadState.DownloadProgressChanged
                    )) 
                _onStatusChanged(downloadList, entry, downloadState, percentage);
            _settings.SaveDownloadLists(this);
        }
        private void OnDownloadStatusChanged(Feed feed, DownloadState downloadState, double percentage)
        {
            var finishedCount = 0;
            var downloadCount = 0;
            var average = 0.0;
            if (downloadState == DownloadState.Deleted) {
                var entry = feed as YoutubeEntry;
                if (entry != null) {
                    entry.OnEntryDownloadStatusChange = null;
                    Entries.Remove(entry);
                }
                return;
            }
            foreach (var en in Entries) {
                if (en.DownloadState == DownloadState.Ready || en.DownloadState == DownloadState.Error)
                    finishedCount++;
                if (
                    !(en.DownloadState == DownloadState.Ready || en.DownloadState == DownloadState.Error ||
                      en.DownloadState == DownloadState.Initialized))
                    downloadCount++;
                average += en.Percentage;
            }
            average = average/Entries.Count;

            if (OnListDownloadStatusChange != null) {
                DownloadState = downloadState;
                if (downloadState == DownloadState.DownloadProgressChanged) {
                    Percentage = average;
                }
                if (downloadCount == 0 && finishedCount == Entries.Count)
                    DownloadState = DownloadState.AllFinished;
                if (Entries.Count == 1 && downloadState == DownloadState.TitleChanged) {
                    Title = Entries[0].Title;
                }
                OnListDownloadStatusChange(this, feed, DownloadState, Percentage);
            }
            if (downloadCount != _poolSize)
                DownloadFirst();
        }
 private void UpdateStatus(Feed list, Feed feed, DownloadState downloadState, double percentage)
 {
     switch (downloadState) {
         case DownloadState.AllStart:
             Controls.ProgressBar.Progress = 0;
             Controls.DownloadFrame.Visibility = ViewStates.Visible;
             break;
         case DownloadState.AllFinished:
             Log.Debug("STATUS", "DONE!");
             Controls.ProgressBar.Progress = 0;
             Controls.DownloadFrame.Visibility = ViewStates.Gone;
             list.Entries.Clear();
             return;
         case DownloadState.DownloadProgressChanged:
             Controls.ProgressBar.Progress = (int)percentage;
             break;
         case DownloadState.TitleChanged:
             //MixpanelTrack("Download", new { feed.Title, _settings.Guid });
             break;
     }
     if (feed != null) Controls.Title.Text = feed.ToString();
 }
 private void OnDownloadStatusChange(Feed list, Feed feed, DownloadState downloadState, double percentage)
 {
     try { Controls.Activity.RunOnUiThread(() => UpdateStatus(list, feed, downloadState, percentage)); } catch { }
 }
 private void UpdateStatus(Feed downloadList, Feed entry, DownloadState state, double percentage)
 {
     DownloadState = state;
     Percentage = percentage;
     if (_onStatusChanged != null) _onStatusChanged(downloadList, entry, DownloadState, Percentage);
 }
 private void OnAudioConversionStatusChange(Feed feed, DownloadState downloadState, double percentage)
 {
     UpdateStatus(downloadState, percentage);
 }