+ @Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ Log.d("profiles", "[fragment] Creating profile details options menu");
+ super.onCreateOptionsMenu(menu, inflater);
+ inflater.inflate(R.menu.profile_details, menu);
+ final MenuItem menuDeleteProfile = menu.findItem(R.id.menuDelete);
+ menuDeleteProfile.setOnMenuItemClickListener(item -> {
+ Log.d("profiles", String.format("[fragment] removing profile %s", mProfile.getUuid()));
+ mProfile.removeFromDB();
+ Data.profiles.remove(mProfile);
+ if (Data.profile.get().equals(mProfile)) {
+ Log.d("profiles", "[fragment] setting current profile to 0");
+ Data.setCurrentProfile(Data.profiles.get(0));
+ }
+ return false;
+ });
+ menuDeleteProfile.setVisible((mProfile != null) && (Data.profiles.size() > 1));
+ }