@ -46,7 +46,7 @@ class PicturePreviewActivity : AppCompatActivity() {
result . toBitmap ( 1000 , 1000 ) { bitmap -> imageView . setImageBitmap ( bitmap ) }
result . toBitmap ( 1000 , 1000 ) { bitmap -> imageView . setImageBitmap ( bitmap ) }
} catch ( e : UnsupportedOperationException ) {
} catch ( e : UnsupportedOperationException ) {
imageView . setImageDrawable ( ColorDrawable ( Color . GREEN ) )
imageView . setImageDrawable ( ColorDrawable ( Color . GREEN ) )
Toast . makeText ( this , " Can't preview this format: " + result . getFormat ( ) , Toast . LENGTH _LONG ) . show ( )
Toast . makeText ( this , " Can't preview this format: " + result . format , Toast . LENGTH _LONG ) . show ( )
}
}
if ( result . isSnapshot ) {
if ( result . isSnapshot ) {
// Log the real size for debugging reason.
// Log the real size for debugging reason.
@ -76,13 +76,13 @@ class PicturePreviewActivity : AppCompatActivity() {
override fun onOptionsItemSelected ( item : MenuItem ) : Boolean {
override fun onOptionsItemSelected ( item : MenuItem ) : Boolean {
if ( item . itemId == R . id . share ) {
if ( item . itemId == R . id . share ) {
Toast . makeText ( this , " Sharing... " , Toast . LENGTH _SHORT ) . show ( )
Toast . makeText ( this , " Sharing... " , Toast . LENGTH _SHORT ) . show ( )
val extension = when ( pictureResult !! . format ) {
val extension = when ( requireNotNull ( pictureResult ) . format ) {
PictureFormat . JPEG -> " jpg "
PictureFormat . JPEG -> " jpg "
PictureFormat . DNG -> " dng "
PictureFormat . DNG -> " dng "
else -> throw RuntimeException ( " Unknown format. " )
else -> throw RuntimeException ( " Unknown format. " )
}
}
val f ile = File ( filesDir , " picture. $extension " )
val destF ile = File ( filesDir , " picture. $extension " )
CameraUtils . writeToFile ( pictureResult !! . data , f ile) { file ->
CameraUtils . writeToFile ( requireNotNull ( pictureResult ?. data ) , destF ile) { file ->
if ( file != null ) {
if ( file != null ) {
val context = this @PicturePreviewActivity
val context = this @PicturePreviewActivity
val intent = Intent ( Intent . ACTION _SEND )
val intent = Intent ( Intent . ACTION _SEND )