Android Open Source - Cam2IMU_calib Save Data Dialog






From Project

Back to project page Cam2IMU_calib.

License

The source code is released under:

MIT License

If you think the Android project Cam2IMU_calib listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package cvg.vslam.c2i_calib;
/*from   ww  w . j a  v a  2s .  co m*/
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.os.Bundle;

import java.io.File;

/**
 * Created with IntelliJ IDEA.
 * User: fede
 * Date: 7/17/13
 * Time: 6:44 PM
 * To change this template use File | Settings | File Templates.
 */

public class SaveDataDialog extends DialogFragment {

    private File storageDir;
    private MainActivity activity;

    public SaveDataDialog(File storageDir, MainActivity activity){
        this.storageDir = storageDir;
        this.activity = activity;
    }

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        // Use the Builder class for convenient dialog construction
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setMessage("Save gathered images/sensor readings?")
                .setPositiveButton("Save", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        activity.finish();
                    }
                })
                .setNegativeButton("Discard", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        recursiveDelete(storageDir);
                        activity.finish();
                    }
                });

        return builder.create();

    }

    private void recursiveDelete(File fileOrDirectory) {
        if (fileOrDirectory.isDirectory())
            for (File child : fileOrDirectory.listFiles())
                recursiveDelete(child);
        fileOrDirectory.delete();
    }

}




Java Source Code List

cvg.vslam.c2i_calib.CameraPreview.java
cvg.vslam.c2i_calib.MainActivity.java
cvg.vslam.c2i_calib.SaveDataDialog.java
cvg.vslam.c2i_calib.SensorBuffer.java