@Override public void onBackPressed() { Fragment details = getSupportFragmentManager().findFragmentById(R.id.detailPane); Log.w(Constants.TAG, "instanceof: " + details.getClass()); if (details instanceof TagDetailFragment) { supportFinishAfterTransition(); super.onBackPressed(); } else { getSupportFragmentManager().popBackStack(); setActionBarInfo(collected.getNiceName()); // don't call super here } }
@Override public boolean onOptionsItemSelected(MenuItem item) { ImageView icon = (ImageView) findViewById(R.id.node_icon); switch (item.getItemId()) { case android.R.id.home: Fragment details = getSupportFragmentManager().findFragmentById(R.id.detailPane); Log.w(Constants.TAG, "instanceof: " + details.getClass()); if (details instanceof TagDetailFragment) supportFinishAfterTransition(); else { getSupportFragmentManager().popBackStack(); setActionBarInfo(collected.getNiceName()); } return true; case R.id.Opzioni: Intent settingsActivity = new Intent(this, PreferencesActivity.class); startActivity(settingsActivity); final Intent preferencesActivity = new Intent(this.getBaseContext(), PreferencesActivity.class); // evita doppie aperture per via delle sotto-schermate preferencesActivity.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(preferencesActivity); return true; case R.id.scegliconaTag: AlertDialog.Builder alert2 = AlertDialogHelper.chooseIconDialog(this, icon, null, db, collected); alert2.show(); return true; case R.id.rinominaTag: AlertDialog.Builder alert = AlertDialogHelper.renameSoulissObjectDialog( this, actionTitleTextView, null, db, collected); alert.show(); return true; case R.id.scegliImmagineTag: Intent intent = new Intent( Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(intent, collected.getTagId().intValue()); return true; } return super.onOptionsItemSelected(item); }
@Override protected void onResume() { super.onResume(); setActionBarInfo(collected.getNiceName()); }