@@ -93,7 +93,7 @@ class SVGAParser(private val context: Context) {
93
93
}
94
94
}
95
95
96
- fun decodeFromAssets (name : String , callback : ParseCompletion ) {
96
+ fun decodeFromAssets (name : String , callback : ParseCompletion ? ) {
97
97
try {
98
98
context.assets.open(name)?.let {
99
99
this .decodeFromInputStream(it, buildCacheKey(" file:///assets/$name " ), callback, true )
@@ -104,7 +104,7 @@ class SVGAParser(private val context: Context) {
104
104
}
105
105
}
106
106
107
- fun decodeFromURL (url : URL , callback : ParseCompletion ): (() -> Unit )? {
107
+ fun decodeFromURL (url : URL , callback : ParseCompletion ? ): (() -> Unit )? {
108
108
if (this .isCached(buildCacheKey(url))) {
109
109
threadPoolExecutor.execute {
110
110
this .decodeFromCacheKey(buildCacheKey(url), callback)
@@ -120,7 +120,7 @@ class SVGAParser(private val context: Context) {
120
120
}
121
121
}
122
122
123
- fun decodeFromInputStream (inputStream : InputStream , cacheKey : String , callback : ParseCompletion , closeInputStream : Boolean = false) {
123
+ fun decodeFromInputStream (inputStream : InputStream , cacheKey : String , callback : ParseCompletion ? , closeInputStream : Boolean = false) {
124
124
threadPoolExecutor.execute {
125
125
try {
126
126
readAsBytes(inputStream)?.let { bytes ->
@@ -155,44 +155,44 @@ class SVGAParser(private val context: Context) {
155
155
* @deprecated from 2.4.0
156
156
*/
157
157
@Deprecated(" This method has been deprecated from 2.4.0." , ReplaceWith (" this.decodeFromAssets(assetsName, callback)" ))
158
- fun parse (assetsName : String , callback : ParseCompletion ) {
158
+ fun parse (assetsName : String , callback : ParseCompletion ? ) {
159
159
this .decodeFromAssets(assetsName, callback)
160
160
}
161
161
162
162
/* *
163
163
* @deprecated from 2.4.0
164
164
*/
165
165
@Deprecated(" This method has been deprecated from 2.4.0." , ReplaceWith (" this.decodeFromURL(url, callback)" ))
166
- fun parse (url : URL , callback : ParseCompletion ) {
166
+ fun parse (url : URL , callback : ParseCompletion ? ) {
167
167
this .decodeFromURL(url, callback)
168
168
}
169
169
170
170
/* *
171
171
* @deprecated from 2.4.0
172
172
*/
173
173
@Deprecated(" This method has been deprecated from 2.4.0." , ReplaceWith (" this.decodeFromInputStream(inputStream, cacheKey, callback, closeInputStream)" ))
174
- fun parse (inputStream : InputStream , cacheKey : String , callback : ParseCompletion , closeInputStream : Boolean = false) {
174
+ fun parse (inputStream : InputStream , cacheKey : String , callback : ParseCompletion ? , closeInputStream : Boolean = false) {
175
175
this .decodeFromInputStream(inputStream, cacheKey, callback, closeInputStream)
176
176
}
177
177
178
- private fun invokeCompleteCallback (videoItem : SVGAVideoEntity , callback : ParseCompletion ) {
178
+ private fun invokeCompleteCallback (videoItem : SVGAVideoEntity , callback : ParseCompletion ? ) {
179
179
Handler (context.mainLooper).post {
180
- callback.onComplete(videoItem)
180
+ callback? .onComplete(videoItem)
181
181
}
182
182
}
183
183
184
- private fun invokeErrorCallback (e : java.lang.Exception , callback : ParseCompletion ) {
184
+ private fun invokeErrorCallback (e : java.lang.Exception , callback : ParseCompletion ? ) {
185
185
e.printStackTrace()
186
186
Handler (context.mainLooper).post {
187
- callback.onError()
187
+ callback? .onError()
188
188
}
189
189
}
190
190
191
191
private fun isCached (cacheKey : String ): Boolean {
192
192
return buildCacheDir(cacheKey).exists()
193
193
}
194
194
195
- private fun decodeFromCacheKey (cacheKey : String , callback : ParseCompletion ) {
195
+ private fun decodeFromCacheKey (cacheKey : String , callback : ParseCompletion ? ) {
196
196
try {
197
197
val cacheDir = File (context.cacheDir.absolutePath + " /" + cacheKey + " /" )
198
198
File (cacheDir, " movie.binary" ).takeIf { it.isFile }?.let { binaryFile ->
0 commit comments