+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ super.onCreateOptionsMenu(menu);
+ Log.d("profiles", "[activity] Creating profile details options menu");
+ getMenuInflater().inflate(R.menu.profile_details, menu);
+ MenuItem menuDeleteProfile = menu.findItem(R.id.menuDelete);
+ menuDeleteProfile.setOnMenuItemClickListener(item -> {
+ Log.d("profiles", String.format("[activity] deleting profile %s", profile.getUuid()));
+ profile.removeFromDB();
+ Data.profiles.remove(profile);
+ if (Data.profile.get().equals(profile)) {
+ Log.d("profiles", "[activity] selecting profile 0");
+ Data.setCurrentProfile(Data.profiles.get(0));
+ }
+ finish();
+ return true;
+ });
+
+ menuDeleteProfile.setVisible((profile != null) && (Data.profiles.size() > 1));
+
+ return true;
+ }