Skip to content

Instantly share code, notes, and snippets.

@deepakkumardk
Last active June 14, 2019 12:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deepakkumardk/63cbf0335847cf365ecaf5a420815e3d to your computer and use it in GitHub Desktop.
Save deepakkumardk/63cbf0335847cf365ecaf5a420815e3d to your computer and use it in GitHub Desktop.
Identifying the source of image and handling it
private fun handleSendImage(intent: Intent) {
val imageUri = intent.getParcelableExtra<Uri>(Intent.EXTRA_STREAM)
if (imageUri.toString().contains("com.google.android.apps.docs")) { //From Google Drive
// show the progress bar until the you get the file
this.createTempFile(imageUri, DriveTempFileCallback {
// hide the progress bar
// file -- handle the file as you want
})
} else { //From gallery intent
// handle signle image from gallary intent
}
}
private fun handleSendMultipleImages(intent: Intent) {
val imageUris = intent.getParcelableArrayListExtra<Uri>(Intent.EXTRA_STREAM)
if (imageUris.size > 1 && imageUris[0].toString().contains("com.google.android.apps.docs")) {
// show the progress bar until the you get the URI list
this.getUriListFromTempFile(imageUris, DriveImageCallback {
// hide the progress bar
// list -- handle the arrayList of Uri
})
} else {
// handle multiple images from gallary intent
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment