
package org.zarroboogs.weibo.dialogfragment;

import org.zarroboogs.weibo.R;

import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.os.Bundle;

public class SaveDraftDialog extends DialogFragment {

    public interface IDraft {
        void saveToDraft();
    }

    public SaveDraftDialog() {

    }

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setTitle(getString(R.string.save_to_draft)).setMessage(getString(R.string.do_you_want_to_save))
                .setPositiveButton(getString(R.string.save), new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        ((IDraft) getActivity()).saveToDraft();
                    }
                }).setNegativeButton(getString(R.string.cancel_draft), new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                getActivity().finish();
            }
        });

        return builder.create();
    }
}
