private void handleSaveMedia() { Intent intent = new Intent(); ArrayList<String> ids = mMediaGalleryEditFragment.getMediaIds(); boolean isRandom = mMediaGallerySettingsFragment.isRandom(); int numColumns = mMediaGallerySettingsFragment.getNumColumns(); String type = mMediaGallerySettingsFragment.getType(); mMediaGallery.setIds(ids); mMediaGallery.setRandom(isRandom); mMediaGallery.setNumColumns(numColumns); mMediaGallery.setType(type); intent.putExtra(RESULT_MEDIA_GALLERY, mMediaGallery); setResult(RESULT_OK, intent); finish(); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (WordPress.wpDB == null) { Toast.makeText(this, R.string.fatal_db_error, Toast.LENGTH_LONG).show(); finish(); return; } setTitle(R.string.media_gallery_edit); setContentView(R.layout.media_gallery_activity); ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.setDisplayShowTitleEnabled(true); } FragmentManager fm = getFragmentManager(); mMediaGallery = (MediaGallery) getIntent().getSerializableExtra(PARAMS_MEDIA_GALLERY); if (mMediaGallery == null) { mMediaGallery = new MediaGallery(); } mMediaGalleryEditFragment = (MediaGalleryEditFragment) fm.findFragmentById(R.id.mediaGalleryEditFragment); mMediaGallerySettingsFragment = (MediaGallerySettingsFragment) fm.findFragmentById(R.id.mediaGallerySettingsFragment); if (savedInstanceState == null) { // if not null, the fragments will remember its state mMediaGallerySettingsFragment.setRandom(mMediaGallery.isRandom()); mMediaGallerySettingsFragment.setNumColumns(mMediaGallery.getNumColumns()); mMediaGallerySettingsFragment.setType(mMediaGallery.getType()); mMediaGalleryEditFragment.setMediaIds(mMediaGallery.getIds()); } mSlidingPanelLayout = (SlidingUpPanelLayout) findViewById(R.id.media_gallery_root); if (mSlidingPanelLayout != null) { // sliding panel layout is on phone only mSlidingPanelLayout.setDragView(mMediaGallerySettingsFragment.getDragView()); mSlidingPanelLayout.setPanelHeight(DisplayUtils.dpToPx(this, 48)); mSlidingPanelLayout.setPanelSlideListener( new PanelSlideListener() { @Override public void onPanelSlide(View panel, float slideOffset) {} @Override public void onPanelExpanded(View panel) { mMediaGallerySettingsFragment.onPanelExpanded(); mIsPanelCollapsed = false; } @Override public void onPanelCollapsed(View panel) { mMediaGallerySettingsFragment.onPanelCollapsed(); mIsPanelCollapsed = true; } }); } if (getIntent().hasExtra(PARAMS_LAUNCH_PICKER)) { handleAddMedia(); } }