-
-
Notifications
You must be signed in to change notification settings - Fork 693
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#450 implemented delegates substitute, making the RequestObserver (Br…
…oadcastReceiver) Lifecycle aware and adding addional onCompletedWhileNotObserving method to cover an edge case
- Loading branch information
Showing
8 changed files
with
153 additions
and
84 deletions.
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
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
53 changes: 53 additions & 0 deletions
53
...service/src/main/java/net/gotev/uploadservice/observer/request/RequestObserverDelegate.kt
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,53 @@ | ||
package net.gotev.uploadservice.observer.request | ||
|
||
import android.content.Context | ||
import net.gotev.uploadservice.data.UploadInfo | ||
import net.gotev.uploadservice.network.ServerResponse | ||
|
||
interface RequestObserverDelegate { | ||
/** | ||
* Called when the upload progress changes. | ||
* | ||
* @param context context | ||
* @param uploadInfo upload status information | ||
*/ | ||
fun onProgress(context: Context, uploadInfo: UploadInfo) | ||
|
||
/** | ||
* Called when the upload is completed successfully. | ||
* | ||
* @param context context | ||
* @param uploadInfo upload status information | ||
* @param serverResponse response got from the server | ||
*/ | ||
fun onSuccess(context: Context, uploadInfo: UploadInfo, serverResponse: ServerResponse) | ||
|
||
/** | ||
* Called when an error happens during the upload. | ||
* | ||
* @param context context | ||
* @param uploadInfo upload status information | ||
* @param exception exception that caused the error | ||
*/ | ||
fun onError(context: Context, uploadInfo: UploadInfo, exception: Throwable) | ||
|
||
/** | ||
* Called when the upload is completed wither with success or error. | ||
* | ||
* @param context context | ||
* @param uploadInfo upload status information | ||
*/ | ||
fun onCompleted(context: Context, uploadInfo: UploadInfo) | ||
|
||
/** | ||
* Called only when listening to a single upload ID and you register the request observer, | ||
* but the upload ID is not present in UploadService's task list, meaning it has completed. | ||
* In this case, you cannot know with which state it finished (success or error). | ||
* | ||
* Useful when used in activities and the following scenario applies: | ||
* - user triggers an upload in an activity which shows the progress | ||
* - user navigates away from that activity and comes back later after the upload completed and | ||
* you need to to some stuff to adjust UI properly | ||
*/ | ||
fun onCompletedWhileNotObserving() | ||
} |
17 changes: 0 additions & 17 deletions
17
...adservice/src/main/java/net/gotev/uploadservice/observer/request/SingleRequestObserver.kt
This file was deleted.
Oops, something went wrong.