Android Open Source - flashcards Delete Deck Dialog






From Project

Back to project page flashcards.

License

The source code is released under:

MIT License

If you think the Android project flashcards 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 edu.cmu.hcii.ssui.flashcards.dialogs;
/*from  w w w .  j  ava2 s. c o m*/
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import edu.cmu.hcii.ssui.flashcards.Deck.DeckMutator;
import edu.cmu.hcii.ssui.flashcards.util.ArgUtil;
import edu.cmu.hcii.ssui.flashcards.R;

public class DeleteDeckDialog extends DialogFragment {

    private DeckMutator mDeckMutator;

    public static DeleteDeckDialog newInstance(long deckId) {
        DeleteDeckDialog dialog = new DeleteDeckDialog();
        Bundle args = new Bundle();
        args.putLong(ArgUtil.ARG_DECK_ID, deckId);
        dialog.setArguments(args);
        return dialog;
    }

    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);

        try {
            mDeckMutator = (DeckMutator) activity;
        } catch (ClassCastException e) {
            throw new ClassCastException(activity.toString() + " must implement DeckMutator");
        }
    }

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        final Context ctx = getActivity();
        final long deckId = getArguments().getLong(ArgUtil.ARG_DECK_ID);

        return new AlertDialog.Builder(ctx)
                .setTitle(R.string.delete_deck_title)
                .setMessage(R.string.delete_deck_message)
                .setPositiveButton(R.string.delete_deck_button,
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                mDeckMutator.deleteDeck(deckId);
                            }
                        })
                .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        // TODO: Cancel delete deck.

                    }
                }).create();
    }

}




Java Source Code List

edu.cmu.hcii.ssui.flashcards.CardListActivity.java
edu.cmu.hcii.ssui.flashcards.Card.java
edu.cmu.hcii.ssui.flashcards.Deck.java
edu.cmu.hcii.ssui.flashcards.StudyActivity.java
edu.cmu.hcii.ssui.flashcards.StudyListActivity.java
edu.cmu.hcii.ssui.flashcards.db.CardContract.java
edu.cmu.hcii.ssui.flashcards.db.CardDatabase.java
edu.cmu.hcii.ssui.flashcards.db.CardDbHelper.java
edu.cmu.hcii.ssui.flashcards.dialogs.DeleteCardDialog.java
edu.cmu.hcii.ssui.flashcards.dialogs.DeleteDeckDialog.java
edu.cmu.hcii.ssui.flashcards.dialogs.EditCardDialog.java
edu.cmu.hcii.ssui.flashcards.dialogs.EditDeckDialog.java
edu.cmu.hcii.ssui.flashcards.dialogs.NewCardDialog.java
edu.cmu.hcii.ssui.flashcards.dialogs.NewDeckDialog.java
edu.cmu.hcii.ssui.flashcards.util.ArgUtil.java