mirror of
https://github.com/CatimaLoyalty/Android.git
synced 2026-02-01 02:31:59 -05:00
Throw more exceptions
We want to know when the code is wrong instead of silently failing
This commit is contained in:
@@ -975,16 +975,12 @@ public class LoyaltyCardEditActivity extends CatimaAppCompatActivity {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
|
||||
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
try {
|
||||
if (requestCode == PERMISSION_REQUEST_CAMERA_IMAGE_FRONT) {
|
||||
takePhotoForCard(Utils.CARD_IMAGE_FROM_CAMERA_FRONT);
|
||||
} else if (requestCode == PERMISSION_REQUEST_CAMERA_IMAGE_BACK) {
|
||||
takePhotoForCard(Utils.CARD_IMAGE_FROM_CAMERA_BACK);
|
||||
} else if (requestCode == PERMISSION_REQUEST_CAMERA_IMAGE_ICON) {
|
||||
takePhotoForCard(Utils.CARD_IMAGE_FROM_CAMERA_ICON);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
if (requestCode == PERMISSION_REQUEST_CAMERA_IMAGE_FRONT) {
|
||||
takePhotoForCard(Utils.CARD_IMAGE_FROM_CAMERA_FRONT);
|
||||
} else if (requestCode == PERMISSION_REQUEST_CAMERA_IMAGE_BACK) {
|
||||
takePhotoForCard(Utils.CARD_IMAGE_FROM_CAMERA_BACK);
|
||||
} else if (requestCode == PERMISSION_REQUEST_CAMERA_IMAGE_ICON) {
|
||||
takePhotoForCard(Utils.CARD_IMAGE_FROM_CAMERA_ICON);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1220,6 +1216,10 @@ public class LoyaltyCardEditActivity extends CatimaAppCompatActivity {
|
||||
callable.call();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
// Rethrow as NoSuchElementException
|
||||
// This isn't really true, but a View.OnClickListener doesn't allow throwing other types
|
||||
throw new NoSuchElementException(e.getMessage());
|
||||
}
|
||||
})
|
||||
.show();
|
||||
|
||||
@@ -252,8 +252,14 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
if (savedInstanceState == null) {
|
||||
Intent incomingIntent = getIntent();
|
||||
int transitionRight = incomingIntent.getExtras().getInt("transition_right", -1);
|
||||
Bundle incomingIntentExtras = getIntent().getExtras();
|
||||
|
||||
if (incomingIntentExtras == null) {
|
||||
Toast.makeText(this, R.string.noCardExistsError, Toast.LENGTH_LONG).show();
|
||||
finish();
|
||||
}
|
||||
|
||||
int transitionRight = incomingIntentExtras.getInt("transition_right", -1);
|
||||
if (transitionRight == 1) {
|
||||
// right side transition
|
||||
overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
|
||||
|
||||
Reference in New Issue
Block a user