Android Open Source - Android-Media-Helper Fragment Support Yes No Dialog






From Project

Back to project page Android-Media-Helper.

License

The source code is released under:

Apache License

If you think the Android project Android-Media-Helper 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 mobi.sherif.imageuploader;
//w  w  w. ja va2 s  .c  o  m
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;

class FragmentSupportYesNoDialog extends android.support.v4.app.DialogFragment {
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    String title = getArguments().getString(FragmentYesNoDialogBuilder.EXTRA_TITLE);
    String yes = getArguments().getString(FragmentYesNoDialogBuilder.EXTRA_YES);
    String no = getArguments().getString(FragmentYesNoDialogBuilder.EXTRA_NO);
    String cancel = getArguments().getString(FragmentYesNoDialogBuilder.EXTRA_CANCEL);
    String message = getArguments().getString(FragmentYesNoDialogBuilder.EXTRA_MESSAGE);
    int icon = getArguments().getInt(FragmentYesNoDialogBuilder.EXTRA_ICON);
    AlertDialog.Builder b = new AlertDialog.Builder(getActivity());
    if (icon != -1) {
      b.setIcon(icon);
    }
    if (title != null) {
      b.setTitle(title);
    }
    if (message != null) {
      b.setMessage(message);
    }
    if (yes != null) {
      b.setPositiveButton(yes, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
          onYes();
        }
      });
    }
    if (no != null) {
      b.setNegativeButton(no, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
          onNo();
        }
      });
    }
    if (cancel != null) {
      b.setNeutralButton(cancel, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
          onNeutral();
        }
      });
    }
    return b.create();
  }

  protected void onNeutral( ) {
    ( MediaEngine.get(getArguments().getInt(FragmentYesNoDialogBuilder.EXTRA_ID)) ).performCancel();
  }

  protected void onNo( ) {
    ( MediaEngine.get(getArguments().getInt(FragmentYesNoDialogBuilder.EXTRA_ID)) ).performImageChoose();
  }

  protected void onYes( ) {
    ( MediaEngine.get(getArguments().getInt(FragmentYesNoDialogBuilder.EXTRA_ID)) ).performImageTake();
  }
}




Java Source Code List

mobi.sherif.example.imageuploader.ActivityForFragmentSupportVideo.java
mobi.sherif.example.imageuploader.ActivityForFragmentSupport.java
mobi.sherif.example.imageuploader.ActivityForFragmentVideo.java
mobi.sherif.example.imageuploader.ActivityForFragment.java
mobi.sherif.example.imageuploader.ImageUploaderActivitySupportVideo.java
mobi.sherif.example.imageuploader.ImageUploaderActivitySupport.java
mobi.sherif.example.imageuploader.ImageUploaderActivityVideo.java
mobi.sherif.example.imageuploader.ImageUploaderActivity.java
mobi.sherif.example.imageuploader.ImageUploaderFragmentSupportVideo.java
mobi.sherif.example.imageuploader.ImageUploaderFragmentSupport.java
mobi.sherif.example.imageuploader.ImageUploaderFragmentVideo.java
mobi.sherif.example.imageuploader.ImageUploaderFragment.java
mobi.sherif.example.imageuploader.MainActivity.java
mobi.sherif.imageuploader.ActivityManager.java
mobi.sherif.imageuploader.DefaultFileCreator.java
mobi.sherif.imageuploader.DefaultImageFileCreator.java
mobi.sherif.imageuploader.DefaultVideoFileCreator.java
mobi.sherif.imageuploader.FileLoadTask.java
mobi.sherif.imageuploader.FragmentSupportYesNoDialog.java
mobi.sherif.imageuploader.FragmentYesNoDialogBuilder.java
mobi.sherif.imageuploader.FragmentYesNoDialog.java
mobi.sherif.imageuploader.MediaEngine.java