@@ -0,0 +1,4030 @@
+/*%0A * The MIT License (MIT)%0A *%0A * Copyright (c) 2012-2014 lacolaco.net%0A *%0A * Permission is hereby granted, free of charge, to any person obtaining a copy%0A * of this software and associated documentation files (the %22Software%22), to deal%0A * in the Software without restriction, including without limitation the rights%0A * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell%0A * copies of the Software, and to permit persons to whom the Software is%0A * furnished to do so, subject to the following conditions:%0A *%0A * The above copyright notice and this permission notice shall be included in all%0A * copies or substantial portions of the Software.%0A *%0A * THE SOFTWARE IS PROVIDED %22AS IS%22, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR%0A * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,%0A * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE%0A * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER%0A * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,%0A * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE%0A * SOFTWARE.%0A */%0A%0Apackage net.lacolaco.smileessence.view.dialog;%0A%0Aimport android.app.Activity;%0Aimport android.app.AlertDialog;%0Aimport android.app.Dialog;%0Aimport android.app.DialogFragment;%0Aimport android.content.DialogInterface;%0Aimport android.os.Bundle;%0Aimport net.lacolaco.smileessence.R;%0A%0Apublic abstract class ConfirmDialogFragment extends DialogFragment%0A%7B%0A%0A    public static final String ARG_TEXT = %22text%22;%0A    private final DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener()%0A    %7B%0A        @Override%0A        public void onClick(DialogInterface dialog, int which)%0A        %7B%0A            onButtonClick(which);%0A            dialog.dismiss();%0A        %7D%0A    %7D;%0A    private int layoutResourceID;%0A    private String text;%0A%0A    public void setText(String text)%0A    %7B%0A        Bundle args = new Bundle();%0A        args.putString(ARG_TEXT, text);%0A        setArguments(args);%0A    %7D%0A%0A    @Override%0A    public void onCreate(Bundle savedInstanceState)%0A    %7B%0A        super.onCreate(savedInstanceState);%0A        Bundle args = getArguments();%0A        if(args != null)%0A        %7B%0A            text = args.getString(ARG_TEXT);%0A        %7D%0A    %7D%0A%0A    @Override%0A    public Dialog onCreateDialog(Bundle savedInstanceState)%0A    %7B%0A        return new AlertDialog.Builder(getActivity()).setTitle(text)%0A                                                     .setCancelable(false)%0A                                                     .setPositiveButton(R.string.alert_dialog_ok, listener)%0A                                                     .setNegativeButton(R.string.alert_dialog_cancel, listener)%0A                                                     .create();%0A    %7D%0A%0A    public abstract void onButtonClick(int which);%0A%0A    public static void show(Activity activity, String text, final Runnable onYes)%0A    %7B%0A        show(activity, text, onYes, null);%0A    %7D%0A%0A    public static void show(Activity activity, String text, final Runnable onOK, final Runnable onCancel)%0A    %7B%0A        ConfirmDialogFragment fragment = new ConfirmDialogFragment()%0A        %7B%0A            @Override%0A            public void onButtonClick(int which)%0A            %7B%0A                switch(which)%0A                %7B%0A                    case DialogInterface.BUTTON_POSITIVE:%0A                    %7B%0A                        if(onOK != null)%0A                        %7B%0A                            onOK.run();%0A                        %7D%0A                        break;%0A                    %7D%0A                    case DialogInterface.BUTTON_NEGATIVE:%0A                    %7B%0A                        if(onCancel != null)%0A                        %7B%0A                            onCancel.run();%0A                        %7D%0A                        break;%0A                    %7D%0A                %7D%0A            %7D%0A        %7D;%0A        fragment.setText(text);%0A        DialogHelper helper = new DialogHelper(activity, fragment);%0A        helper.show();%0A    %7D%0A%7D%0A

Add ConfirmDialogFragment