/// <summary>
            /// The send message.
            /// </summary>
            /// <param name="msg">
            /// The msg.
            /// </param>
            private void SendMessage(Message msg)
            {
                switch ((ClientMessages)msg.What)
                {
                case ClientMessages.DownloadProgress:
                    if (this.classLoader != null)
                    {
                        Bundle bun = msg.Data;
                        bun.SetClassLoader(this.classLoader);
                        string progress = msg.Data.GetString(ClientMessageParameters.Progress);
                        var    info     = new DownloadProgressInfo(progress);
                        this.clientType.OnDownloadProgress(info);
                    }

                    break;

                case ClientMessages.DownloadStateChanged:
                    var state = (DownloaderState)msg.Data.GetInt(ClientMessageParameters.NewState);
                    this.clientType.OnDownloadStateChanged(state);
                    break;

                case ClientMessages.ServiceConnected:
                    var m = (Messenger)msg.Data.GetParcelable(ClientMessageParameters.Messenger);
                    this.clientType.OnServiceConnected(m);
                    break;
                }
            }
コード例 #2
0
        /// <summary>
        /// The on update validation ui.
        /// </summary>
        /// <param name="handler">
        /// The handler.
        /// </param>
        private void OnUpdateValidationUi(ZipFileValidationHandler handler)
        {
            var info = new DownloadProgressInfo(
                handler.TotalBytes, handler.CurrentBytes, handler.TimeRemaining, handler.AverageSpeed);

            this.RunOnUiThread(() => this.OnDownloadProgress(info));
        }
コード例 #3
0
        /// <summary>
        /// Событие обновления процесса загрузки
        /// </summary>
        /// <param name="downloadInfo">Информация о процессе загрузки</param>
        /// <param name="mangaTable">Список манги, для таблицы</param>
        /// <param name="finalWork">Флаг завершения работы</param>
        /// <param name="toDown">Флаг необходимости прокрутки страницы вниз</param>
        /// <param name="selected">Id выбранной задачи</param>
        private void Mw_onUpdateDownload(DownloadProgressInfo downloadInfo,
                                         List <TableMangaInfo> mangaTable, bool finalWork, bool toDown, int selected)
        {
            //Выполняем действия в основном потоке
            this.BeginInvoke(new Action(() => {
                //Обновляем таблицу манги
                updateTable(mangaTable);
                //Обновляем значения контроллов
                updateElems(downloadInfo);

                //Если нужно опустить вниз
                if (toDown)
                {
                    //Опускаем
                    scrollToDown();
                }

                //Если работа была завершена
                if (finalWork)
                {
                    //Вызываем сообщение о завершении загрузки
                    pl.showMessage(0);
                }

                //Выделяем строку активной задачи
                scrollToActive(selected);
            }));
        }
コード例 #4
0
 /// <summary>
 /// The on download progress.
 /// </summary>
 /// <param name="progress">
 /// The progress.
 /// </param>
 public void OnDownloadProgress(DownloadProgressInfo progress)
 {
     using (var p = new Bundle(1))
     {
         p.PutString(ClientMessageParameters.Progress, progress.ToString());
         this.SendMessage(ClientMessages.DownloadProgress, p);
     }
 }
コード例 #5
0
        public DownloadProgressInfo GetDownloadProgressInfo(int id, string fileUrl)
        {
            try {
                DownloadProgressInfo progressInfo = new DownloadProgressInfo();

                bool downloadingOrPaused = DownloadHandle.isPaused.ContainsKey(id);

                var file = new Java.IO.File(fileUrl);

                bool exists = file.Exists();

                if (downloadingOrPaused)
                {
                    int paused = DownloadHandle.isPaused[id];
                    progressInfo.state = paused == 1 ? DownloadState.Paused : DownloadState.Downloading;
                }
                else
                {
                    progressInfo.state = exists ? DownloadState.Downloaded : DownloadState.NotDownloaded;
                }

                if (progressInfo.bytesDownloaded < progressInfo.totalBytes - 10 && progressInfo.state == DownloadState.Downloaded)
                {
                    progressInfo.state = DownloadState.NotDownloaded;
                }
                print("CONTAINS ::>>" + DownloadHandle.isStartProgress.ContainsKey(id));
                progressInfo.bytesDownloaded = (exists ? (file.Length()) : 0) + (DownloadHandle.isStartProgress.ContainsKey(id) ? 1 : 0);

                progressInfo.totalBytes = exists ? App.GetKey <long>("dlength", "id" + id, 0) : 0;
                print("STATE:::::==" + progressInfo.totalBytes + "|" + progressInfo.bytesDownloaded);

                if (!exists)
                {
                    return(progressInfo);
                }

                if (progressInfo.bytesDownloaded >= progressInfo.totalBytes - 10)
                {
                    progressInfo.state = DownloadState.Downloaded;
                }
                else if (progressInfo.state == DownloadState.Downloaded)
                {
                    progressInfo.state = DownloadState.NotDownloaded;
                }

                if (progressInfo.bytesDownloaded < 0 || progressInfo.totalBytes < 0)
                {
                    progressInfo.state      = DownloadState.NotDownloaded;
                    progressInfo.totalBytes = 0;
                }

                return(progressInfo);
            }
            catch (Exception _ex) {
                error(_ex);
                return(null);
            }
        }
コード例 #6
0
 /// <summary>
 /// Sets the state of the various controls based on the progressinfo
 /// object sent from the downloader service.
 /// </summary>
 /// <param name="progress">
 /// The progressinfo object sent from the downloader service.
 /// </param>
 public void OnDownloadProgress(DownloadProgressInfo progress)
 {
     _averageSpeedTextView.Text     = string.Format("{0} Kb/s", Helpers.GetSpeedString(progress.CurrentSpeed));
     _timeRemainingTextView.Text    = string.Format(Resources.GetString(Resource.String.exp_down_time_remaining), Helpers.GetTimeRemaining(progress.TimeRemaining));
     _progressBar.Max               = (int)(progress.OverallTotal >> 8);
     _progressBar.Progress          = (int)(progress.OverallProgress >> 8);
     _progressPercentTextView.Text  = string.Format("{0}%", progress.OverallProgress * 100 / progress.OverallTotal);
     _progressFractionTextView.Text = Helpers.GetDownloadProgressString(progress.OverallProgress, progress.OverallTotal);
 }
コード例 #7
0
 /// <summary>
 /// Sets the state of the various controls based on the progressinfo
 /// object sent from the downloader service.
 /// </summary>
 /// <param name="progress">
 /// The progressinfo object sent from the downloader service.
 /// </param>
 public void OnDownloadProgress(DownloadProgressInfo progress)
 {
     this.averageSpeedTextView.Text  = string.Format("{0} Kb/s", Helpers.GetSpeedString(progress.CurrentSpeed));
     this.timeRemainingTextView.Text = string.Format(
         "Time remaining: {0}", Helpers.GetTimeRemaining(progress.TimeRemaining));
     this.progressBar.Max              = (int)(progress.OverallTotal >> 8);
     this.progressBar.Progress         = (int)(progress.OverallProgress >> 8);
     this.progressPercentTextView.Text = string.Format(
         "{0}%", progress.OverallProgress * 100 / progress.OverallTotal);
     this.progressFractionTextView.Text = Helpers.GetDownloadProgressString(
         progress.OverallProgress, progress.OverallTotal);
 }
 /// <summary>
 /// Sets the state of the various controls based on the progressinfo 
 /// object sent from the downloader service.
 /// </summary>
 /// <param name="progress">
 /// The progressinfo object sent from the downloader service.
 /// </param>
 public void OnDownloadProgress(DownloadProgressInfo progress)
 {
     this.averageSpeedTextView.Text = string.Format("{0} Kb/s", Helpers.GetSpeedString(progress.CurrentSpeed));
     this.timeRemainingTextView.Text = string.Format(
         "Time remaining: {0}", Helpers.GetTimeRemaining(progress.TimeRemaining));
     this.progressBar.Max = (int)(progress.OverallTotal >> 8);
     this.progressBar.Progress = (int)(progress.OverallProgress >> 8);
     this.progressPercentTextView.Text = string.Format(
         "{0}%", progress.OverallProgress * 100 / progress.OverallTotal);
     this.progressFractionTextView.Text = Helpers.GetDownloadProgressString(
         progress.OverallProgress, progress.OverallTotal);
 }
コード例 #9
0
 /// <summary>
 /// Обновляем значеняи контроллов
 /// </summary>
 /// <param name="info">ИНформация о процессе загрузки</param>
 private void updateElems(DownloadProgressInfo info)
 {
     //Обновляем строки статусов
     mainProgressLabel.Text      = info.getFullStatus();
     secondaryProgressLabel.Text = info.getCurrentStatus();
     loadTimeLabel.Text          = info.getLoadTime();
     stepInfoLabel.Text          = info.getStep();
     //Обновляем прогрессбары
     mainProgress.max        = info.maxFull;
     mainProgress.value      = info.currentFull;
     secondaryProgress.max   = info.maxCurr;
     secondaryProgress.value = info.currentCurr;
     //Проставляем активность кнопкам
     setButtonsEnableStatus(!info.finalFlag);
 }
コード例 #10
0
    public DownloadProgressInfo GetDownloadProgressInfo()
    {
        if (m_DownloadProgressInfo == null)
        {
            m_DownloadProgressInfo = new DownloadProgressInfo();
        }

        if (m_DownloadClient != null)
        {
            var info = m_DownloadClient.Call <AndroidJavaObject>("GetProgressInfo");
            m_DownloadProgressInfo.CurrentSpeed    = info.Get <float>("mCurrentSpeed");
            m_DownloadProgressInfo.OverallProgress = info.Get <long>("mOverallProgress");
            m_DownloadProgressInfo.OverallTotal    = info.Get <long>("mOverallTotal");
            m_DownloadProgressInfo.TimeRemaining   = info.Get <long>("mTimeRemaining");
        }
        return(m_DownloadProgressInfo);
    }
コード例 #11
0
 public void UpdateDownloadProgress(DownloadProgressInfo info, long? bytesPerSec)
 {
     ListViewItem item;
     if (!_items.TryGetValue(info.DownloadID, out item)) {
         item = new ListViewItem(String.Empty);
         for (int i = 1; i < lvDownloads.Columns.Count; i++) {
             item.SubItems.Add(String.Empty);
         }
         SetSubItemText(item, ColumnIndex.URL, info.URL);
         SetSubItemText(item, ColumnIndex.Size, GetKilobytesString(info.TotalSize, "KB"));
         SetSubItemText(item, ColumnIndex.Try, info.TryNumber.ToString());
         lvDownloads.Items.Add(item);
         _items[info.DownloadID] = item;
     }
     if (info.TotalSize != null) {
         SetSubItemText(item, ColumnIndex.Percent, (info.DownloadedSize * 100 / info.TotalSize.Value).ToString() + "%");
     }
     else {
         SetSubItemText(item, ColumnIndex.Size, GetKilobytesString(info.DownloadedSize, "KB"));
     }
     SetSubItemText(item, ColumnIndex.Speed, GetKilobytesString(bytesPerSec, "KB/s"));
 }
 /// <summary>
 /// The on download progress.
 /// </summary>
 /// <param name="progress">
 /// The progress.
 /// </param>
 public void OnDownloadProgress(DownloadProgressInfo progress)
 {
     using (var p = new Bundle(1))
     {
         p.PutString(ClientMessageParameters.Progress, progress.ToString());
         this.SendMessage(ClientMessages.DownloadProgress, p);
     }
 }
コード例 #13
0
 public void OnDownloadProgress(DownloadProgressInfo progress)
 {
     this.progressBar.Max               = (int)(progress.OverallTotal >> 8);
     this.progressBar.Progress          = (int)(progress.OverallProgress >> 8);
     this.progressFractionTextView.Text = Helpers.GetDownloadProgressString(progress.OverallProgress, progress.OverallTotal);
 }
        /// <summary>
        /// The on update validation ui.
        /// </summary>
        /// <param name="handler">
        /// The handler.
        /// </param>
        private void OnUpdateValidationUi(ZipFileValidationHandler handler)
        {
            var info = new DownloadProgressInfo(
                handler.TotalBytes, handler.CurrentBytes, handler.TimeRemaining, handler.AverageSpeed);

            this.RunOnUiThread(() => this.OnDownloadProgress(info));
        }
コード例 #15
0
        /// <summary>
        /// Вызываем обновление списков загрузки
        /// </summary>
        /// <param name="finalWork">Флаг завершения работы</param>
        /// <param name="onDown">Флаг необходимости прокрутки вниз</param>
        /// <param name="selected">Id задачи, над которой идёт работа</param>
        public void updateDownloadExec(int selected, bool finalWork = false, bool onDown = false)
        {
            //Инициализируем переменные
            DownloadProgressInfo  info       = new DownloadProgressInfo();
            List <TableMangaInfo> mangaTable = new List <TableMangaInfo>();

            int currentCurr, currentFull, maxCurr, countPages;

            //Инициализируем рассчитываемые значения нолями
            currentCurr = maxCurr = currentFull = countPages = 0;

            //Проходимся по списку загрузок
            foreach (var mn in dList.downloadList)
            {
                //Добавляем мангу в список загрузок
                mangaTable.Add(new TableMangaInfo()
                {
                    count         = mn.countPages,
                    downloadCount = mn.downloadPages(),
                    name          = mn.name,
                    status        = mn.status,
                    url           = mn.url
                });

                //Если данная манга сейчас загружается
                if (mn.status == MangaStatus.status.Загрузка_страниц)
                {
                    //Указываем количество страниц текущей загружаемой манги
                    maxCurr = mn.countPages;
                    //Указываем количество загруженных страниц текущей манги
                    currentCurr = mn.downloadPages();
                    //Добавляем количество страниц, которые нужно загрузить в расчете
                    countPages += (maxCurr - currentCurr);
                }
                //Если для данной манги загружена инфа
                else if (mn.status == MangaStatus.status.Информация_загружена)
                {
                    //Добавляем все страницы под загрузку
                    countPages += mn.countPages;
                }
            }

            //Если мы щас грузим страницы
            if (workStep == DownloadStep.Steps.Загрузка_страниц_манги)
            {
                //Количество загруженных манг равно количеству загруженных старниц
                currentFull = dList.getCountByStatus(MangaStatus.status.Страницы_загружены);

                //Передаём информацию в класс
                info = new DownloadProgressInfo()
                {
                    finalFlag           = (workStep != DownloadStep.Steps.Сбор_ссылок),
                    approximateLoadTime = averageLoadTime,
                    maxFull             = dList.getCount(),
                    countPages          = countPages,
                    currentCurr         = currentCurr,
                    currentFull         = currentFull,
                    maxCurr             = maxCurr,
                    step = workStep
                };
            }
            //Если мы щас грузим инфу
            else if (workStep == DownloadStep.Steps.Загрузка_информации_о_манге)
            {
                //Количество загруженных манг равно количеству загруженных старниц
                currentFull = dList.getCountByStatus(MangaStatus.status.Информация_загружена);

                //Передаём информацию в класс
                info = new DownloadProgressInfo()
                {
                    finalFlag           = false,
                    approximateLoadTime = averageLoadInfoTime,
                    maxFull             = dList.getCount(),
                    countPages          = dList.getCount(),
                    currentCurr         = 0,
                    currentFull         = currentFull,
                    maxCurr             = 0,
                    step = workStep
                };
            }
            //Если мы щас чекаем статусы
            else if (workStep == DownloadStep.Steps.Проверка_статусов_загрузки)
            {
                //Передаём информацию в класс
                info = new DownloadProgressInfo()
                {
                    finalFlag           = false,
                    approximateLoadTime = 1,
                    maxFull             = dList.getCount(),
                    countPages          = dList.getCount(),
                    currentCurr         = 0,
                    currentFull         = dList.getCount(),
                    maxCurr             = 0,
                    step = workStep
                };
            }

            //Вызываем событие обновления
            onUpdateDownload?.Invoke(info, mangaTable, finalWork, onDown, selected);
        }
コード例 #16
0
 private void ThreadWatcher_DownloadStart(ThreadWatcher watcher, DownloadStartEventArgs args)
 {
     DownloadProgressInfo info = new DownloadProgressInfo();
     info.DownloadID = args.DownloadID;
     info.URL = args.URL;
     info.TryNumber = args.TryNumber;
     info.StartTicks = TickCount.Now;
     info.TotalSize = args.TotalSize;
     lock (_downloadProgresses) {
         _downloadProgresses[args.DownloadID] = info;
         ConcurrentDownloads += 1;
     }
 }
            /// <summary>
            /// The send message.
            /// </summary>
            /// <param name="msg">
            /// The msg.
            /// </param>
            private void SendMessage(Message msg)
            {
                switch ((ClientMessages)msg.What)
                {
                    case ClientMessages.DownloadProgress:
						string progress = msg.Data.GetString(ClientMessageParameters.Progress);
                        var info = new DownloadProgressInfo(progress);
                        this.clientType.OnDownloadProgress(info);
                        break;
                    case ClientMessages.DownloadStateChanged:
                        var state = (DownloaderState)msg.Data.GetInt(ClientMessageParameters.NewState);
                        this.clientType.OnDownloadStateChanged(state);
                        break;
                    case ClientMessages.ServiceConnected:
                        var m = (Messenger)msg.Data.GetParcelable(ClientMessageParameters.Messenger);
                        this.clientType.OnServiceConnected(m);
                        break;
                }
            }
コード例 #18
0
 public void OnDownloadProgress(DownloadProgressInfo progress)
 {
     _progressDialog.SetMessage(GetString(Resource.String.apkDown_downloading) + " " + Helpers.GetDownloadProgressString(progress.OverallProgress, progress.OverallTotal));
     _progressDialog.Max      = (int)(progress.OverallTotal >> 8);
     _progressDialog.Progress = (int)(progress.OverallProgress >> 8);
 }
コード例 #19
0
 public void OnDownloadProgress(DownloadProgressInfo progress)
 {
     //("MainActivity.OnDownloadProgress OverallProgress:" + progress.OverallProgress + ", OverallTotal:" + progress.OverallTotal + ", TimeRemaining:" + progress.TimeRemaining + ", CurrentSpeed:" + progress.CurrentSpeed);
 }