fragments.SavePicker.java Source code

Java tutorial

Introduction

Here is the source code for fragments.SavePicker.java

Source

package fragments;

import common.InterfaceClass;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.View;
import android.widget.Toast;
import asynctasks.UpdateTicketDataAsync;

public class SavePicker extends DialogFragment {

    public InterfaceClass iCcallback;
    public AlertDialog dialog;

    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        try {
            iCcallback = (InterfaceClass) activity;
        } catch (ClassCastException e) {
            throw new ClassCastException(activity.toString() + " must implement InterfaceClass");
        }
    }

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {

        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()).setTitle("Save Changes?")
                .setPositiveButton("OK", null).setNegativeButton("CANCEL", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dismiss();
                    }
                });

        dialog = builder.create();

        dialog.show();
        dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                String id, ticket, name, cartype, model, color, license, park, key;

                Bundle myArgs = getArguments();
                id = myArgs.getString("id");
                ticket = myArgs.getString("ticket");
                name = myArgs.getString("name");
                cartype = myArgs.getString("cartype");
                model = myArgs.getString("model");
                color = myArgs.getString("color");
                license = myArgs.getString("license");
                park = myArgs.getString("park");
                key = myArgs.getString("key");

                UpdateTicketDataAsync task = new UpdateTicketDataAsync(getActivity(), getFragmentManager());
                task.execute(id, ticket, name, cartype, model, color, license, park, key);

            }
        });

        return dialog;
    }

}

//new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) {   
//
//String ticket, name, date, cartype, model, color, license, park, key;
//
//Bundle myArgs = getArguments();
//ticket = myArgs.getString("ticket");
//name = myArgs.getString("name");
//date = myArgs.getString("date");
//cartype = myArgs.getString("cartype");
//model = myArgs.getString("model");
//color = myArgs.getString("color");
//license = myArgs.getString("license");
//park = myArgs.getString("park");
//key = myArgs.getString("key");
//
//UpdateTicketDataAsync task = new UpdateTicketDataAsync(getActivity(), getFragmentManager());
//task.execute(ticket, name, date, cartype, model, color, license, park, key);
//
//iCcallback.updateTicket(true);
//
//}})