1 package de.example.exampletdd.fragment;
3 import android.app.Dialog;
4 import android.app.ProgressDialog;
5 import android.content.DialogInterface;
6 import android.os.Bundle;
7 import android.support.v4.app.DialogFragment;
8 import android.view.KeyEvent;
10 public class ProgressDialogFragment extends DialogFragment {
12 public static ProgressDialogFragment newInstance(final int title) {
13 return newInstance(title, null);
16 public static ProgressDialogFragment newInstance(final int title,
17 final String message) {
18 final ProgressDialogFragment frag = new ProgressDialogFragment();
19 final Bundle args = new Bundle();
21 args.putInt("title", title);
22 args.putString("message", message);
23 frag.setArguments(args);
28 public Dialog onCreateDialog(final Bundle savedInstanceState) {
29 final int title = this.getArguments().getInt("title");
30 final String message = this.getArguments().getString("message");
32 final ProgressDialog dialog = new ProgressDialog(this.getActivity());
33 dialog.setIcon(android.R.drawable.ic_dialog_info);
35 dialog.setTitle(title);
37 if (message != null) {
38 dialog.setMessage(message);
40 dialog.setCancelable(false);
41 this.setCancelable(false);
42 dialog.setIndeterminate(true);
43 dialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
46 public final boolean onKey(final DialogInterface dialog,
47 final int keyCode, final KeyEvent event) {