Esempio n. 1
0
        private void updateDownloadPreferences(Download download)
        {
            string resolvedDownloadUrlsSO = PlayerPrefs.GetString ("resolvedDownloadUrls");
            ArrayList resolvedDownloadUrls = JsonMapper.ToObject<ArrayList> (resolvedDownloadUrlsSO);

            int removeIndex = -1;
            foreach (IDictionary storedDownload in resolvedDownloadUrls) {

                if (download.fileId.Equals(storedDownload["fileId"] as string)) {
                    removeIndex = resolvedDownloadUrls.IndexOf(storedDownload);
                }

            }

            if (removeIndex != -1) {
                resolvedDownloadUrls.RemoveAt(removeIndex);
            }

            PlayerPrefs.SetString ("resolvedDownloadUrls", JsonMapper.ToJson (resolvedDownloadUrls));
            PlayerPrefs.Save ();
        }
Esempio n. 2
0
 public DownloadManagerEvent(DownloadManager downloadManager, Download download, int errorCode)
 {
     this.download = download;
     this.downloadManager = downloadManager;
     this.errorCode = errorCode;
 }
Esempio n. 3
0
        private void dispatchDownloadEvent(string type, Download download)
        {
            if (downloadDelegate != null) {
                switch (type) {

                    case DOWNLOAD_DID_FINISH_LOADING:
                        this.downloadDelegate.downloadDidFinishLoading(download);
                        break;
                    case DOWNLOAD_DID_FAIL:
                        this.downloadDelegate.downloadDidFail (download);
                        break;
                    case DOWNLOAD_DID_FAIL_CONNECTIVITY:
                        this.downloadDelegate.downloadDidFailConnectivity (download);
                        break;
                    case DOWNLOAD_DID_FAIL_NO_AVAILABLE_SPACE:
                        this.downloadDelegate.downloadDidFailNoAvailableSpace (download);
                        break;
                    case DOWNLOAD_DID_RECEIVE_DATA:
                        this.downloadDelegate.downloadDidReceiveData(download);
                        break;
                    case DOWNLOAD_DID_START:
                        this.downloadDelegate.downloadDidStart(download);
                        break;
                    case DOWNLOAD_DID_PAUSE:
                        this.downloadDelegate.downloadDidPause(download);
                        break;

                }
            }else {
                Debug.LogWarning("No downloadDelegae defined");
            }
        }
Esempio n. 4
0
        private void dispatchEvent(string type, Download download = null)
        {
            DownloadManagerEvent e = new DownloadManagerEvent(this,download);
            switch (type) {

                case DOWNLOAD_DID_FINISH_LOADING:
                        if (DownloadDidFinishLoading != null) DownloadDidFinishLoading(this,e);
                        break;
                case DOWNLOAD_DID_FAIL:
                        if (DownloadDidFail != null) DownloadDidFail(this,e);
                        break;
                case DOWNLOAD_DID_RECEIVE_DATA:
                        if (DownloadDidReceiveData != null) DownloadDidReceiveData(this,e);
                        break;
                case DOWNLOAD_DID_START:
                        if (DownloadDidStart != null) DownloadDidStart(this,e);
                        break;
                case DOWNLOADMANAGER_DID_FINISH_LOADING_ALL:
                        if (DownloadDidFinishLoadingAll != null) DownloadDidFinishLoadingAll(this,e);
                        break;
                case DOWNLOADMANAGER_DID_START_LOADING_ALL:
                        if (DownloadDidStartLoadingAllForManager != null) DownloadDidStartLoadingAllForManager(this,e);
                        break;

            }
        }
Esempio n. 5
0
 public DownloadManagerEvent(DownloadManager downloadManager, Download download)
 {
     this.download = download;
     this.downloadManager = downloadManager;
 }
Esempio n. 6
0
        public void downloadDidStart(Download download)
        {
            this.dispatchEvent (DOWNLOAD_DID_START, download);

            bool allRunning = true;

            foreach (Download _download in _downloads)
            {
                if (!_download.isDownloading() && !_downloadeds.Contains(_download)) {
                    allRunning = false;
                    break;
                }
            }

            if (allRunning) {
                this.dispatchEvent(DOWNLOADMANAGER_DID_START_LOADING_ALL,null);
            }
        }
Esempio n. 7
0
        public void RemoveDownload(Download download)
        {
            #if UNITY_STANDALONE
            if (_downloadeds == null) _downloadeds = new ArrayList();
            _downloadeds.Add(download);
            #else
            int removeIndex = -1;
            foreach (Download item in _downloads)
            {
                if (item.FileId.Equals(download.FileId)) removeIndex = _downloads.IndexOf(item);

            }

            if (removeIndex != -1) _downloads.RemoveAt (removeIndex);
            #endif
        }
Esempio n. 8
0
 public void downloadDidPause(Download download)
 {
     if (!this._cancelAllInProgress) {
         this.tryDownloading();
     }
 }
Esempio n. 9
0
 public void downloadDidReceiveData(Download download)
 {
     this.dispatchEvent (DOWNLOAD_DID_RECEIVE_DATA,download);
 }
Esempio n. 10
0
        public void downloadDidFailNoAvailableSpace(Download download)
        {
            this.RemoveDownload(download);
            this.RemoveResolveDownloadUrl(JsonMapper.ToJson(download));

            DownloadManagerEvent dEvent = new DownloadManagerEvent(this,download,DownloadManagerEvent.ERROR_DOWNLOAD_DID_FAIL_NO_SPACE);
            if (DownloadDidFail != null) DownloadDidFail(this, dEvent);

            if (!this._cancelAllInProgress) {
                #if UNITY_STANDALONE
                #else
                this.tryDownloading ();
                #endif
            }
        }
Esempio n. 11
0
        public void downloadDidFinishLoading(Download download)
        {
            this.RemoveDownload(download);
            this.RemoveResolveDownloadUrl(JsonMapper.ToJson(download));
            this.dispatchEvent(DOWNLOAD_DID_FINISH_LOADING,download);

            #if UNITY_STANDALONE
            #else
            this.tryDownloading ();
            #endif
        }
Esempio n. 12
0
        public void downloadDidFailConnectivity(Download download)
        {
            this.dispatchEvent (DOWNLOAD_DID_FAIL,download);

            DownloadManagerEvent dEvent = new DownloadManagerEvent(this,download,DownloadManagerEvent.ERROR_DOWNLOAD_DID_FAIL_CONNECTIVITY);
            if (DownloadDidFail != null) DownloadDidFail(this, dEvent);

            if (!this._cancelAllInProgress) {
                #if UNITY_STANDALONE
                #else
                this.tryDownloading ();
                #endif
            }
        }
Esempio n. 13
0
        public Download addDownloadWithFilename(string filename, string url, string fileId)
        {
            //Debug.Log("[Gamedonia DownloadManager] addDownloadWithFilename("+filename+","+url+","+fileId+"){ }");
            Download download = this.FindDownloadByFileId(fileId);
            if (download == null) {

                download = new Download();
                download.init(filename,url,fileId);
                download.DownloadDelegate = this;
                download.filesystemPath = this.filesystemPath;
                _downloads.Add(download);
            }

            //TODO Gestion de PAUSE
            //this.addEventListener(Event.ACTIVATE,onActivate);
            //this.addEventListener(Event.DEACTIVATE,onDeactivate);

            return download;
        }
Esempio n. 14
0
 public DownloadManagerEvent(DownloadManager downloadManager, Download download, int errorCode)
 {
     this.download        = download;
     this.downloadManager = downloadManager;
     this.errorCode       = errorCode;
 }
Esempio n. 15
0
 public DownloadManagerEvent(DownloadManager downloadManager, Download download)
 {
     this.download        = download;
     this.downloadManager = downloadManager;
 }
Esempio n. 16
0
 public void downloadDidReceiveData(Download download)
 {
     this.dispatchEvent(DOWNLOAD_DID_RECEIVE_DATA, download);
 }