Android Open Source - OneSearch Pause Dialog Fragment






From Project

Back to project page OneSearch.

License

The source code is released under:

MIT License

If you think the Android project OneSearch 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 chrisjluc.funsearch.ui.gameplay;
//w w w .j  av  a2 s.c  om
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;

import chrisjluc.funsearch.R;

public class PauseDialogFragment extends DialogFragment {

    private PauseDialogListener mListener;

    public Dialog onCreateDialog(Bundle savedInstanceState) {
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        Activity activity = getActivity();
        LayoutInflater inflater = activity.getLayoutInflater();
        View layout = inflater.inflate(R.layout.fragment_gameplay_dialog, null);
        Button resumeButton = (Button) layout.findViewById(R.id.bResume);
        Button restartButton = (Button) layout.findViewById(R.id.bRestart);
        Button quitButton = (Button) layout.findViewById(R.id.bQuit);
        resumeButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                getDialog().dismiss();
                mListener.onDialogResume();
            }
        });
        restartButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                getDialog().dismiss();
                mListener.onDialogRestart();
            }
        });
        quitButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                getDialog().dismiss();
                mListener.onDialogQuit();
            }
        });

        builder.setView(layout);
        Dialog dialog = builder.create();
        dialog.setCanceledOnTouchOutside(false);
        return dialog;
    }

    @Override
    public void onCancel(DialogInterface dialog) {
        mListener.onDialogResume();
        super.onCancel(dialog);
    }

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

    @Override
    public void onDetach() {
        super.onDetach();
        mListener = null;
    }

    public interface PauseDialogListener {
        public void onDialogQuit();

        public void onDialogResume();

        public void onDialogRestart();
    }
}




Java Source Code List

chrisjluc.funsearch.ApplicationTest.java
chrisjluc.funsearch.WordSearchManager.java
chrisjluc.funsearch.adapters.WordSearchGridAdapter.java
chrisjluc.funsearch.adapters.WordSearchPagerAdapter.java
chrisjluc.funsearch.base.BaseActivity.java
chrisjluc.funsearch.models.GameDifficulty.java
chrisjluc.funsearch.models.GameMode.java
chrisjluc.funsearch.models.GameType.java
chrisjluc.funsearch.ui.MenuActivity.java
chrisjluc.funsearch.ui.ResultsActivity.java
chrisjluc.funsearch.ui.components.GameButton.java
chrisjluc.funsearch.ui.components.GameTextView.java
chrisjluc.funsearch.ui.gameplay.PauseDialogFragment.java
chrisjluc.funsearch.ui.gameplay.WordSearchActivity.java
chrisjluc.funsearch.ui.gameplay.WordSearchFragment.java
chrisjluc.funsearch.ui.gameplay.WordSearchGridView.java
chrisjluc.funsearch.ui.gameplay.WordSearchViewPager.java
chrisjluc.funsearch.wordSearchGenerator.generators.DistinctRandomGenerator.java
chrisjluc.funsearch.wordSearchGenerator.generators.WordSearchGenerator.java
chrisjluc.funsearch.wordSearchGenerator.models.Node.java
chrisjluc.funsearch.wordSearchGenerator.models.Point.java
chrisjluc.funsearch.wordSearchGenerator.models.PossibleInstance.java