~cmiller/ubuntuone-android-music/goog-analytics

« back to all changes in this revision

Viewing changes to src/net/sourceforge/subsonic/androidapp/util/ErrorDialog.java

  • Committer: sindre_mehus
  • Date: 2009-10-03 08:14:28 UTC
  • Revision ID: svn-v4:24148959-8e0e-0410-9c20-a6ce11f09cd5:trunk/subsonic-android:1069
Android: Changed package name.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 This file is part of Subsonic.
 
3
 
 
4
 Subsonic is free software: you can redistribute it and/or modify
 
5
 it under the terms of the GNU General Public License as published by
 
6
 the Free Software Foundation, either version 3 of the License, or
 
7
 (at your option) any later version.
 
8
 
 
9
 Subsonic is distributed in the hope that it will be useful,
 
10
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 GNU General Public License for more details.
 
13
 
 
14
 You should have received a copy of the GNU General Public License
 
15
 along with Subsonic.  If not, see <http://www.gnu.org/licenses/>.
 
16
 
 
17
 Copyright 2009 (C) Sindre Mehus
 
18
 */
 
19
package net.sourceforge.subsonic.androidapp.util;
 
20
 
 
21
import android.app.Activity;
 
22
import android.app.AlertDialog;
 
23
import android.content.DialogInterface;
 
24
 
 
25
/**
 
26
 * @author Sindre Mehus
 
27
 */
 
28
public class ErrorDialog {
 
29
 
 
30
    public ErrorDialog(final Activity activity, String errorMessage, final boolean finishActivityOnCancel) {
 
31
 
 
32
        AlertDialog.Builder builder = new AlertDialog.Builder(activity);
 
33
        builder.setIcon(android.R.drawable.ic_dialog_alert);
 
34
        builder.setTitle("Error");
 
35
        builder.setMessage(errorMessage);
 
36
        builder.setCancelable(true);
 
37
        builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
 
38
            @Override
 
39
            public void onCancel(DialogInterface dialogInterface) {
 
40
                if (finishActivityOnCancel) {
 
41
                    activity.finish();
 
42
                }
 
43
            }
 
44
        });
 
45
        builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
 
46
            @Override
 
47
            public void onClick(DialogInterface dialogInterface, int i) {
 
48
                if (finishActivityOnCancel) {
 
49
                    activity.finish();
 
50
                }
 
51
            }
 
52
        });
 
53
 
 
54
        builder.create().show();
 
55
    }
 
56
}