diff --git a/library/src/main/java/com/panoramagl/downloaders/PLFileDownloaderListener.java b/library/src/main/java/com/panoramagl/downloaders/PLFileDownloaderListener.java deleted file mode 100755 index 8b873f6..0000000 --- a/library/src/main/java/com/panoramagl/downloaders/PLFileDownloaderListener.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * PanoramaGL library - * Version 0.2 beta - * Copyright (c) 2010 Javier Baez - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.panoramagl.downloaders; - -public interface PLFileDownloaderListener { - /** - * download methods - */ - - void didBeginDownload(String url, long startTime); - - void didProgressDownload(String url, int progress); - - void didStopDownload(String url); - - void didEndDownload(String url, byte[] data, long elapsedTime); - - /** - * error methods - */ - - void didErrorDownload(String url, String error, int responseCode, byte[] data); -} \ No newline at end of file diff --git a/library/src/main/java/com/panoramagl/downloaders/PLFileDownloaderListener.kt b/library/src/main/java/com/panoramagl/downloaders/PLFileDownloaderListener.kt new file mode 100755 index 0000000..1a0ca07 --- /dev/null +++ b/library/src/main/java/com/panoramagl/downloaders/PLFileDownloaderListener.kt @@ -0,0 +1,13 @@ +package com.panoramagl.downloaders + +interface PLFileDownloaderListener { + fun didBeginDownload(url: String?, startTime: Long) + + fun didProgressDownload(url: String?, progress: Int) + + fun didStopDownload(url: String?) + + fun didEndDownload(url: String?, data: ByteArray?, elapsedTime: Long) + + fun didErrorDownload(url: String?, error: String?, responseCode: Int, data: ByteArray?) +} \ No newline at end of file diff --git a/library/src/main/java/com/panoramagl/downloaders/PLIFileDownloaderManager.java b/library/src/main/java/com/panoramagl/downloaders/PLIFileDownloaderManager.java deleted file mode 100755 index e4020e1..0000000 --- a/library/src/main/java/com/panoramagl/downloaders/PLIFileDownloaderManager.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * PanoramaGL library - * Version 0.2 beta - * Copyright (c) 2010 Javier Baez - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.panoramagl.downloaders; - -public interface PLIFileDownloaderManager { - /** - * property methods - */ - - boolean isRunning(); - - /** - * file downloaders methods - */ - - void add(PLIFileDownloader fileDownloader); - - boolean remove(PLIFileDownloader fileDownloader); - - boolean removeAll(); - - /** - * control methods - */ - - void download(PLIFileDownloader fileDownloader); - - boolean start(); - - boolean stop(); -} \ No newline at end of file diff --git a/library/src/main/java/com/panoramagl/downloaders/PLIFileDownloaderManager.kt b/library/src/main/java/com/panoramagl/downloaders/PLIFileDownloaderManager.kt new file mode 100755 index 0000000..f417e59 --- /dev/null +++ b/library/src/main/java/com/panoramagl/downloaders/PLIFileDownloaderManager.kt @@ -0,0 +1,17 @@ +package com.panoramagl.downloaders + +interface PLIFileDownloaderManager { + val isRunning: Boolean + + fun add(fileDownloader: PLIFileDownloader?) + + fun remove(fileDownloader: PLIFileDownloader?): Boolean + + fun removeAll(): Boolean + + fun download(fileDownloader: PLIFileDownloader?) + + fun start(): Boolean + + fun stop(): Boolean +} diff --git a/library/src/main/java/com/panoramagl/downloaders/PLLocalFileDownloader.kt b/library/src/main/java/com/panoramagl/downloaders/PLLocalFileDownloader.kt index c3b80e0..9051562 100755 --- a/library/src/main/java/com/panoramagl/downloaders/PLLocalFileDownloader.kt +++ b/library/src/main/java/com/panoramagl/downloaders/PLLocalFileDownloader.kt @@ -46,7 +46,8 @@ class PLLocalFileDownloader(private var context: Context, url: String?, listener val file = File(url.substring(7)) if (file.canRead()) `is` = FileInputStream(file) } - } else throw PLRequestInvalidatedException(url) + } else + throw PLRequestInvalidatedException(url) if (this.isRunning) { result = ByteArray(`is`!!.available()) `is`.read(result) @@ -54,7 +55,8 @@ class PLLocalFileDownloader(private var context: Context, url: String?, listener listener!!.didProgressDownload(url, 100) listener.didEndDownload(url, result, System.currentTimeMillis() - startTime) } - } else throw PLRequestInvalidatedException(url) + } else + throw PLRequestInvalidatedException(url) } catch (e: Throwable) { if (this.isRunning) { Timber.e(e) diff --git a/library/src/main/java/com/panoramagl/downloaders/PLRequestInvalidatedException.java b/library/src/main/java/com/panoramagl/downloaders/PLRequestInvalidatedException.java deleted file mode 100755 index 663377a..0000000 --- a/library/src/main/java/com/panoramagl/downloaders/PLRequestInvalidatedException.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * PanoramaGL library - * Version 0.2 beta - * Copyright (c) 2010 Javier Baez - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.panoramagl.downloaders; - -@SuppressWarnings("serial") -public class PLRequestInvalidatedException extends RuntimeException { - /** - * init methods - */ - - public PLRequestInvalidatedException(String url) { - super(String.format("Request to %s was invalidated", url)); - } -} \ No newline at end of file diff --git a/library/src/main/java/com/panoramagl/downloaders/PLRequestInvalidatedException.kt b/library/src/main/java/com/panoramagl/downloaders/PLRequestInvalidatedException.kt new file mode 100755 index 0000000..ca0e005 --- /dev/null +++ b/library/src/main/java/com/panoramagl/downloaders/PLRequestInvalidatedException.kt @@ -0,0 +1,3 @@ +package com.panoramagl.downloaders + +class PLRequestInvalidatedException(url: String) : RuntimeException(String.format("Request to %s was invalidated", url)) \ No newline at end of file