This file contains hidden or 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
companion object { | |
/** | |
* Unique job ID for this service. | |
*/ | |
const val JOB_ID = 1000 | |
const val IMAGE_URI = "image_uri" | |
const val IMAGE_URL = "image_url" | |
const val DOCUMENT_URI = "document_uri" | |
const val DOCUMENT_URL = "document_url" |
This file contains hidden or 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
class UploadService : JobIntentService() { | |
private val secrets = getSecrets() | |
override fun onHandleWork(intent: Intent) { | |
if (intent.extras?.containsKey(IMAGE_URI) == true) { | |
val imageUri = intent.getParcelableExtra<Uri>(IMAGE_URI) | |
var image: Bitmap? = null | |
if (imageUri != null) { | |
image = MediaStore.Images.Media.getBitmap(contentResolver, imageUri) |
This file contains hidden or 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
LiveSubject.FILE_UPLOAD_FILE.subscribe({ | |
when(it) { | |
is UploadFileStatus.Complete -> { | |
Glide.with(this).load(it.s3Url).into(image) | |
toast("Uploaded image") | |
logD("complete upload") | |
} | |
is UploadFileStatus.Error -> { | |
logE("could not upload") | |
} |
OlderNewer