Android Open Source - PhotoStrips Confirm Dialog Fragment






From Project

Back to project page PhotoStrips.

License

The source code is released under:

MIT License

If you think the Android project PhotoStrips 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 com.ahmetkizilay.image.photostrips.dialogs;
/*from   w  w w  . j a  v  a  2 s  .co  m*/
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;

public class ConfirmDialogFragment extends DialogFragment{

    private ConfirmDialogResultListener mCallback;

    private static final String MESSAGE_LABEL = "message";
    private static final String POSITIVE_LABEL = "confirm";
    private static final String NEGATIVE_LABEL = "cancel";

  public static ConfirmDialogFragment newInstance(String message) {
    ConfirmDialogFragment frag = new ConfirmDialogFragment();
    Bundle args = new Bundle();
        args.putString(MESSAGE_LABEL, message);
    frag.setArguments(args);
    return frag;
  }

    public static ConfirmDialogFragment newInstance(String message, String positiveLabel, String negativeLabel) {
        ConfirmDialogFragment frag = new ConfirmDialogFragment();
        Bundle args = new Bundle();
        args.putInt("num", 6);
        args.putString(MESSAGE_LABEL, message);
        args.putString(POSITIVE_LABEL, positiveLabel);
        args.putString(NEGATIVE_LABEL, negativeLabel);
        frag.setArguments(args);
        return frag;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

  public Dialog onCreateDialog(Bundle savedInstanceState) {

        Bundle bundle = getArguments();

        String message = (String) bundle.get(MESSAGE_LABEL);
        String positiveLabel = bundle.get(POSITIVE_LABEL) != null ? (String) bundle.get(POSITIVE_LABEL) : "Confirm";
        String negativeLabel = bundle.get(NEGATIVE_LABEL) != null ? (String) bundle.get(NEGATIVE_LABEL) : "Cancel";

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setMessage(message)
        .setCancelable(false)
        .setPositiveButton(positiveLabel,
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int id) {
                dialog.dismiss();
                mCallback.onPositiveSelected();
              }
            })
        .setNegativeButton(negativeLabel,
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int id) {
                dialog.cancel();
                                mCallback.onNegativeSelected();
              }
            });
    return builder.create();
  }

    public void setConfirmDialogResultListener(ConfirmDialogResultListener callback) {
        this.mCallback = callback;
    }

    public interface ConfirmDialogResultListener {
        public void onPositiveSelected();
        public void onNegativeSelected();
    }
}




Java Source Code List

com.ahmetkizilay.image.photostrips.AltGalleryActivity.java
com.ahmetkizilay.image.photostrips.CameraPreview.java
com.ahmetkizilay.image.photostrips.PhotoBoothActivity.java
com.ahmetkizilay.image.photostrips.PhotoCreator.java
com.ahmetkizilay.image.photostrips.ViewImageActivity.java
com.ahmetkizilay.image.photostrips.dialogs.AboutMeDialogFragment.java
com.ahmetkizilay.image.photostrips.dialogs.CompletionDialogFragment.java
com.ahmetkizilay.image.photostrips.dialogs.ConfirmDialogFragment.java
com.ahmetkizilay.image.photostrips.dialogs.PhotoCreationDialogFragment.java
com.ahmetkizilay.image.photostrips.utils.CustomHorizontalScrollView.java
com.ahmetkizilay.image.photostrips.utils.GalleryItemAdapter.java
com.ahmetkizilay.image.photostrips.utils.OnDoubleTapListener.java
com.ahmetkizilay.image.photostrips.utils.OnMultiTapListener.java
com.ahmetkizilay.image.photostrips.utils.TouchImageView.java
com.ahmetkizilay.image.photostrips.utils.TransportViewGroup.java