Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
liply
committed
Oct 6, 2017
1 parent
1b0150a
commit ea89397
Showing
6 changed files
with
107 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
function ProgressWatcher(){ | ||
throw new Error('This is a static class'); | ||
} | ||
|
||
ProgressWatcher.initialize = function(){ | ||
this.clearProgress(); | ||
ImageManager.setCreationHook(this._bitmapListener.bind(this)); | ||
AudioManager.setCreationHook(this._audioListener.bind(this)); | ||
}; | ||
|
||
ProgressWatcher._bitmapListener = function(bitmap){ | ||
this._countLoading++; | ||
bitmap.addLoadListener(function(){ | ||
this._countLoaded++; | ||
this._progressListener(this._countLoaded, this._countLoading); | ||
}.bind(this)); | ||
}; | ||
|
||
ProgressWatcher._audioListener = function(audio){ | ||
this._countLoading++; | ||
audio.addLoadListener(function(){ | ||
this._countLoaded++; | ||
this._progressListener(this._countLoaded, this._countLoading); | ||
}.bind(this)); | ||
}; | ||
|
||
ProgressWatcher.setProgressListener = function(progressListener){ | ||
this._progressListener = progressListener; | ||
}; | ||
|
||
ProgressWatcher.clearProgress = function(){ | ||
this._countLoading = 0; | ||
this._countLoaded = 0; | ||
}; | ||
|
||
ProgressWatcher.truncateProgress = function(){ | ||
if(this._countLoaded){ | ||
this._countLoading -= this._countLoaded; | ||
this._countLoaded = 0; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters