Android Open Source - irma_android_cardproxy Confirmation Dialog Fragment






From Project

Back to project page irma_android_cardproxy.

License

The source code is released under:

GNU General Public License

If you think the Android project irma_android_cardproxy 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 org.irmacard.androidcardproxy;
//from  w  w w.  j a  v  a 2  s  .  co  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 ConfirmationDialogFragment extends DialogFragment {
  
  public interface ConfirmationDialogListener {
    public void onConfirmationPositive();
    public void onConfirmationNegative();
  }
  
  ConfirmationDialogListener mListener;
  
  public static ConfirmationDialogFragment newInstance(String message) {
    ConfirmationDialogFragment f = new ConfirmationDialogFragment();
    Bundle args = new Bundle();
    args.putString("message", message);
    f.setArguments(args);
    return f;
  }
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        // Use the Builder class for convenient dialog construction
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setMessage(getArguments().getString("message"))
              .setTitle("Please confirm")
               .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                   public void onClick(DialogInterface dialog, int id) {
                       mListener.onConfirmationPositive();
                   }
               })
               .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                   public void onClick(DialogInterface dialog, int id) {
                       mListener.onConfirmationNegative();
                   }
               });
        // Create the AlertDialog object and return it
        return builder.create();
    }
    // Override the Fragment.onAttach() method to instantiate the ConfirmationDialogListener
    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        // Verify that the host activity implements the callback interface
        try {
            // Instantiate the ConfirmationDialogListener so we can send events to the host
            mListener = (ConfirmationDialogListener) activity;
        } catch (ClassCastException e) {
            // The activity doesn't implement the interface, throw exception
            throw new ClassCastException(activity.toString()
                    + " must implement PINDialogListener");
        }
    }
}




Java Source Code List

org.irmacard.androidcardproxy.ConfirmationDialogFragment.java
org.irmacard.androidcardproxy.MainActivity.java
org.irmacard.androidcardproxy.ProtocolCommandDeserializer.java
org.irmacard.androidcardproxy.ProtocolResponseSerializer.java
org.irmacard.androidcardproxy.messages.EventArguments.java
org.irmacard.androidcardproxy.messages.PinResultArguments.java
org.irmacard.androidcardproxy.messages.ReaderMessageArguments.java
org.irmacard.androidcardproxy.messages.ReaderMessageDeserializer.java
org.irmacard.androidcardproxy.messages.ReaderMessage.java
org.irmacard.androidcardproxy.messages.ResponseArguments.java
org.irmacard.androidcardproxy.messages.SelectAppletArguments.java
org.irmacard.androidcardproxy.messages.TransmitCommandSetArguments.java