From 1e261043f79418b20aa8a6757855ce1ea3f492c2 Mon Sep 17 00:00:00 2001 From: Andrew Sapperstein Date: Tue, 5 Feb 2019 13:02:36 -0800 Subject: Add android_library target. Put most of the app logic in a library so it is more easily reusable. Bug: 120115754 Test: build, verify that EmergencyInfo works Change-Id: I7b2ad172f9487df50a24f0b6c8076db37a865221 --- src/com/android/emergency/edit/EditInfoActivity.java | 19 +++++++++---------- src/com/android/emergency/view/ViewInfoActivity.java | 19 +++++++++---------- 2 files changed, 18 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/com/android/emergency/edit/EditInfoActivity.java b/src/com/android/emergency/edit/EditInfoActivity.java index 8f19692e..7a6a01b8 100644 --- a/src/com/android/emergency/edit/EditInfoActivity.java +++ b/src/com/android/emergency/edit/EditInfoActivity.java @@ -92,16 +92,15 @@ public class EditInfoActivity extends Activity { @Override public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - // The user asked to navigate up, which, in this case, can easily be accomplished - // by finishing the activity. - finish(); - return true; - - case R.id.action_clear_all: - showClearAllDialog(); - return true; + int itemId = item.getItemId(); + if (itemId == android.R.id.home) { + // The user asked to navigate up, which, in this case, can easily be accomplished + // by finishing the activity. + finish(); + return true; + } else if (itemId == R.id.action_clear_all) { + showClearAllDialog(); + return true; } return super.onOptionsItemSelected(item); } diff --git a/src/com/android/emergency/view/ViewInfoActivity.java b/src/com/android/emergency/view/ViewInfoActivity.java index dcf34cba..30bcae36 100644 --- a/src/com/android/emergency/view/ViewInfoActivity.java +++ b/src/com/android/emergency/view/ViewInfoActivity.java @@ -154,16 +154,15 @@ public class ViewInfoActivity extends FragmentActivity { @Override public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - - case R.id.action_edit: - Intent intent = new Intent(this, EditInfoActivity.class); - intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - startActivity(intent); - return true; + int itemId = item.getItemId(); + if (itemId == android.R.id.home) { + onBackPressed(); + return true; + } else if (itemId == R.id.action_edit) { + Intent intent = new Intent(this, EditInfoActivity.class); + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + startActivity(intent); + return true; } return super.onOptionsItemSelected(item); } -- cgit v1.2.3