@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_filter); mUri = getIntent().getParcelableExtra(KEY_PATH); mControlHolder = (LinearLayout) findViewById(R.id.linearLayoutControlHolder); mToolbar = (Toolbar) findViewById(R.id.toolbar); mBlurSizeSpinner = (Spinner) findViewById(R.id.spinnerBlurSize); mFilterSizeAdapter = new FilterSizeAdapter(this, 10, 100); mBlurSizeSpinner.setAdapter(mFilterSizeAdapter); mBlurSizeSpinner.setSelection(8); mBlurSizeSpinner.setOnItemSelectedListener(this); setSupportActionBar(mToolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); mBlurButton = (ImageButton) findViewById(R.id.imageButtonFilter); mBlurButton.setOnClickListener(mBlurClickListener); mPanButton = (ImageButton) findViewById(R.id.imageButtonPan); mPanButton.setOnClickListener(mPanClickListener); if (savedInstanceState == null) { mFilterFragment = FilterFragment.newInstance(mUri); getSupportFragmentManager() .beginTransaction() .add(R.id.frameLayoutBlurHolder, mFilterFragment, TAG_FRAGMENT) .commit(); } else { mFilterFragment = (FilterFragment) getSupportFragmentManager().findFragmentByTag(TAG_FRAGMENT); } mFilterFragment.setCurrentFilter(new PixelateFilter()); }
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_undo: mFilterFragment.undo(); return true; case R.id.action_save: showSaveDialog(); return true; case R.id.action_delete: undoAll(); return true; case R.id.action_share: share(); return true; case R.id.action_feedback: Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "*****@*****.**", null)); emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Pixelator " + BuildConfig.VERSION_NAME); startActivity(Intent.createChooser(emailIntent, "Send feedback...")); return true; case android.R.id.home: onBackPressed(); return true; } return super.onOptionsItemSelected(item); }
private void save(final File pathFile) { if (mSaveProgressDialog == null) { mSaveProgressDialog = new ProgressDialog(this); mSaveProgressDialog.setMessage("Saving"); mSaveProgressDialog.setCancelable(false); mSaveProgressDialog.show(); } mSaveTask = new SaveTask(mFilterFragment.getBlurredImage(), this); mSaveTask.execute(pathFile); }
@Override public void onClick(View v) { mFilterFragment.setControlMode(FilterFragment.MODE_FILTER); mPanButton.setBackgroundResource(R.drawable.btn_selected); mBlurButton.setBackgroundResource(R.drawable.btn_unselected); }
@Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (mFilterFragment != null) { mFilterFragment.setFilterSize(mFilterSizeAdapter.getSize(position)); } }