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 (); }
public DownloadManagerEvent(DownloadManager downloadManager, Download download, int errorCode) { this.download = download; this.downloadManager = downloadManager; this.errorCode = errorCode; }
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"); } }
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; } }
public DownloadManagerEvent(DownloadManager downloadManager, Download download) { this.download = download; this.downloadManager = downloadManager; }
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); } }
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 }
public void downloadDidPause(Download download) { if (!this._cancelAllInProgress) { this.tryDownloading(); } }
public void downloadDidReceiveData(Download download) { this.dispatchEvent (DOWNLOAD_DID_RECEIVE_DATA,download); }
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 } }
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 }
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 } }
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; }
public void downloadDidReceiveData(Download download) { this.dispatchEvent(DOWNLOAD_DID_RECEIVE_DATA, download); }