finish the Edit activity if the image uri is invalid

This commit is contained in:
tibbi 2016-10-05 23:36:53 +02:00
parent acf539ee93
commit c433c897b5
9 changed files with 16 additions and 0 deletions

View file

@ -13,9 +13,16 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_edit) setContentView(R.layout.activity_edit)
if (intent.data == null) {
toast(R.string.invalid_image_path)
finish()
return
}
crop_image_view.apply { crop_image_view.apply {
guidelines = CropImageView.Guidelines.OFF guidelines = CropImageView.Guidelines.OFF
setOnCropImageCompleteListener(this@EditActivity) setOnCropImageCompleteListener(this@EditActivity)
setImageUriAsync(intent.data)
} }
} }

View file

@ -4,3 +4,5 @@ import android.content.Context
import android.widget.Toast import android.widget.Toast
fun Context.toast(msg: String, duration: Int = Toast.LENGTH_SHORT) = Toast.makeText(this, msg, duration).show() fun Context.toast(msg: String, duration: Int = Toast.LENGTH_SHORT) = Toast.makeText(this, msg, duration).show()
fun Context.toast(msgId: Int, duration: Int = Toast.LENGTH_SHORT) = Toast.makeText(this, resources.getString(msgId), duration).show()

View file

@ -48,6 +48,7 @@
<string name="save">Save</string> <string name="save">Save</string>
<string name="rotate">Rotate</string> <string name="rotate">Rotate</string>
<string name="image_croping_failed">Image croping failed:</string> <string name="image_croping_failed">Image croping failed:</string>
<string name="invalid_image_path">Invalid image path</string>
<!-- About --> <!-- About -->
<string name="about">Über</string> <string name="about">Über</string>

View file

@ -48,6 +48,7 @@
<string name="save">Save</string> <string name="save">Save</string>
<string name="rotate">Rotate</string> <string name="rotate">Rotate</string>
<string name="image_croping_failed">Image croping failed:</string> <string name="image_croping_failed">Image croping failed:</string>
<string name="invalid_image_path">Invalid image path</string>
<!-- About --> <!-- About -->
<string name="about">Acerca de</string> <string name="about">Acerca de</string>

View file

@ -48,6 +48,7 @@
<string name="save">Save</string> <string name="save">Save</string>
<string name="rotate">Rotate</string> <string name="rotate">Rotate</string>
<string name="image_croping_failed">Image croping failed:</string> <string name="image_croping_failed">Image croping failed:</string>
<string name="invalid_image_path">Invalid image path</string>
<!-- About --> <!-- About -->
<string name="about">Informazioni</string> <string name="about">Informazioni</string>

View file

@ -48,6 +48,7 @@
<string name="save">Save</string> <string name="save">Save</string>
<string name="rotate">Rotate</string> <string name="rotate">Rotate</string>
<string name="image_croping_failed">Image croping failed:</string> <string name="image_croping_failed">Image croping failed:</string>
<string name="invalid_image_path">Invalid image path</string>
<!-- About --> <!-- About -->
<string name="about">アプリについて</string> <string name="about">アプリについて</string>

View file

@ -48,6 +48,7 @@
<string name="save">Save</string> <string name="save">Save</string>
<string name="rotate">Rotate</string> <string name="rotate">Rotate</string>
<string name="image_croping_failed">Image croping failed:</string> <string name="image_croping_failed">Image croping failed:</string>
<string name="invalid_image_path">Invalid image path</string>
<!-- About --> <!-- About -->
<string name="about">Sobre</string> <string name="about">Sobre</string>

View file

@ -48,6 +48,7 @@
<string name="save">Save</string> <string name="save">Save</string>
<string name="rotate">Rotate</string> <string name="rotate">Rotate</string>
<string name="image_croping_failed">Image croping failed:</string> <string name="image_croping_failed">Image croping failed:</string>
<string name="invalid_image_path">Invalid image path</string>
<!-- About --> <!-- About -->
<string name="about">Om</string> <string name="about">Om</string>

View file

@ -48,6 +48,7 @@
<string name="save">Save</string> <string name="save">Save</string>
<string name="rotate">Rotate</string> <string name="rotate">Rotate</string>
<string name="image_croping_failed">Image croping failed:</string> <string name="image_croping_failed">Image croping failed:</string>
<string name="invalid_image_path">Invalid image path</string>
<!-- About --> <!-- About -->
<string name="about">About</string> <string name="about">About</string>