App

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
mhr.app.fragments.toolbox.FileOperationsToolSettingsFragment Class Reference

Slouží k nastavení nástroje pro práci se soubory. More...

Inheritance diagram for mhr.app.fragments.toolbox.FileOperationsToolSettingsFragment:

## Public Member Functions
void | onClick (View v)
void | onAttach (Activity activity)
View | onCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)

## Protected Member Functions
void | initExportDialog (LayoutInflater inflater)
View | initView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)

## Protected Attributes
View | root = null
AppMainActivity | activity
AlertDialog | exportDialog

## Detailed Description

Slouží k nastavení nástroje pro práci se soubory.

Definition at line 45 of file FileOperationsToolSettingsFragment.java.

## Member Function Documentation

void mhr.app.fragments.toolbox.FileOperationsToolSettingsFragment.initExportDialog | ( | LayoutInflater | inflater | ) |
| inlineprotected

Definition at line 61 of file FileOperationsToolSettingsFragment.java.

{
AlertDialog.Builder b = new AlertDialog.Builder(activity);
final View dv = inflater.inflate(R.layout.dialog_export_image, null, false);
((Spinner)dv.findViewById(R.id.ExportFormatSp)).setOnItemSelectedListener(new OnItemSelectedListener() {
View quality = dv.findViewById(R.id.ImageQualityValueGroup);
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
if (position == 0) {
quality.setVisibility(quality.VISIBLE);
} else {
quality.setVisibility(quality.INVISIBLE);
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
((SeekBar)dv.findViewById(R.id.ImageQualityValueSB)).setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
TextView label = (TextView)dv.findViewById(R.id.ImageQualityValueTV);
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
label.setText(Integer.toString(progress));
}
});
b.setMessage("Please select output file name, format and quality.").setTitle("Export image to gallery").setView(dv);
b.setPositiveButton("Export", new DialogInterface.OnClickListener() {
final AppMainActivity a = activity;
final Spinner format = (Spinner)dv.findViewById(R.id.ExportFormatSp);
final EditText name = (EditText) dv.findViewById(R.id.ExportFileNameValueET);
final SeekBar quality = (SeekBar) dv.findViewById(R.id.ImageQualityValueSB);
boolean ow = false;
protected File getFile() {
File path = Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES);
return new File(path, name.getText().toString() + format.getSelectedItem().toString());
}
protected void writeFile(File f) {
AppCore c = a.getAppCore();
c.suspend(); // Nic nedela
Bitmap out = ((APDBitmap)c.getOutput()).getBitmap();
OutputStream os = null;
try {
f.getParentFile().mkdirs(); // Jestli cesta opravdu existuje
os = new FileOutputStream(f);
switch (format.getSelectedItemPosition()) {
case 0:
out.compress(CompressFormat.JPEG, quality.getProgress(), os);
break;
case 1:
out.compress(CompressFormat.PNG, 100, os);
break;
default:
break;
}
os.flush();
} catch (IOException e) {
} finally {
if (os != null) {
try {
os.close();
} catch (IOException e) {
}
}
}
MediaScannerConnection.scanFile(activity, new String[] { f.toString() }, null, null);
c.wake(); // Prozatim nic...
}
@Override
public void onClick(DialogInterface dialog, int which) {
final File file = getFile();
if (file.exists()) {
AlertDialog.Builder b = new AlertDialog.Builder(activity);
b.setMessage("Do you want to overwrite the file?").setTitle("File already exists");
b.setPositiveButton("Overwrite", new DialogInterface.OnClickListener() {
File f = file;
@Override
public void onClick(DialogInterface dialog, int which) {
writeFile(f);
}
});
b.setNegativeButton("Cancel", null);
b.create().show();
return;
} else {
writeFile(file);
}
}
});
b.setNegativeButton("Cancel", null);
exportDialog = b.create();
}

View mhr.app.fragments.toolbox.FileOperationsToolSettingsFragment.initView | ( | LayoutInflater | inflater,
|  | ViewGroup | container,
|  | Bundle | savedInstanceState
| ) |  |
| inlineprotected

Definition at line 197 of file FileOperationsToolSettingsFragment.java.

{
View v = inflater.inflate(R.layout.fragment_file_operations_tool_settings, container, false);
root = v;
root.findViewById(R.id.CreateNewImageBtn).setOnClickListener(this);
root.findViewById(R.id.OpenGalleryImageBtn).setOnClickListener(this);
root.findViewById(R.id.OpenSavedImageBtn).setOnClickListener(this);
root.findViewById(R.id.SaveImageBtn).setOnClickListener(this);
root.findViewById(R.id.ExportImageBtn).setOnClickListener(this);
initExportDialog(inflater);
return v;
}

void mhr.app.fragments.toolbox.FileOperationsToolSettingsFragment.onAttach | ( | Activity | activity | ) |
| inline

Definition at line 252 of file FileOperationsToolSettingsFragment.java.

{
super.onAttach(activity);
/*
* called once the fragment is associated with its activity.
*/
this.activity = (AppMainActivity) activity;
}

void mhr.app.fragments.toolbox.FileOperationsToolSettingsFragment.onClick | ( | View | v | ) |
| inline

Definition at line 218 of file FileOperationsToolSettingsFragment.java.

{
int id = v.getId();
switch (id) {
case R.id.CreateNewImageBtn:
activity.showDialog(new CreateImagePopUpFragment());
break;
case R.id.OpenGalleryImageBtn:
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
intent.putExtra(Intent.EXTRA_TITLE, "Open image with:");
intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
try {
activity.startActivityForResult(intent, activity.OPEN_IMAGE_FROM_GALLERY_REQUEST_CODE);
} catch (ActivityNotFoundException e) {
e.printStackTrace();
}
break;
case R.id.OpenSavedImageBtn:
activity.showDialog(new OpenImagePopUpFragment());
break;
case R.id.SaveImageBtn:
activity.showDialog(new SaveImagePopUpFragment());
break;
case R.id.ExportImageBtn:
exportDialog.show();
break;
default:
break;
}
}

View mhr.app.fragments.toolbox.FileOperationsToolSettingsFragment.onCreateView | ( | LayoutInflater | inflater,
|  | ViewGroup | container,
|  | Bundle | savedInstanceState
| ) |  |
| inline

Definition at line 272 of file FileOperationsToolSettingsFragment.java.

{
// return super.onCreateView(inflater, container, savedInstanceState);
/*
* creates and returns the view hierarchy associated with the fragment.
*
* The system calls this when it's time for the fragment to draw its user interface for the first time. To draw a UI for your fragment, you must return a
* View from this method that is the root of your fragment's layout. You can return null if the fragment does not provide a UI.
*
* Zde začíná životní cyklus při návratu z backstacku
*/
if (root == null) {
return initView(inflater, container, savedInstanceState);
} else {
return root;
}
}

## Member Data Documentation

AppMainActivity mhr.app.fragments.toolbox.FileOperationsToolSettingsFragment.activity
| protected

Definition at line 54 of file FileOperationsToolSettingsFragment.java.

AlertDialog mhr.app.fragments.toolbox.FileOperationsToolSettingsFragment.exportDialog
| protected

Definition at line 55 of file FileOperationsToolSettingsFragment.java.

View mhr.app.fragments.toolbox.FileOperationsToolSettingsFragment.root = null
| protected

Definition at line 53 of file FileOperationsToolSettingsFragment.java.

The documentation for this class was generated from the following file:

- /home/xxx/eclipse_workspaces/app/app/src/mhr/app/fragments/toolbox/FileOperationsToolSettingsFragment.java