Android Open Source - go-android Quit Dialog Fragment






From Project

Back to project page go-android.

License

The source code is released under:

MIT License

If you think the Android project go-android 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.pololanguage.pologo;
//from   w  ww. ja  v  a2  s  .c  o  m
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.os.Bundle;

public class QuitDialogFragment extends DialogFragment {

  public interface QuitDialogListener {
    public void onDialogPositiveClick();
    public void onDialogNeutralClick();
    //public void onDialogNegativeClick();
  }

  QuitDialogListener listener;

  @Override
  public void onAttach(Activity activity) {
    super.onAttach(activity);
    // Verify that the host activity implements the callback interface
    try {
      // Instantiate the NoticeDialogListener so we can send events to the host
      listener = (QuitDialogListener) activity;
    } catch (ClassCastException e) {
      throw new ClassCastException(activity.toString() + " must implement QuitDialogListener");
    }
  }

  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    builder.setPositiveButton(R.string.quit, new DialogInterface.OnClickListener() {
      @Override
      public void onClick(DialogInterface dialog, int which) {
        listener.onDialogPositiveClick();
      }
    });

    builder.setNeutralButton(R.string.new_game, new DialogInterface.OnClickListener() {
      @Override
      public void onClick(DialogInterface dialog, int which) {
        listener.onDialogNeutralClick();
      }
    });

    builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
      @Override
      public void onClick(DialogInterface dialog, int which) {
        // Do nothing
      }
    });

    return builder.create();
  }
}




Java Source Code List

.argmin.java
com.example.pololanguage.pologo.ApplicationTest.java
com.pololanguage.pologo.BoardActivity.java
com.pololanguage.pologo.BoardFragment.java
com.pololanguage.pologo.QuitDialogFragment.java
com.pololanguage.pologo.SelectorActivity.java
com.pololanguage.pologo.StoneColor.java
com.pololanguage.pologo.StoredMove.java