Ejemplo n.º 1
0
        public void SetPause(bool isPause)
        {
            if (mIsPause == isPause)
            {
                return;
            }

            mIsPause = isPause;

            if (mIsPause && null != mCurTask)
            {
                mDownloadTask.Add(mCurTask);
                mCurTask = null;

                lock (mLockObject)
                {
                    mIsDownload = false;
                }
            }

            if (null != mDownloader)
            {
                mDownloader.SetPause(isPause);
            }
        }
Ejemplo n.º 2
0
        public void PushDownloadFile(string url, string saveFile, AssetBundleConfig config, HttpDownloadFinish finishCallback = null)
        {
            int index = -1;

            for (int i = 0; i < mDownloadTask.Count; i++)
            {
                if (mDownloadTask[i].url.Equals(url))
                {
                    index = i;

                    break;
                }
            }
            if (-1 != index)
            {
                if (mDownloadTask.Count > 1)
                {
                    HttpDownloadTask tmp = mDownloadTask[index];
                    mDownloadTask.RemoveAt(index);
                    mDownloadTask.Add(tmp);
                }
            }
            else if (null == mCurTask || !mCurTask.url.Equals(url))
            {
                HttpDownloadTask task = new HttpDownloadTask(url, saveFile, config, finishCallback);
                mDownloadTask.Add(task);
            }
        }
Ejemplo n.º 3
0
        private void DownloadCallback(bool success, HttpDownloadTask task)
        {
            if (null != task)
            {
                task.success = success;

                mIsDownload = false;
            }
        }
Ejemplo n.º 4
0
        //private ABProcessor mABProcessorNum0 = new ABProcessor(0);
        //private ABProcessor mABProcessorNum1 = new ABProcessor(1);

        void Update()
        {
            lock (mLockObject)
            {
                if (!mIsDownload && null != mCurTask)
                {
                    ABFileMgr.Instance.SetABFileState(mCurTask.config.RelativePath, ABFileState.DOWNLOADED);
                    if (null != mCurTask.callback)
                    {
                        mCurTask.callback(mCurTask.success);
                    }
                    mCurTask = null;
                }

                Download();
            }
        }
Ejemplo n.º 5
0
        private void Download()
        {
            if (!mIsPause && mDownloadTask.Count > 0 && !mIsDownload)
            {
                if (null == mDownloader || (!mDownloader.IsProcess() && !mDownloader.HasTask()))
                {
                    mCurTask = mDownloadTask[mDownloadTask.Count - 1];
                    HttpDownloadCallback callback = (success) =>
                    {
                        lock (mLockObject)
                        {
                            DownloadCallback(success, mCurTask);
                        }
                    };
                    mDownloader = HttpDownload.StartDownloadFile(mCurTask.url, mCurTask.saveFile, mCurTask.config, callback);
                    mDownloadTask.RemoveAt(mDownloadTask.Count - 1);
                    mIsDownload = true;

                    LogMgr.UnityLog("http download:" + mCurTask.url);
                }
            }
        }