1 | package ve.gob.cenditel.tibisaymovil; |
---|
2 | |
---|
3 | |
---|
4 | import android.annotation.SuppressLint; |
---|
5 | import android.content.Context; |
---|
6 | import android.view.LayoutInflater; |
---|
7 | import android.view.View; |
---|
8 | import android.view.ViewGroup; |
---|
9 | import android.widget.ArrayAdapter; |
---|
10 | import android.widget.ImageView; |
---|
11 | import android.widget.TextView; |
---|
12 | |
---|
13 | /** |
---|
14 | * Adaptador para mostrar la lista de funciones disponibles al inicio |
---|
15 | * de la aplicación. |
---|
16 | * |
---|
17 | */ |
---|
18 | public class FunctionListAdapter extends ArrayAdapter<String> { |
---|
19 | private final Context context; |
---|
20 | private final String[] values; |
---|
21 | |
---|
22 | public FunctionListAdapter(Context context, String[] values) { |
---|
23 | super(context, R.layout.list_item, values); |
---|
24 | this.context = context; |
---|
25 | this.values = values; |
---|
26 | } |
---|
27 | |
---|
28 | @Override |
---|
29 | public View getView(int position, View convertView, ViewGroup parent) { |
---|
30 | LayoutInflater inflater = (LayoutInflater) context |
---|
31 | .getSystemService(Context.LAYOUT_INFLATER_SERVICE); |
---|
32 | |
---|
33 | View rowView = inflater.inflate(R.layout.list_item, parent, false); |
---|
34 | TextView textView1 = (TextView) rowView.findViewById(R.id.textListMainMenu); |
---|
35 | textView1.setText(values[position]); |
---|
36 | ImageView imageView = (ImageView) rowView.findViewById(R.id.imageListMainMenu); |
---|
37 | |
---|
38 | // Change icon based on name |
---|
39 | String s = values[position]; |
---|
40 | |
---|
41 | System.out.println(s); |
---|
42 | |
---|
43 | if (s.equals(context.getString(R.string.firmar))) { |
---|
44 | imageView.setImageResource(R.drawable.ic_pluma); |
---|
45 | } else if (s.equals(context.getString(R.string.verificar))) { |
---|
46 | imageView.setImageResource(R.drawable.ic_verify); |
---|
47 | } else if (s.equals(context.getString(R.string.cifrar))) { |
---|
48 | imageView.setImageResource(R.drawable.ic_secure); |
---|
49 | } else if (s.equals(context.getString(R.string.descifrar))) { |
---|
50 | imageView.setImageResource(R.drawable.ic_not_secure); |
---|
51 | } else if (s.equals(context.getString(R.string.compartir))) { |
---|
52 | imageView.setImageResource(R.drawable.ic_share); |
---|
53 | } else if (s.equals(context.getString(R.string.certificados))) { |
---|
54 | imageView.setImageResource(R.drawable.ic_management); |
---|
55 | } else if (s.equals(context.getString(R.string.preferencias))) { |
---|
56 | imageView.setImageResource(R.drawable.ic_preferences); |
---|
57 | } |
---|
58 | return rowView; |
---|
59 | } |
---|
60 | } |
---|