2 * Copyright 2014 Gustavo Martin Morcuende
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package name.gumartinm.weather.information.fragment;
18 import android.app.AlertDialog;
19 import android.app.Dialog;
20 import android.content.DialogInterface;
21 import android.os.Bundle;
22 import android.support.v4.app.DialogFragment;
24 public class ErrorDialogFragment extends DialogFragment {
26 public static ErrorDialogFragment newInstance(final int title) {
27 final ErrorDialogFragment frag = new ErrorDialogFragment();
28 final Bundle args = new Bundle();
30 args.putInt("title", title);
31 frag.setArguments(args);
37 public Dialog onCreateDialog(final Bundle savedInstanceState) {
38 final int title = this.getArguments().getInt("title");
40 return new AlertDialog.Builder(this.getActivity())
41 .setIcon(android.R.drawable.ic_dialog_alert)
43 .setPositiveButton(android.R.string.ok,
44 new DialogInterface.OnClickListener() {
46 public void onClick(final DialogInterface dialog,
47 final int whichButton) {
54 public void onDestroyView() {
55 if (getDialog() != null && getRetainInstance()) {
56 getDialog().setDismissMessage(null);
58 super.onDestroyView();