1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
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 |
|
import net.sourceforge.subsonic.androidapp.R; |
25 |
|
|
26 |
|
|
27 |
|
@author |
28 |
|
|
|
|
| 0% |
Uncovered Elements: 21 (21) |
Complexity: 6 |
Complexity Density: 0,46 |
|
29 |
|
public class ErrorDialog { |
30 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
31 |
0
|
public ErrorDialog(Activity activity, int messageId, boolean finishActivityOnCancel) {... |
32 |
0
|
this(activity, activity.getResources().getString(messageId), finishActivityOnCancel); |
33 |
|
} |
34 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 1 |
Complexity Density: 0,12 |
|
35 |
0
|
public ErrorDialog(final Activity activity, String message, final boolean finishActivityOnClose) {... |
36 |
|
|
37 |
0
|
AlertDialog.Builder builder = new AlertDialog.Builder(activity); |
38 |
0
|
builder.setIcon(android.R.drawable.ic_dialog_alert); |
39 |
0
|
builder.setTitle(R.string.error_label); |
40 |
0
|
builder.setMessage(message); |
41 |
0
|
builder.setCancelable(true); |
42 |
0
|
builder.setOnCancelListener(new DialogInterface.OnCancelListener() { |
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
43 |
0
|
@Override... |
44 |
|
public void onCancel(DialogInterface dialogInterface) { |
45 |
0
|
if (finishActivityOnClose) { |
46 |
0
|
activity.finish(); |
47 |
|
} |
48 |
|
} |
49 |
|
}); |
50 |
0
|
builder.setPositiveButton(R.string.common_ok, new DialogInterface.OnClickListener() { |
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
51 |
0
|
@Override... |
52 |
|
public void onClick(DialogInterface dialogInterface, int i) { |
53 |
0
|
if (finishActivityOnClose) { |
54 |
0
|
activity.finish(); |
55 |
|
} |
56 |
|
} |
57 |
|
}); |
58 |
|
|
59 |
0
|
builder.create().show(); |
60 |
|
} |
61 |
|
} |