@Override protected void onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent) { super.onActivityResult(requestCode, resultCode, imageReturnedIntent); Log.i(Constants.TAG, "SAVING IMG RESULT:" + resultCode); if (resultCode == RESULT_OK) { Uri selectedImage = imageReturnedIntent.getData(); Log.i(Constants.TAG, "RESULT_OK PATH:" + selectedImage.toString()); collected.setImagePath(selectedImage.toString()); // String[] filePathColumn = {MediaStore.Images.Media.DATA}; db.createOrUpdateTag(collected); // Bitmap yourSelectedImage = BitmapFactory.decodeFile(filePath); Log.i(Constants.TAG, "SAVED IMG PATH:" + collected.getImagePath()); } FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); TagDetailFragment fragment = new TagDetailFragment(); transaction.replace(R.id.detailPane, fragment); transaction.commit(); }
@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 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 } }
public void showDetails(int pos) { Bundle bundle = new Bundle(); bundle.putInt("key", pos); List<SoulissTypical> typicalList = collected.getAssignedTypicals(); android.support.v4.app.FragmentManager manager = getSupportFragmentManager(); // Check what fragment is currently shown, replace if needed. Fragment details = manager.findFragmentById(R.id.detailPane); Fragment NewFrag = null; // Istanzia e ci mette l'indice if (typicalList.get(pos).isSensor()) NewFrag = T5nSensorFragment.newInstance(pos, typicalList.get(pos)); else if (typicalList.get(pos) instanceof SoulissTypical16AdvancedRGB) NewFrag = T16RGBAdvancedFragment.newInstance(pos, typicalList.get(pos)); else if (typicalList.get(pos) instanceof SoulissTypical19AnalogChannel) NewFrag = T19SingleChannelLedFragment.newInstance(pos, typicalList.get(pos)); else if (typicalList.get(pos) instanceof SoulissTypical31Heating) NewFrag = T31HeatingFragment.newInstance(pos, typicalList.get(pos)); else if (typicalList.get(pos) instanceof SoulissTypical11DigitalOutput || typicalList.get(pos) instanceof SoulissTypical12DigitalOutputAuto) NewFrag = T1nGenericLightFragment.newInstance(pos, typicalList.get(pos)); else if (typicalList.get(pos) instanceof SoulissTypical41AntiTheft || typicalList.get(pos) instanceof SoulissTypical42AntiTheftPeer || typicalList.get(pos) instanceof SoulissTypical43AntiTheftLocalPeer) NewFrag = T4nFragment.newInstance(pos, typicalList.get(pos)); FragmentTransaction ft = manager.beginTransaction(); if (NewFrag != null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // details.setSharedElementReturnTransition(TransitionInflater.from(this).inflateTransition(android.R.transition.move)); // details.setExitTransition(TransitionInflater.from(this).inflateTransition(android.R.transition.fade)); // Create new fragment to add (Fragment B) // NewFrag.setSharedElementEnterTransition(TransitionInflater.from(this).inflateTransition(android.R.transition.move)); NewFrag.setEnterTransition( TransitionInflater.from(this).inflateTransition(android.R.transition.explode)); // Our shared element (in Fragment A) ImageView mProductImage = (ImageView) details.getView().findViewById(R.id.card_thumbnail_image2); TextView mProductText = (TextView) findViewById(R.id.TextViewTypicalsTitle); AppBarLayout.Behavior beh = new AppBarLayout.Behavior(); // Add Fragment B manager .beginTransaction() .replace(R.id.detailPane, NewFrag) .addToBackStack("transaction") .addSharedElement(mProductText, "hero_title") .commit(); // NOT WORK // .addSharedElement(mProductText, "ToolbarText"); } else { // if (opzioni.isAnimationsEnabled()) // ft.setCustomAnimations(R.anim.slide_in_right, R.anim.slide_out_left); ft.replace(R.id.detailPane, NewFrag); ft.addToBackStack(null); // ft.remove(details); // ft.add(NewFrag,"BOH"); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE); ft.commit(); } } else { Toast.makeText(getApplicationContext(), "No detail to show", Toast.LENGTH_SHORT).show(); } }
@Override protected void onResume() { super.onResume(); setActionBarInfo(collected.getNiceName()); }