DialogPersoComplexResultados.java
6.6 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
package com.focasoftware.deboinventario;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import java.util.ArrayList;
import java.util.HashMap;
/**
* Dialogo personalizado donde se muestran los resultados de una bsqueda
* @author GuillermoR
*
*/
public class DialogPersoComplexResultados extends Dialog {
@NonNull
private HashMap<Integer,Integer> codigos_articulo_seleccionado = new HashMap<Integer, Integer>();
/**
* Constructor
* <p>1 Carga contexto y titulo
* <p>2 Cargamos el layout y main layout
* <p>3 Boton de cancel
* <p>4 Carga tabla central
* <p> 4.1 Listeners y handlers de las lineas de resultado
*
* @param context
* @param lista_propuestas Los resultados de la busqueda?
* @param listenerSeleccionar Que hace al seleccionar uno
* @param listenerCancel Que hace al cancelar
*/
public DialogPersoComplexResultados(
@NonNull Context context,
@NonNull ArrayList<HashMap<Integer, Object>> lista_propuestas,
View.OnClickListener listenerSeleccionar/*View.OnLongClickListener listenerSeleccionar*/,
View.OnClickListener listenerCancel
) {
//1� Carga contexto y titulo:
super(context);
final Activity owner = (Activity) context;
/**
* Ver como se hace para que seleccione de donde viene la llamada y no agregue
* lo de presione 2 veces su eleccin
*/
super.setTitle(lista_propuestas.size() + " resultados - Presione 2 veces su eleccion");
//2 Cargamos el layout y main layout:
super.setContentView(R.layout.z_dialogpersocomplexresultados);
//3 Boton de cancel:
Button boton_cancelar = (Button) super.findViewById(R.id.Z_DIALOG_boton_cancelar);
boton_cancelar.setOnClickListener(listenerCancel);
//4 Carga tabla central:
//TableLayout tabla_resultados = (TableLayout)super.findViewById(R.id.Z_DIALOG_tabla_resultados);
LinearLayout tabla_resultados = (LinearLayout)super.findViewById(R.id.Z_DIALOG_tabla_resultados);
final GestorLogEventos log = new GestorLogEventos();
log.setUbicacion(ParametrosInventario.CARPETA_LOGTABLET);
log.tipo_0 = Parametros.PREF_LOG_EVENTOS;
log.tipo_2 = Parametros.PREF_LOG_PROCESOS;
log.tipo_3 = Parametros.PREF_LOG_MENSAJES;
log.tipo_4 = Parametros.PREF_LOG_EXCEPCIONES;
log.log("[-- 75 --]" + "Inicio de Dialog Perso Complex Resultados", 2);
for (HashMap<Integer, Object> hmap : lista_propuestas) {
//Se programo en XML
// TableRow tr = new TableRow(context);
// TextView tv0 = new TextView(context);
// TextView tv1 = new TextView(context);
// TextView tv2 = new TextView(context);
//
LayoutInflater inflater = (LayoutInflater)owner.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
// TableRow linea = (TableRow) inflater.inflate(R.layout.z_linea_busqueda_resultados, null);
// tabla_resultados.addView(linea);
LinearLayout linea = (LinearLayout) inflater.inflate(R.layout.z_linea_busqueda_resultados, null);
// TextView tv0=(TextView)linea.getChildAt(COLUMNA_NOMBRE);
// TextView tv1=(TextView)linea.getChildAt(COLUMNA_SECTOR);
// TextView tv2=(TextView)linea.getChildAt(COLUMNA_CODIGO);
TextView tv0=(TextView)linea.findViewById(R.id.textViewResultado);
TextView tv1=(TextView)linea.findViewById(R.id.textViewSector);
TextView tv2=(TextView)linea.findViewById(R.id.textViewCodigo);
//Modificado 09/05/12 para que se muestre en la linea el codigo y sector
String codSec,codArt,nombre;
codSec=String.valueOf(hmap.get(ParametrosInventario.clave_art_sector));
codArt=String.valueOf(hmap.get(ParametrosInventario.clave_art_codigo));
nombre=String.valueOf(hmap.get(ParametrosInventario.clave_art_nombre));
tv0.setText(codSec+"-"+codArt+" : "+nombre);
//Old
// tv0.setText(String.valueOf(hmap.get(ParametrosInventario.clave_art_nombre)));
// tv0.setTextColor(owner.getResources().getColor(R.color.white));
// tv0.setBackgroundColor(owner.getResources().getColor(R.color.verde_oscuro));
// tv0.setTextSize(18);
// tv0.setPadding(2, 2, 2, 2);
tv1.setText(String.valueOf(hmap.get(ParametrosInventario.clave_art_sector)));
// tv1.setVisibility(View.GONE);
tv2.setText(String.valueOf(hmap.get(ParametrosInventario.clave_art_codigo)));
// tv2.setVisibility(View.GONE);
// tr.addView(tv0);
// tr.addView(tv1);
// tr.addView(tv2);
//4.1 Listeners y handlers de las lineas de resultado
linea.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, @NonNull MotionEvent event) {
log.log("[-- 123 --]" + "Selecciono un producto", 0);
LinearLayout trow = (LinearLayout)v;
TextView tv1=(TextView)trow.findViewById(R.id.textViewSector);
TextView tv2=(TextView)trow.findViewById(R.id.textViewCodigo);
if (event.getAction() == MotionEvent.ACTION_DOWN) {
codigos_articulo_seleccionado.clear();
codigos_articulo_seleccionado.put(ParametrosInventario.clave_art_sector, Integer.parseInt(String.valueOf(tv1.getText())));
codigos_articulo_seleccionado.put(ParametrosInventario.clave_art_codigo, Integer.parseInt(String.valueOf(tv2.getText())));
int sector = Integer.parseInt(String.valueOf(tv1.getText()));
int codigo = Integer.parseInt(String.valueOf(tv2.getText()));
log.log("[-- 136 --]" + "codigo articulo: " + codigo + "sector: " + sector , 2);
//((TextView)trow.getChildAt(COLUMNA_NOMBRE)).setBackgroundColor(owner.getResources().getColor(R.color.orange));
}
/*else if (event.getAction() == MotionEvent.ACTION_UP) {
TableLayout padre = (TableLayout)trow.getParent();
for (int i = 0 ; i < padre.getChildCount() ; i++) {
TableRow lineaOnFoco = (TableRow) padre.getChildAt(i);
TextView casilla = (TextView) lineaOnFoco.getChildAt(COLUMNA_NOMBRE);
casilla.setBackgroundColor(owner.getResources().getColor(R.color.verde_oscuro));
}
}*/
return false;
}
});
//tr.setOnLongClickListener(listenerSeleccionar);
linea.setOnClickListener(listenerSeleccionar);
// linea.setBackgroundColor(owner.getResources().getColor(R.color.white));
// linea.setPadding(1, 1, 1, 0);
tabla_resultados.addView(linea);
}
}
@NonNull
public HashMap<Integer, Integer> get_codigos_articulo_seleccionado() {
return codigos_articulo_seleccionado;
}
}