DialogPersoComplexSiNoInvComp.java
2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package com.focasoftware.deboinventario;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
/**
* Dialogo personalizado que presenta al usuario la opcion de elegir entre una accion
* positiva y otra negativa
* @author GuillermoR
*
*/
public class DialogPersoComplexSiNoInvComp extends Dialog {
/**
* Quien llamo a este dialog, aparentemente en desuso
*/
private Activity owner;
/**
* Constructor que inicializa la UI y los handlers
* <p>1 Construccin del ttulo
* <p>2 Cargamos el layout y main layout
* <p>3 Construccin de la imagen
* <p>4 Mensaje
* <p>5 Botones y handlers
*
* @param context
* @param titulo
* @param mensaje
* @param categoria_alerta
* @param listenerPositivo
* @param listenerNegativo
*/
public DialogPersoComplexSiNoInvComp(Context context,
String titulo, String mensaje, int categoria_alerta,
View.OnClickListener listenerPositivo, View.OnClickListener listenerNegativo) {
super(context);
final Activity owner = (Activity) context;
//1 Construccin del ttulo:
if (titulo.length() > 0) {
super.setTitle(titulo);
}
//2 Cargamos el layout y main layout:
super.setContentView(R.layout.z_dialogpersocomplex_sino);
//3 Construccin de la imagen:
ImageView imagen = (ImageView) super.findViewById(R.id.DIALOG_imagen);
switch (categoria_alerta) {
case DialogPerso.DEFAULT:
imagen.setImageDrawable(owner.getResources().getDrawable(R.drawable.dialog_alertar));
break;
case DialogPerso.VALIDAR:
imagen.setImageDrawable(owner.getResources().getDrawable(R.drawable.dialog_validar));
break;
case DialogPerso.ALERTAR:
imagen.setImageDrawable(owner.getResources().getDrawable(R.drawable.dialog_alertar));
break;
case DialogPerso.PROHIBIR:
imagen.setImageDrawable(owner.getResources().getDrawable(R.drawable.dialog_prohibir));
break;
default:
imagen.setImageDrawable(owner.getResources().getDrawable(R.drawable.dialog_alertar));
break;
}
//4 Mensaje:
TextView texto = (TextView) super.findViewById(R.id.DIALOG_texto);
texto.setText(mensaje);
//5 Botones y handlers:
Button boton_validar = (Button) super.findViewById(R.id.DIALOG_boton_validar);
Button boton_cancelar = (Button) super.findViewById(R.id.DIALOG_boton_cancelar);
if (listenerNegativo != null) {
boton_validar.setOnClickListener(listenerPositivo);
boton_cancelar.setOnClickListener(listenerNegativo);
} else {
boton_validar.setOnClickListener(listenerPositivo);
boton_validar.setText("OK");
boton_cancelar.setVisibility(View.GONE);
}
}
}